Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_add.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_build.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_changed.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_diff-sources.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_history.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_list.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_metadata.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_query.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_render.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_test.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/user/reference/cli/azldev_component_update.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion docs/user/reference/config/overlays.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Overlays are defined within a component's configuration in your TOML config file

### Spec Overlays

These overlays modify `.spec` files using the component command's `--spec-editor` option. The default `legacy` editor is line-oriented; `--spec-editor experimental` selects the structural editor, which preserves conditional and section structure.
These overlays modify `.spec` files using the component command's `--spec-editor` option. The default `structural` editor preserves conditional and section structure; `--spec-editor legacy` selects the line-oriented legacy editor.

The `legacy` editor is deprecated and will be removed in a future release. Explicit use emits a warning; migrate existing invocations to `structural` or omit `--spec-editor`.

#### Known Limitations

Expand Down
8 changes: 8 additions & 0 deletions internal/app/azldev/agentskill/agentskill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ func TestComponentTomlSkillDocumentsRPMDevBumpspecPreview(t *testing.T) {
assert.Contains(t, doc, "no bumpspec runtime discovery occurs")
}

func TestOverlaysSkillDocumentsSpecEditorDeprecation(t *testing.T) {
doc, err := agentskill.SkillDocument("azldev-overlays", testParams())
require.NoError(t, err)
assert.Contains(t, doc, "The structural editor is the default")
assert.Contains(t, doc, "The `legacy` editor is deprecated")
assert.Contains(t, doc, "The former `experimental` value is no longer accepted")
}

func TestImageSkillDocumentsSKUGroupGuidance(t *testing.T) {
doc, err := agentskill.SkillDocument("azldev-image", testParams())
require.NoError(t, err)
Expand Down
7 changes: 7 additions & 0 deletions internal/app/azldev/agentskill/content/overlays.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ overlays before it stay applied.
Config errors reference the offending overlay by its `description`, so give every
overlay a short, specific `description`.

## Spec editor selection

The structural editor is the default. It preserves conditional and section structure
more reliably than the line-oriented editor. The `legacy` editor is deprecated and
emits a warning when selected with `--spec-editor legacy`; it will be removed in a
future release. The former `experimental` value is no longer accepted.
Comment on lines +38 to +41

## Diagnose common failures

Start with `azldev comp diff-sources -p <name>` to see the exact overlay effect.
Expand Down
26 changes: 16 additions & 10 deletions internal/app/azldev/cmds/component/speceditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ package component

import (
"fmt"
"log/slog"

"github.com/microsoft/azure-linux-dev-tools/internal/rpm/spec"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

const (
specEditorLegacy = "legacy"
specEditorExperimental = "experimental"
// specEditorLegacy remains supported temporarily for backward compatibility.
// It is deprecated and will be removed in a future release.
specEditorLegacy = "legacy"
specEditorStructural = "structural"
)

// componentCommandOptions are shared by component subcommands that edit specs.
Expand All @@ -23,7 +26,7 @@ type componentCommandOptions struct {

func (o componentCommandOptions) specEditorMode() spec.EditorMode {
if o.SpecEditor == "" {
return spec.EditorLegacy
return spec.EditorStructural
}

return o.SpecEditor
Expand All @@ -36,12 +39,12 @@ type specEditorFlagValue struct {
var _ pflag.Value = (*specEditorFlagValue)(nil)

func newSpecEditorFlagValue() *specEditorFlagValue {
return &specEditorFlagValue{mode: spec.EditorLegacy}
return &specEditorFlagValue{mode: spec.EditorStructural}
}

func (v *specEditorFlagValue) String() string {
if v.mode == spec.EditorStructural {
return specEditorExperimental
return specEditorStructural
}

return specEditorLegacy
Expand All @@ -51,12 +54,15 @@ func (v *specEditorFlagValue) Set(value string) error {
switch value {
case specEditorLegacy:
v.mode = spec.EditorLegacy
case specEditorExperimental:

slog.Warn("The RPM spec 'legacy' editor is deprecated and will be removed in a future release; " +
"use 'structural' instead")
case specEditorStructural:
v.mode = spec.EditorStructural
default:
return fmt.Errorf(
"unsupported RPM spec editor %#q; expected %#q or %#q",
value, specEditorLegacy, specEditorExperimental,
value, specEditorLegacy, specEditorStructural,
)
}

Expand All @@ -71,19 +77,19 @@ func addSpecEditorOption(cmd *cobra.Command) {
cmd.PersistentFlags().Var(
newSpecEditorFlagValue(),
"spec-editor",
"Select the RPM spec editor (legacy or experimental)",
"Select the RPM spec editor ('structural' or deprecated 'legacy')",
)
}

func specEditorFromCommand(cmd *cobra.Command) spec.EditorMode {
flag := cmd.Flags().Lookup("spec-editor")
if flag == nil {
return spec.EditorLegacy
return spec.EditorStructural
}

value, ok := flag.Value.(*specEditorFlagValue)
if !ok {
return spec.EditorLegacy
return spec.EditorStructural
}

return value.mode
Expand Down
Loading
Loading