Commit 770e03b
feat: Add multiple terraform output formats for CI integration (#1885)
* refactor: Move terraform output execution to pkg/terraform/output with DI pattern
## What Changed
- Moved all terraform output execution logic from `internal/exec/` to new `pkg/terraform/output/` package
- Implemented dependency injection pattern using `ComponentDescriber` interface to break circular dependencies
- Created backward-compatible wrappers in `internal/exec/` to maintain API compatibility
- Achieved <30 cognitive complexity per function through strategic refactoring
- Added 39 comprehensive unit tests covering executor and configuration extraction
## Key Improvements
- **No circular dependencies**: `pkg/terraform/output/` defines interfaces, `internal/exec/` implements them
- **Better separation of concerns**: terraform output logic isolated in focused package
- **Testability**: All major functions tested with mocks, 89 total tests in package
- **Maintainability**: Reduced `internal/exec/terraform_output_utils.go` from 761 to focused helper
## Files Created
- `pkg/terraform/output/executor.go` - Core orchestration engine
- `pkg/terraform/output/config.go` - Configuration extraction
- `pkg/terraform/output/workspace.go` - Workspace management
- `pkg/terraform/output/backend.go` - Backend generation
- `pkg/terraform/output/environment.go` - Environment setup
- `pkg/terraform/output/platform_*.go` - Platform-specific utilities
- `pkg/terraform/output/*_test.go` - Comprehensive unit tests
- `internal/exec/component_describer_adapter.go` - Dependency injection adapter
## Files Deleted
- `internal/exec/terraform_output_utils_*.go` (platform-specific files)
- Integration tests (migrated to unit tests in new package)
## Verification
- ✅ `make build` passes
- ✅ `make lint` passes (0 issues)
- ✅ All 89 tests pass
- ✅ No circular dependencies
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Haiku 4.5 <[email protected]>
* [autofix.ci] apply automated fixes
* fix: Address code review feedback for spinner and workspace
- Replace fmt.Fprintln/fmt.Println with ui.Writeln per coding guidelines
- Add debug log when workspace creation fails before attempting select
- Fixes CodeQL false positive about sensitive data logging
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* fix: Properly differentiate workspace errors in terraform output
- Add isWorkspaceExistsError helper to check for "already exists" errors
- Fail fast on unexpected errors (network, permission) instead of
silently falling through to workspace select
- Add tests for both "already exists" and unexpected error cases
- Fix godot linter issue in comment
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* fix: Allow multiple Output calls in test for Windows retry logic
The retryOnWindows function retries failed terraform output calls up to
3 times on Windows. Update the mock expectation to use AnyTimes() to
prevent flaky test failures on Windows CI.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* test: Add unit tests for backend and environment setup in terraform output
Add comprehensive unit tests for previously untested code in the
terraform output package:
- backend_test.go: Tests for generateBackendConfig, generateProviderOverrides,
GenerateBackendIfNeeded, and GenerateProvidersIfNeeded functions
- environment_test.go: Tests for SetupEnvironment including prohibited
variable filtering, AWS auth context merging, and component env overrides
These tests increase package coverage from ~70% to ~80%.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* docs: Add multiple terraform output formats to roadmap
Add milestone documenting support for exporting terraform outputs
in multiple formats (JSON, YAML, HCL, env, dotenv, bash, CSV, TSV)
with options for uppercase keys and nested value flattening.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
* add tests
* address comments
* address comments
---------
Co-authored-by: Claude Haiku 4.5 <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Andriy Knysh <[email protected]>
Co-authored-by: aknysh <[email protected]>1 parent 97d1641 commit 770e03b
File tree
40 files changed
+6377
-1008
lines changed- cmd/terraform
- errors
- internal/exec
- pkg
- hooks
- terraform/output
- website
- blog
- docs/cli/commands/terraform
- src/data
40 files changed
+6377
-1008
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
22 | 34 | | |
23 | 35 | | |
24 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
7 | 20 | | |
8 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
9 | 25 | | |
10 | 26 | | |
11 | 27 | | |
12 | 28 | | |
13 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
14 | 33 | | |
15 | 34 | | |
16 | 35 | | |
17 | 36 | | |
18 | 37 | | |
19 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
20 | 50 | | |
21 | 51 | | |
22 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 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 | + | |
23 | 172 | | |
24 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
25 | 192 | | |
26 | | - | |
27 | | - | |
28 | 193 | | |
29 | | - | |
30 | | - | |
31 | 194 | | |
32 | 195 | | |
0 commit comments