Commit 4fcddbf
fix: Enable YAML function authentication in terraform commands with --identity flag (#1769)
* updates
* updates
* updates
* updates
* updates
* updates
* updates
* updates
* [autofix.ci] apply automated fixes
* fix: Thread authManager through detectComponentType and update NOTICE
Addresses coderabbitai review comments on PR #1769:
1. Fix authManager not populated in detectComponentType
- Added authManager: params.AuthManager to baseParams initialization
- This ensures describe component commands properly thread AuthManager
- Fixes auth pre-hooks not receiving AuthManager when using --identity flag
2. Regenerate NOTICE file
- Updated with ./scripts/generate-notice.sh
- Resolves pipeline failure from outdated NOTICE file
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* [autofix.ci] apply automated fixes
* updates
* fix: Replace math.MaxInt32 with FatalLevel+1 for log disabling and disable AWS-dependent test
Addresses CodeRabbitAI feedback and CI test failures:
1. **Logging Fix (CodeRabbitAI):**
- charmbracelet/log doesn't support arbitrary high integers like math.MaxInt32
- Changed to FatalLevel + 1 which properly disables logging while staying in expected range
- Updated pkg/config/config.go and pkg/logger/utils.go
- Removed unused math imports
- Updated tests to expect FatalLevel + 1 instead of math.MaxInt32
2. **Test Fix (CI Failure):**
- Disabled `atmos stack manifest templates with terraform init` test
- Test requires AWS credentials for S3 backend which aren't available in CI
- CI has ATMOS_TEST_SKIP_PRECONDITION_CHECKS=true which bypasses precondition infrastructure
- Following pattern of other tests requiring external resources (auth tests, version check, etc.)
- Precondition check remains in place for local development
Root cause: CI globally disables precondition checks to handle various environment constraints,
so tests requiring specific resources must be explicitly disabled rather than using preconditions.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* refactor: Use ParseLogLevel and ConvertLogLevel utilities in setLogConfig
Refactored setLogConfig to use existing ParseLogLevel and ConvertLogLevel
utilities instead of duplicating logic with a switch statement.
Fixes:
- Missing "Error" log level case (was falling through to default WarnLevel)
- Inconsistent default behavior (WarnLevel vs InfoLevel)
- Code duplication between config.go and logger/utils.go
Benefits:
- Single source of truth for log level conversion
- All valid log levels (Trace, Debug, Info, Warning, Error, Off) now handled
- Consistent default behavior (Info on parse error)
- Reduced maintenance burden
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* updates
* [autofix.ci] apply automated fixes
* updates
* updates
* [autofix.ci] apply automated fixes
* feat: Auto-detect default identity for YAML function authentication
Fixes critical bug where YAML functions (!terraform.state, !terraform.output)
fail to authenticate when no --identity flag is provided, even with default
identity configured in atmos.yaml or stack configs.
## Problem
PR #1769 fixed authentication for --identity CLI flag but didn't handle
default identities from configuration. Users reported:
- Works: atmos terraform plan --identity core-auto/terraform
- Fails: atmos terraform plan (with default identity in config)
## Root Cause
CreateAndAuthenticateManager() returned nil when identityName was empty,
ignoring default identities configured in atmos.yaml or stack configs.
## Solution
Enhanced CreateAndAuthenticateManager() to auto-detect default identities:
1. When identityName is empty, check if auth is configured
2. If configured, call GetDefaultIdentity() to find default identity
3. If found, use it for authentication
4. If not found, return nil (backward compatible)
Supports both:
- Global defaults in atmos.yaml
- Stack-level defaults in stack configs (with override/merge behavior)
## Changes
**Modified:**
- pkg/auth/manager_helpers.go
- Added autoDetectDefaultIdentity() helper function
- Auto-detect default identity when identityName is empty
- Use existing GetDefaultIdentity() method for consistency
- Handle all edge cases (no auth, no default, multiple defaults)
- Updated documentation with auto-detection behavior
**Added Tests:**
- TestCreateAndAuthenticateManager_AutoDetectSingleDefault
- TestCreateAndAuthenticateManager_AutoDetectNoDefault
- TestCreateAndAuthenticateManager_AutoDetectNoAuthConfig
- TestCreateAndAuthenticateManager_AutoDetectEmptyIdentities
- TestCreateAndAuthenticateManager_AutoDetectMultipleDefaults
**Updated Documentation:**
- docs/prd/terraform-command-yaml-function-authentication.md
- Added "Default Identity Auto-Detection" section
- Configuration examples for global and stack-level defaults
- Usage patterns before/after auto-detection
- Implementation details and edge cases
## Behavior
**Before:**
- Always required --identity flag for YAML function authentication
- Default identity in config was ignored
**After:**
- Auto-detects and uses default identity from config
- No --identity flag needed when default is configured
- Explicit --identity flag still works (takes precedence)
- Fully backward compatible
## Test Results
All tests pass ✅
- 5 new tests for auto-detection behavior
- All existing tests continue to pass
- Backward compatibility verified
## Impact
✅ YAML functions work without --identity flag (with default identity)
✅ Stack-level default identity configuration supported
✅ Fully backward compatible
✅ Consistent authentication behavior across all commands
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat: Support --identity=off to disable authentication
Adds support for explicitly disabling authentication via --identity=off
(or false/no/0), allowing users to use external identity mechanisms like Leapp.
## Behavior
Three ways to disable/skip Atmos authentication:
1. **No auth configured** (no `auth:` section in atmos.yaml or stacks)
- Returns nil AuthManager
- Allows external mechanisms (env vars, Leapp, IMDS, etc.)
2. **No --identity flag with no default identity**
- Returns nil AuthManager
- Uses external credentials
3. **Explicit --identity=off/false/no/0** (NEW)
- Returns nil AuthManager even if auth is configured
- Overrides default identity if configured
- Useful for temporarily using external credentials
## Changes
**Modified:**
- pkg/auth/manager_helpers.go
- Check for cfg.IdentityFlagDisabledValue ("__DISABLED__") sentinel
- Return nil immediately when authentication explicitly disabled
- Updated documentation to clarify all disable scenarios
**Added Tests:**
- TestCreateAndAuthenticateManager_ExplicitlyDisabled
- Verifies --identity=off disables auth even with default identity
- TestCreateAndAuthenticateManager_NoAuthConfigured_NoIdentityFlag
- Verifies no auth used when no config and no flag
- TestCreateAndAuthenticateManager_NoAuthConfigured_WithExplicitIdentity
- Verifies error when identity flag but no auth config
## Examples
```bash
# Scenario 1: No auth configured - uses external credentials
# (no auth: section in atmos.yaml)
atmos terraform plan vpc -s dev
# Scenario 2: Auth configured with default, but want to use Leapp
atmos terraform plan vpc -s dev --identity=off
# Scenario 3: Auth configured, no default - uses external credentials
atmos terraform plan vpc -s dev
```
## Infrastructure
The --identity=off functionality was already implemented:
- cmd/identity_flag.go: Converts off/false/no/0 → "__DISABLED__"
- pkg/auth/hooks.go: isAuthenticationDisabled() checks for "__DISABLED__"
- Comprehensive tests already existed
This change completes the integration by handling "__DISABLED__" in
CreateAndAuthenticateManager(), ensuring consistent behavior across
all authentication code paths.
All tests pass ✅
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Format Go code blocks in terraform authentication PRD
Formatted all Go code snippets in the documentation to match standard
Go formatting conventions (gofmt/gofumpt style):
- Proper indentation with tabs
- Consistent spacing around braces and operators
- Multi-line function signatures properly formatted
- Comments ending with periods
This improves readability and consistency with the rest of the
codebase's Go code formatting standards.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix CodeRabbitAI issues and format Go code in terraform output auth flow doc
Fixed issues:
- Added missing period at end of line 86 (after "binary")
- Added missing period at end of line 172 (after "AuthManager")
- Fixed unordered list indentation on lines 266-267 (changed from 2 to 3 spaces)
- Formatted all Go code blocks with proper indentation (tabs instead of spaces)
- Added periods to end of inline comments in Go code
All Go code blocks now follow standard Go formatting conventions
(gofmt/gofumpt style) and markdown follows proper list indentation rules.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add authentication flow documentation for !terraform.state YAML function
Created comprehensive documentation explaining the authentication flow
for the !terraform.state YAML function, parallel to the existing
!terraform.output documentation.
Key sections:
- Complete call flow from command execution to S3 state retrieval
- Critical code sections with properly formatted Go snippets
- Architecture diagram showing authentication pipeline
- Comparison with !terraform.output function
- Performance analysis and use case recommendations
- Testing verification examples
- Error handling reference
Highlights differences between the two functions:
- !terraform.state: Direct AWS SDK usage for S3 access
- !terraform.output: Terraform binary execution with env vars
All Go code blocks properly formatted with tabs (gofmt/gofumpt style).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* updates
* Fix: Prompt users once for identity selection when no default configured
Fixed UX issue where users were prompted multiple times (once per YAML
function) when no default identity was configured.
Changes:
- Modified autoDetectDefaultIdentity() to accept allowInteractive parameter
- When no default identity exists:
* Interactive mode: Prompts user ONCE to select identity
* Non-interactive (CI): Returns nil (no authentication)
- When multiple defaults exist:
* Interactive mode: Prompts user to choose from defaults
* Non-interactive (CI): Returns nil (no authentication)
- When exactly one default exists: Uses it automatically
Behavior improvements:
✅ Single prompt per command execution (not per YAML function)
✅ Selected identity cached in AuthManager for all YAML functions
✅ Handles all default scenarios: none, one, multiple
✅ CI-friendly: No prompts in non-interactive environments
✅ Backward compatible: Existing workflows unchanged
Example scenario (fixed):
Command: atmos terraform plan component -s stack
Before: Prompted for each !terraform.state function
After: Prompted ONCE, selection used for all functions
Addresses user-reported UX issue where component configs with multiple
!terraform.state or !terraform.output functions caused repeated prompts
for the same identity selection.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add debug logging to track identity selection prompts
Added debug logging to help diagnose double-prompt issue:
- Log when CreateAndAuthenticateManager is called
- Log when auto-detection starts
- Log when user is prompted for selection
- Log user's selection
This will help identify if:
1. CreateAndAuthenticateManager is being called twice
2. Auto-detection is triggered multiple times
3. The selection is properly cached
To enable debug logging:
export ATMOS_LOGS_LEVEL=Debug
atmos terraform plan component -s stack
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* updates
* updates
* updates
* updates
* updates
* updates
* updates
* updates
* updates
* updates
* updates
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Claude <[email protected]>1 parent ff26f86 commit 4fcddbf
File tree
40 files changed
+2823
-148
lines changed- cmd
- docs
- prd
- errors
- internal/exec
- pkg
- auth
- component
- config
- flags
- logger
- utils
- tests
- snapshots
- test-cases
- website/src/components/Screengrabs/demo-stacks
40 files changed
+2823
-148
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
732 | 732 | | |
733 | 733 | | |
734 | 734 | | |
735 | | - | |
| 735 | + | |
736 | 736 | | |
737 | 737 | | |
738 | 738 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | 4 | | |
8 | 5 | | |
9 | 6 | | |
10 | 7 | | |
11 | 8 | | |
12 | | - | |
13 | 9 | | |
14 | | - | |
15 | | - | |
16 | 10 | | |
17 | 11 | | |
18 | 12 | | |
| |||
133 | 127 | | |
134 | 128 | | |
135 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
136 | 133 | | |
137 | 134 | | |
138 | 135 | | |
139 | 136 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 137 | + | |
177 | 138 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
290 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
291 | 293 | | |
292 | 294 | | |
293 | 295 | | |
| |||
577 | 579 | | |
578 | 580 | | |
579 | 581 | | |
580 | | - | |
| 582 | + | |
581 | 583 | | |
582 | 584 | | |
583 | 585 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
| 284 | + | |
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
| 312 | + | |
313 | 313 | | |
314 | | - | |
315 | | - | |
| 314 | + | |
| 315 | + | |
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| |||
0 commit comments