Skip to content

feat: add azldev advanced ct-tools config-dump command#55

Open
sameluch wants to merge 5 commits intomicrosoft:mainfrom
sameluch:add-ct-tools-config-dump
Open

feat: add azldev advanced ct-tools config-dump command#55
sameluch wants to merge 5 commits intomicrosoft:mainfrom
sameluch:add-ct-tools-config-dump

Conversation

@sameluch
Copy link
Copy Markdown

@sameluch sameluch commented Apr 1, 2026

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:

  • 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: --ct-config (required), --environment (required)

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)
Copilot AI review requested due to automatic review settings April 1, 2026 23:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/cttools with typed config structs, an include+deep-merge TOML loader, and a template resolver.
  • Wires up the new azldev advanced ct-tools config-dump Cobra 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.

sameluch added 2 commits April 2, 2026 00:39
- 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
Copilot AI review requested due to automatic review settings April 2, 2026 01:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

sameluch added 2 commits April 2, 2026 17:54
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.
Copilot AI review requested due to automatic review settings April 2, 2026 21:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

@sameluch sameluch marked this pull request as ready for review April 6, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants