Skip to content

fix(overlays): expand overlay files after config resolution#256

Open
liunan-ms wants to merge 1 commit into
microsoft:mainfrom
liunan-ms:liunan/overlay-files-post-resolution
Open

fix(overlays): expand overlay files after config resolution#256
liunan-ms wants to merge 1 commit into
microsoft:mainfrom
liunan-ms:liunan/overlay-files-post-resolution

Conversation

@liunan-ms

Copy link
Copy Markdown
Contributor

Summary

This updates overlay-files expansion so per-file overlay documents are loaded after component config resolution instead of during raw config file loading.

That means overlay-files can now be declared in default-component-config at the project, distro, or component-group level and inherited by every applicable component. Relative patterns are interpreted for each concrete component, so a shared default such as:

[default-component-config]
overlay-files = ["overlays/*.overlay.toml"]

can discover component-local overlay files for each component.

Behavior Changes

  • Allows overlay-files in default component config.
  • Applies inherited overlay-files to every component that receives that default.
  • Resolves inherited relative overlay-file globs relative to the concrete component config file, or the matched spec directory for spec-discovered components.
  • Treats overlay-file glob patterns with no matches as no-op instead of an error.
  • Clears OverlayFiles after expansion so overlays are not appended more than once.
  • Preserves component-level override behavior: a non-empty component overlay-files list replaces the inherited list.

Fixed #253

Resolve inherited overlay-file globs only after component defaults are merged so relative patterns can be interpreted for each concrete component. This also consumes the glob list after expansion to avoid duplicate overlay loading.
Copilot AI review requested due to automatic review settings June 26, 2026 23:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request moves overlay-files glob expansion from raw config-file loading to the component resolution phase, enabling overlay-files to be inherited via default-component-config (project/distro/component-group) and resolved relative to each concrete component (or spec directory for spec-discovered components).

Changes:

  • Expand and validate per-file overlay documents during component resolution (ExpandResolvedOverlayFiles), then clear OverlayFiles to prevent double expansion.
  • Adjust overlay-file glob semantics: patterns with no matches are treated as a no-op instead of an error, and invalid overlays are validated with clearer per-overlay context.
  • Update inheritance behavior so a non-empty overlay-files list overrides inherited values, plus update schema/snapshots/docs/tests to reflect the new behavior.

Reviewed changes

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

Show a summary per file
File Description
schemas/azldev.schema.json Updates schema description to reflect post-resolution overlay-file expansion and spec-dir-relative behavior.
scenario/snapshots/TestSnapshotsContainer_config_generate-schema_stdout_1.snap Updates generated schema snapshot description text.
scenario/snapshots/TestSnapshots_config_generate-schema_stdout_1.snap Updates generated schema snapshot description text.
internal/projectconfig/overlay_file.go Replaces loader-time expansion with ExpandResolvedOverlayFiles; changes no-match glob handling; validates overlays during overlay-file parsing.
internal/projectconfig/overlay_file_test.go Updates and expands unit tests for new no-op semantics, per-overlay validation, and post-resolution expansion behavior.
internal/projectconfig/loader.go Removes overlay-file expansion from raw config loading.
internal/projectconfig/component.go Updates OverlayFiles doc/schema tag and changes merge semantics so non-empty overlay-files override inherited values.
internal/projectconfig/component_test.go Adds tests covering overlay-files override vs inheritance behavior in merges.
internal/app/azldev/core/components/resolver.go Expands overlay-files after config inheritance is applied, using an appropriate reference directory (config dir or spec dir).
internal/app/azldev/core/components/resolver_test.go Adds resolver test ensuring spec-discovered components inherit and expand overlay-files defaults correctly.
docs/user/reference/config/overlays.md Updates user docs for new inheritance behavior, reference-dir rules, and no-op no-match semantics.
docs/user/reference/config/components.md Updates component config docs to reflect post-resolution expansion and inheritance semantics.

Comment on lines 463 to +466
// Apply inherited defaults to the component.
updatedComponentConfig, err = applyInheritedDefaultsToComponent(r.env, foundComponentConfig)
overlayFilesReferenceDir := overlayFilesReferenceDir(foundComponentConfig, specPath)

updatedComponentConfig, err = applyInheritedDefaultsToComponent(r.env, foundComponentConfig, overlayFilesReferenceDir)
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.

Move overlay-files expansion closer to component resolution

2 participants