Repository navigation
fix(stacks): scope per-component auth to requested stack/components - #2642
Brian Ojeda (sgtoj) wants to merge 2 commits into
Conversation
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
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 (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughReorders ChangesAuth Resolution Ordering Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/exec/describe_stacks_component_processor_auth_test.go (1)
366-445: ⚡ Quick winConsolidate these two skip-auth scenarios into one table-driven test.
The two tests are structurally the same and differ only by filter setup. A table-driven form will reduce duplication and make additional skip-path cases easier to extend.
As per coding guidelines, "
**/*_test.go: Use table-driven tests for testing multiple scenarios in Go."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/exec/describe_stacks_component_processor_auth_test.go` around lines 366 - 445, The two test functions TestProcessComponentEntry_OutOfScopeStackSkipsAuth and TestProcessComponentEntry_OutOfScopeComponentSkipsAuth are structurally identical and differ only in their filter setup and component inputs. Consolidate them into a single table-driven test by defining a slice of test case structs that capture the differences (such as filterByStack value, components filter slice, stackFileName, and componentName), then iterate through the table executing the same test logic for each scenario. This will eliminate code duplication and make it easier to add additional skip-path test cases in the future.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/fixes/2026-06-20-secret-list-stack-scope-per-component-auth.md`:
- Around line 32-38: The fenced code block containing the log output starting
with "DEBU Created component-specific AuthManager..." is missing a language
identifier, which triggers markdownlint rule MD040. Add the language identifier
"text" to the opening fence of this code block by changing the opening triple
backticks from ``` to ```text.
---
Nitpick comments:
In `@internal/exec/describe_stacks_component_processor_auth_test.go`:
- Around line 366-445: The two test functions
TestProcessComponentEntry_OutOfScopeStackSkipsAuth and
TestProcessComponentEntry_OutOfScopeComponentSkipsAuth are structurally
identical and differ only in their filter setup and component inputs.
Consolidate them into a single table-driven test by defining a slice of test
case structs that capture the differences (such as filterByStack value,
components filter slice, stackFileName, and componentName), then iterate through
the table executing the same test logic for each scenario. This will eliminate
code duplication and make it easier to add additional skip-path test cases in
the future.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b4e3523d-fe7b-4058-9298-ef1bb8170716
📒 Files selected for processing (3)
docs/fixes/2026-06-20-secret-list-stack-scope-per-component-auth.mdinternal/exec/describe_stacks_component_processor.gointernal/exec/describe_stacks_component_processor_auth_test.go
`processComponentEntry` resolved per-component auth (a full credential write + file lock + keyring rebuild) before applying the stack and component filters. Because describe-stacks walks every stack file, `atmos secret list -s <stack>` authenticated every component in every other stack before discarding it, scaling with the whole repo and appearing to hang on large repos. Move the stack and component filters ahead of resolveComponentAuthManager so per-component auth runs only for in-scope components. Auth still precedes its consumers (BuildTerraformWorkspace, Go-template and YAML-function processing), so nothing downstream loses its AuthContext. This also benefits `describe stacks -s` and the `list` family. Adds a table-driven regression test asserting the resolver is not invoked for out-of-scope stacks or components. Closes cloudposse#2639
4058bf9 to
f27090b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2642 +/- ##
==========================================
+ Coverage 80.02% 80.04% +0.01%
==========================================
Files 1361 1361
Lines 127449 127449
==========================================
+ Hits 101994 102016 +22
+ Misses 19790 19766 -24
- Partials 5665 5667 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
what
describe stacksper-component authentication to the components the caller actually requested.processComponentEntry, the stack and component filters now run beforeresolveComponentAuthManager, so out-of-scope components are skipped without authenticating.why
atmos secret list -s <stack>(without--component) callsExecuteDescribeStacks, which walks every stack file. Per-component auth — a full credential-file write + file lock + keyring rebuild — was resolved before the stack/component filters, so it authenticated every component in every other stack before discarding it.--componentwas fast only because it takes a separate single-component fast path.info.AuthContextfor that component's later Go-template (atmos.Component(...)) and YAML-function (!terraform.state/!terraform.output) processing — which never runs for a filtered-out component, so resolving it first was pure waste.BuildTerraformWorkspace, Go-template and YAML-function processing), so nothing downstream loses itsAuthContext. This also benefitsdescribe stacks -sand thelistfamily.aws-kmsprovider and a default identity: the command now returns promptly and authenticates only the requested stack plus the specific cross-stack components it actually references via!terraform.output/atmos.Component.references
atmos secret list -s <stack>(without-c) hangs: authenticates once per component across all stacks instead of scoping to the requested stack #2639docs/fixes/2026-06-20-secret-list-stack-scope-per-component-auth.mdSummary by CodeRabbit
atmos secret list -s <stack>where, without--component, the command could appear to hang by performing unnecessary authentication for out-of-scope components.