Summary
In name_template mode, addAffectedSpaceliftAdminStack in internal/exec/describe_affected_utils_2.go renders both the admin-stack selector prefix (line 473) and the per-candidate stack prefix (line 512) against the same configAndStacksInfo.ComponentSection. Because both sides of the comparison always produce the same string, the adminStackContextPrefix == contextPrefix guard at line 523 is effectively a no-op, and the function can match the wrong admin stack when a component name repeats across stacks.
This is in contrast to the name_pattern else branches, which correctly use adminStackContext (the selector) for the admin-stack prefix and the candidate's own context for the per-candidate prefix.
Steps to reproduce
- Configure
stacks.name_template (instead of stacks.name_pattern).
- Have two stacks that share a component name, where one stack has
settings.spacelift.admin_stack_selector pointing to a specific admin component.
- Run
atmos describe-affected --include-dependents.
- Observe that the admin stack may be incorrectly identified because the prefix comparison is always equal.
Expected behavior
- The admin-stack prefix should be rendered using the selector context (
adminStackContext / adminStackContextSection).
- The per-candidate prefix should be rendered using the candidate component's own section (the iterated
componentSection).
Proposed fix
- adminStackContextPrefix, err = ProcessTmpl(atmosConfig, "spacelift-admin-stack-name-template", atmosConfig.Stacks.NameTemplate, configAndStacksInfo.ComponentSection, ...)
+ adminStackTemplateData := map[string]any{
+ cfg.VarsSectionName: adminStackContextSection,
+ }
+ adminStackContextPrefix, err = ProcessTmpl(atmosConfig, "spacelift-admin-stack-name-template", atmosConfig.Stacks.NameTemplate, adminStackTemplateData, ...)
...
- contextPrefix, err = ProcessTmpl(atmosConfig, "spacelift-stack-name-template", atmosConfig.Stacks.NameTemplate, configAndStacksInfo.ComponentSection, ...)
+ contextPrefix, err = ProcessTmpl(atmosConfig, "spacelift-stack-name-template", atmosConfig.Stacks.NameTemplate, componentSection, ...)
A fixture test covering name_template + spacelift admin_stack_selector + describe-affected-with-dependents should be added.
Context
Summary
In
name_templatemode,addAffectedSpaceliftAdminStackininternal/exec/describe_affected_utils_2.gorenders both the admin-stack selector prefix (line 473) and the per-candidate stack prefix (line 512) against the sameconfigAndStacksInfo.ComponentSection. Because both sides of the comparison always produce the same string, theadminStackContextPrefix == contextPrefixguard at line 523 is effectively a no-op, and the function can match the wrong admin stack when a component name repeats across stacks.This is in contrast to the
name_patternelsebranches, which correctly useadminStackContext(the selector) for the admin-stack prefix and the candidate's owncontextfor the per-candidate prefix.Steps to reproduce
stacks.name_template(instead ofstacks.name_pattern).settings.spacelift.admin_stack_selectorpointing to a specific admin component.atmos describe-affected --include-dependents.Expected behavior
adminStackContext/adminStackContextSection).componentSection).Proposed fix
A fixture test covering
name_template+spacelift admin_stack_selector+describe-affected-with-dependentsshould be added.Context
IgnoreMissingTemplateValuesto name-template call sites.