Skip to content

feat(overlays): handle empty sections explicitly#208

Open
dmcilvaney wants to merge 1 commit into
microsoft:mainfrom
dmcilvaney:damcilva/allow-overlays-to-target-full-spec
Open

feat(overlays): handle empty sections explicitly#208
dmcilvaney wants to merge 1 commit into
microsoft:mainfrom
dmcilvaney:damcilva/allow-overlays-to-target-full-spec

Conversation

@dmcilvaney
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 22, 2026 23:10
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 explicit “whole-spec” behavior for spec overlays when section is omitted, avoiding the previous ambiguity where an empty section could be interpreted as the global section (especially for append). This fits into the overlays system by making overlay targeting rules clearer, enforcing invalid field combinations at config-validate time, and updating schema/docs/snapshots accordingly.

Changes:

  • Add Spec.PrependLines / Spec.AppendLines to insert lines at the very top/bottom of a spec file.
  • Update spec overlay application so spec-prepend-lines / spec-append-lines with no section target the whole file.
  • Tighten overlay validation to reject package when section is omitted for whole-file-capable overlays, and update schema/docs/snapshots/tests.

Reviewed changes

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

Show a summary per file
File Description
schemas/azldev.schema.json Updates schema descriptions for section/package to document whole-file targeting and the package constraint.
scenario/snapshots/TestSnapshotsContainer_config_generate-schema_stdout_1.snap Updates schema snapshot output to match new descriptions.
scenario/snapshots/TestSnapshots_config_generate-schema_stdout_1.snap Updates schema snapshot output to match new descriptions.
internal/rpm/spec/edit.go Adds whole-file prepend/append APIs on Spec.
internal/rpm/spec/edit_test.go Adds unit tests covering new PrependLines/AppendLines behavior.
internal/projectconfig/overlay.go Documents whole-file targeting semantics; adds validation rejecting package when section is omitted for applicable overlay types.
internal/projectconfig/overlay_test.go Adds validation test cases for whole-file targeting + invalid package usage.
internal/app/azldev/core/sources/overlays.go Routes empty-section prepend/append overlays to the new whole-file Spec methods.
internal/app/azldev/core/sources/overlays_test.go Adds tests for applying whole-file prepend/append and whole-file search/replace behavior.
docs/user/reference/config/overlays.md Documents whole-file targeting semantics and provides examples.

Comment on lines +210 to +216
// requireSectionIfPackageSet checks that, for overlays that may target either a single
// section or the entire spec file (indicated by omitting `section`), a `package` is only
// specified when a `section` is also specified. A package is always a sub-qualifier of
// a section, so specifying one without the other is meaningless.
requireSectionIfPackageSet := func() error {
if c.SectionName == "" && c.PackageName != "" {
return unexpectedField("package")
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