Repository navigation
fix(locals): stack-name derivation reads vars/settings/env merged across imports (#2374) - #2623
Andriy Knysh (aknysh) wants to merge 10 commits into
Conversation
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
|
Important Cloud Posse Engineering Team Review RequiredThis pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes. To expedite this process, reach out to us on Slack in the |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughFixes ChangesStack-name derivation fix with import overlay
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2623 +/- ##
==========================================
+ Coverage 80.44% 80.46% +0.01%
==========================================
Files 1444 1444
Lines 134759 134824 +65
==========================================
+ Hits 108406 108482 +76
+ Misses 20348 20329 -19
- Partials 6005 6013 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…rivation Address review feedback: don't reinvent helpers that already exist, and keep shared helpers in a general package. - Promote pkg/config's import-path resolver to an exported, generally-named `ResolveStackImportFiles` (was `resolveAuthImportPaths`). It is a lite, YAML-only resolver already used by the auth-defaults pre-pass; the stack-name derivation pre-pass now reuses it so both resolve imports identically. - Delete the duplicated helpers from describe_locals.go: `resolveImportFilePathsForStackName`, `globMatchesWithExt`, `hasYAMLExt`, `findFirstExistingWithExt`, `mergeMapShallow`, and the `stackNameImportYAMLExts` var. Map merges now use stdlib `maps.Copy`; import resolution delegates to `cfg.ResolveStackImportFiles`. - deriveStackNameSections resolves the logical stack file name to a path under the stacks base so the shared resolver (which resolves `./` imports against the importing file's directory) sees a real path. No behavior change for stack-name derivation; the describe-locals integration tests and unit tests still pass, and the auth-loader tests cover the shared resolver. All touched functions remain >=80% covered.
|
💥 This pull request now has conflicts. Could you fix it Andriy Knysh (@aknysh)? 🙏 |
what
name_templatecan reference identifying values that live in a parent_defaults.yamlimport.deriveStackNameFromTemplatenow feeds vars + settings + env to the template (previously onlyvars), and rejects any rendering that contains<no value>(falling back to the filename) so a malformed identifier never reaches downstream code.deriveStackNameSectionsperforms a lite, YAML-only import walk that mergesvars/settings/envacross the leaf file and its transitive imports (imports are the base, the leaf overrides). It does not process Go templates or YAML functions; unresolvable paths and non-pure-YAML files are skipped; cycles are broken with avisitedset.describe localspath, plus unit tests for the new functions.why
name_template: "{{ .settings.* }}",describe locals -s <name>returnedstack not foundbecause the derivation only carriedvars, neversettings. So a settings-based name template could never resolve.name_templatereferencing anamespacedefined in a parent_defaults.yaml, the leaf-only render produced a malformed name like-prodbecause imported vars were never merged before derivation.locals:block (which routes derivation through the locals pre-pass). The new integration tests were verified failing before this change (stack not found: acme-prod/cloudlabs-plat-ue1-prod) and passing after.references
docs/fixes/2026-06-16-locals-name-template-import-derivation.mdSummary by CodeRabbit
Release Notes
Bug Fixes
name_templatereferences values provided via imported parent YAML defaults (varsand.settings).vars,settings, andenvduring derivation and safely handling missing values.Tests
vars/settingsindescribe locals, including cycle handling and invalid import scenarios.Documentation