Skip to content

Commit b41e1cd

Browse files
authored
feat: add configuration system (#4)
1 parent 4523adf commit b41e1cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+10960
-14
lines changed

cmd/azldev/azldev.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88

99
"github.com/microsoft/azure-linux-dev-tools/internal/app/azldev"
10+
"github.com/microsoft/azure-linux-dev-tools/internal/app/azldev/cmds/config"
1011
"github.com/microsoft/azure-linux-dev-tools/internal/app/azldev/cmds/docs"
1112
"github.com/microsoft/azure-linux-dev-tools/internal/app/azldev/cmds/version"
1213
)
@@ -28,6 +29,7 @@ func InstantiateApp() *azldev.App {
2829

2930
// Give top level command packages an opportunity to register their commands (or in some cases,
3031
// request post-init callbacks).
32+
config.OnAppInit(app)
3133
docs.OnAppInit(app)
3234
version.OnAppInit(app)
3335

cmd/azldev/azldev_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestInstantiateApp(t *testing.T) {
2222
t,
2323
topLevelCommandNames,
2424
[]string{
25+
"config",
2526
"docs",
2627
"version",
2728
},
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tools.imageCustomizer]
2+
containerTag = "mcr.microsoft.com/azurelinux/imagecustomizer:1"

defaultconfigs/defaultconfigs.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
package defaultconfigs
5+
6+
import (
7+
"embed"
8+
"fmt"
9+
"path/filepath"
10+
11+
"github.com/microsoft/azure-linux-dev-tools/internal/global/opctx"
12+
"github.com/microsoft/azure-linux-dev-tools/internal/utils/fileutils"
13+
)
14+
15+
// Embedfs-relative path to the root directory of the embedded filesystem.
16+
const embedfsRootDir = "/content"
17+
18+
// Name of the root default configuration file that should be loaded from these default files.
19+
const rootDefaultConfigFilename = "defaults.toml"
20+
21+
// The embedded filesystem containing compiled-in default configuration files. This configuration
22+
// defines distro-level defaults for consistency.
23+
//
24+
//go:embed content/*
25+
var content embed.FS
26+
27+
// CopyTo recursively copies the contents of the [content] embedded filesystem to the specified
28+
// destination path in the provided filesystem. Returns the path to the root configuration file
29+
// to load from the copied directory.
30+
func CopyTo(dryRunnable opctx.DryRunnable, fs opctx.FS, destPath string) (rootConfigFilePath string, err error) {
31+
sourceFS := fileutils.WrapEmbedFS(&content)
32+
33+
err = fileutils.CopyDirRecursiveCrossFS(
34+
dryRunnable,
35+
sourceFS, embedfsRootDir,
36+
fs, destPath,
37+
fileutils.CopyDirOptions{},
38+
)
39+
if err != nil {
40+
return "", fmt.Errorf("failed to copy default configs to '%s': %w", destPath, err)
41+
}
42+
43+
return filepath.Join(destPath, rootDefaultConfigFilename), nil
44+
}

docs/user/reference/cli/azldev.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/user/reference/cli/azldev_config.md

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/user/reference/cli/azldev_config_dump.md

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/user/reference/cli/azldev_config_generate-schema.md

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,31 @@ module github.com/microsoft/azure-linux-dev-tools
33
go 1.25.6
44

55
require (
6+
dario.cat/mergo v1.0.2
7+
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
68
github.com/auribuo/stylishcobra v1.0.1
79
github.com/bmatcuk/doublestar/v4 v4.10.0
810
github.com/briandowns/spinner v1.23.2
11+
github.com/brunoga/deep v1.3.1
912
github.com/charmbracelet/bubbles v1.0.0
1013
github.com/charmbracelet/gum v0.17.0
1114
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
15+
github.com/charmbracelet/x/term v0.2.2
16+
github.com/go-playground/validator/v10 v10.30.1
1217
github.com/google/renameio v1.0.1
18+
github.com/invopop/jsonschema v0.13.0
19+
github.com/jedib0t/go-pretty/v6 v6.7.8
20+
github.com/knqyf263/go-rpm-version v0.0.0-20240918084003-2afd7dc6a38f
1321
github.com/lmittmann/tint v1.1.3
1422
github.com/magefile/mage v1.15.0
1523
github.com/mark3labs/mcp-go v0.44.1
1624
github.com/mattn/go-isatty v0.0.20
1725
github.com/muesli/termenv v0.16.0
26+
github.com/nxadm/tail v1.4.11
1827
github.com/opencontainers/selinux v1.13.1
28+
github.com/pelletier/go-toml/v2 v2.2.4
1929
github.com/samber/lo v1.52.0
30+
github.com/samber/slog-multi v1.7.1
2031
github.com/spf13/afero v1.15.0
2132
github.com/spf13/cobra v1.10.2
2233
github.com/spf13/pflag v1.0.10
@@ -36,7 +47,6 @@ require (
3647
github.com/charmbracelet/harmonica v0.2.0 // indirect
3748
github.com/charmbracelet/x/ansi v0.11.6 // indirect
3849
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
39-
github.com/charmbracelet/x/term v0.2.2 // indirect
4050
github.com/clipperhouse/displaywidth v0.9.0 // indirect
4151
github.com/clipperhouse/stringish v0.1.1 // indirect
4252
github.com/clipperhouse/uax29/v2 v2.5.0 // indirect
@@ -45,10 +55,14 @@ require (
4555
github.com/davecgh/go-spew v1.1.1 // indirect
4656
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
4757
github.com/fatih/color v1.18.0 // indirect
58+
github.com/fsnotify/fsnotify v1.9.0 // indirect
59+
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
60+
github.com/go-playground/locales v0.14.1 // indirect
61+
github.com/go-playground/universal-translator v0.18.1 // indirect
4862
github.com/google/go-cmp v0.7.0 // indirect
4963
github.com/google/uuid v1.6.0 // indirect
5064
github.com/inconshreveable/mousetrap v1.1.0 // indirect
51-
github.com/invopop/jsonschema v0.13.0 // indirect
65+
github.com/leodido/go-urn v1.4.0 // indirect
5266
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
5367
github.com/mailru/easyjson v0.9.0 // indirect
5468
github.com/mattn/go-colorable v0.1.14 // indirect
@@ -60,13 +74,16 @@ require (
6074
github.com/rivo/uniseg v0.4.7 // indirect
6175
github.com/rogpeppe/go-internal v1.14.1 // indirect
6276
github.com/russross/blackfriday/v2 v2.1.0 // indirect
77+
github.com/samber/slog-common v0.20.0 // indirect
6378
github.com/spf13/cast v1.10.0 // indirect
6479
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
6580
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
6681
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
6782
go.yaml.in/yaml/v3 v3.0.4 // indirect
83+
golang.org/x/crypto v0.46.0 // indirect
6884
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect
6985
golang.org/x/term v0.38.0 // indirect
7086
golang.org/x/text v0.32.0 // indirect
87+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
7188
gopkg.in/yaml.v3 v3.0.1 // indirect
7289
)

0 commit comments

Comments
 (0)