feat: add azldev advanced ct-tools config-dump command#55
Open
sameluch wants to merge 5 commits intomicrosoft:mainfrom
Open
feat: add azldev advanced ct-tools config-dump command#55sameluch wants to merge 5 commits intomicrosoft:mainfrom
azldev advanced ct-tools config-dump command#55sameluch wants to merge 5 commits intomicrosoft:mainfrom
Conversation
Add a new CLI command that parses Azure Linux distro configuration TOML files, recursively resolves includes via deep merge, expands koji-targets/build-roots/mock-options templates, filters to a specified Control Tower environment, and outputs the fully resolved config as JSON or YAML. New packages/files: - internal/app/azldev/core/cttools: types, TOML loader with glob include resolution and cycle detection, template resolver - internal/app/azldev/cmds/advanced/cttools.go: CLI wiring Flags: --config (required), --environment (required), --format (json|yaml)
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “Control Tower tools” CLI surface under azldev advanced ct-tools, with an initial config-dump subcommand that loads a distro TOML config (with recursive includes + deep merge), resolves koji/build-root/mock-option templates, filters to a single CT environment, and emits JSON/YAML.
Changes:
- Introduces
internal/app/azldev/core/cttoolswith typed config structs, an include+deep-merge TOML loader, and a template resolver. - Wires up the new
azldev advanced ct-tools config-dumpCobra command + generated CLI reference docs. - Adds scenario testdata and new tests covering JSON/YAML output and core resolver/loader behavior.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| scenario/testdata/cttools/versions/v1.toml | Adds version-specific distro config used by scenario tests. |
| scenario/testdata/cttools/templates/options.toml | Adds mock-options and build-root templates for scenario tests. |
| scenario/testdata/cttools/templates/koji-targets.toml | Adds koji target templates for scenario tests. |
| scenario/testdata/cttools/resources/ct-test.toml | Adds CT environment resource definitions for scenario tests. |
| scenario/testdata/cttools/distro.toml | Adds top-level distro config entrypoint with includes for scenario tests. |
| scenario/testdata/cttools/common.toml | Adds shared include patterns for templates/resources in scenario tests. |
| scenario/clismoke_test.go | Adds end-to-end smoke tests for ct-tools config-dump JSON/YAML output. |
| internal/app/azldev/core/cttools/types.go | Defines typed representation of the merged CT distro config (TOML/JSON/YAML tags). |
| internal/app/azldev/core/cttools/resolver.go | Implements template expansion and environment filtering. |
| internal/app/azldev/core/cttools/resolver_test.go | Adds unit coverage for template resolution + environment filtering. |
| internal/app/azldev/core/cttools/loader.go | Implements recursive include resolution + deep merge TOML loading. |
| internal/app/azldev/core/cttools/loader_test.go | Adds unit coverage for include resolution, globbing, deep merge, and cycle detection. |
| internal/app/azldev/cmds/advanced/cttools.go | Adds the Cobra command hierarchy and config-dump implementation. |
| internal/app/azldev/cmds/advanced/cttools_test.go | Adds basic command wiring tests for the new advanced subcommands. |
| internal/app/azldev/cmds/advanced/advanced.go | Registers ct-tools under the advanced top-level command. |
| docs/user/reference/cli/azldev_advanced.md | Updates generated CLI docs to include the new ct-tools subtree. |
| docs/user/reference/cli/azldev_advanced_ct-tools.md | Adds generated CLI docs for azldev advanced ct-tools. |
| docs/user/reference/cli/azldev_advanced_ct-tools_config-dump.md | Adds generated CLI docs for azldev advanced ct-tools config-dump. |
- Use opctx.FS abstraction in loader instead of raw os.ReadFile / filepath.Glob; thread fs parameter through LoadConfig and helpers - Rewrite loader_test.go to use testctx.NewCtx() + fileutils for in-memory filesystem instead of t.TempDir() / os.WriteFile - Return *DistroConfig from RunConfigDump and let the framework handle serialization via --output-format; drop custom --format flag and yaml dependency - Pass *azldev.Env to RunConfigDump; use env.FS() for filesystem access - Sort map keys before iteration and sort resolved koji targets by name for deterministic output across runs - Add slog.Debug calls when loading files and resolving includes - Rename --config to --ct-config to avoid ambiguity with global --config-file; add MarkFlagFilename for shell completion - Remove TestCTToolsConfigDumpYAML scenario test (YAML output dropped)
- Error on missing non-glob includes instead of silently succeeding, matching projectconfig/loader.go behavior (glob patterns with no matches still succeed silently) - Sort available environment names in FilterEnvironment error message for stable, testable output - templateSet iteration was already sorted from prior commit
The CI runner's working directory is the repo root, not scenario/, so filepath.Abs(testdata/...) resolved incorrectly. Use scenario/testdata/... to match the convention in other scenario tests.
The visited map was never cleared on recursion unwind, so diamond includes (same file included from two branches) were incorrectly flagged as circular. Replace with an inProgress stack (defer delete on exit) for true cycle detection and a separate loaded set to skip already-processed files. Extract resolveIncludes helper to stay within funlen limit. Add TestLoadConfig_DiamondInclude to cover the diamond pattern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new CLI command that parses Azure Linux distro configuration TOML files, recursively resolves includes via deep merge, expands koji-targets/build-roots/mock-options templates, filters to a specified Control Tower environment, and outputs the fully resolved config as JSON.
New packages/files:
Flags: --ct-config (required), --environment (required)