Update atmos terraform version and atmos helmfile version commands#1274
Update atmos terraform version and atmos helmfile version commands#1274
atmos terraform version and atmos helmfile version commands#1274Conversation
📝 Walkthrough""" WalkthroughThis update introduces dynamic command assignment for Terraform and Helmfile executables based on configuration, adds targeted tests for version command execution, updates documentation for component configuration, and bumps several dependencies. New fixture scenarios demonstrate the configurable command feature for both Terraform and OpenTofu. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant Config
participant Executor
User->>CLI: Run 'atmos terraform version'
CLI->>Config: Load atmos.yaml
Config-->>CLI: Return terraform command (e.g., "terraform" or "tofu")
CLI->>Executor: ExecuteShellCommand(command, "version")
Executor-->>CLI: Output version info
CLI-->>User: Display version output
sequenceDiagram
participant User
participant CLI
participant Config
participant Executor
User->>CLI: Run 'atmos helmfile version'
CLI->>Config: Load atmos.yaml
Config-->>CLI: Return helmfile command (e.g., "helmfile")
CLI->>Executor: ExecuteShellCommand(command, "version")
Executor-->>CLI: Output version info
CLI-->>User: Display version output
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (3)
⏰ Context from checks skipped due to timeout of 90000ms (6)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (10)
go.mod(9 hunks)internal/exec/helmfile.go(1 hunks)internal/exec/terraform.go(1 hunks)internal/exec/terraform_test.go(1 hunks)internal/exec/utils.go(4 hunks)tests/fixtures/scenarios/atmos-terraform-version/atmos.yaml(1 hunks)tests/fixtures/scenarios/atmos-terraform-version/stacks/deploy/nonprod.yaml(1 hunks)tests/fixtures/scenarios/atmos-tofu-version/atmos.yaml(1 hunks)tests/fixtures/scenarios/atmos-tofu-version/stacks/deploy/nonprod.yaml(1 hunks)website/docs/cli/configuration/components.mdx(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
internal/exec/terraform.go (3)
pkg/schema/schema.go (3)
Command(568-578)Components(307-310)Terraform(277-288)pkg/config/const.go (1)
TerraformComponentType(44-44)internal/exec/shell_utils.go (1)
ExecuteShellCommand(21-75)
internal/exec/helmfile.go (3)
pkg/schema/schema.go (3)
Command(568-578)Components(307-310)Helmfile(298-305)pkg/config/const.go (1)
HelmfileComponentType(45-45)internal/exec/shell_utils.go (1)
ExecuteShellCommand(21-75)
internal/exec/utils.go (1)
pkg/schema/schema.go (2)
AtmosConfiguration(23-57)Command(568-578)
🪛 golangci-lint (1.64.8)
internal/exec/terraform_test.go
[error] 441-441: 441-489 lines are duplicate of internal/exec/terraform_test.go:491-539
(dupl)
[error] 491-491: 491-539 lines are duplicate of internal/exec/terraform_test.go:441-489
(dupl)
🪛 GitHub Check: golangci-lint
internal/exec/terraform_test.go
[failure] 441-441:
441-489 lines are duplicate of internal/exec/terraform_test.go:491-539
[failure] 491-491:
491-539 lines are duplicate of internal/exec/terraform_test.go:441-489
🪛 GitHub Actions: Dependency Review
go.mod
[error] 1-1: Dependency review detected incompatible licenses: github.com/redis/go-redis/v9@9.9.0 uses BSD-2-Clause license which is incompatible.
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Summary
🔇 Additional comments (14)
tests/fixtures/scenarios/atmos-tofu-version/stacks/deploy/nonprod.yaml (1)
1-13: LGTM! Well-structured test fixture.The YAML configuration is properly structured with schema validation and provides clear test data for the tofu version scenario. The component variables and stage definition will work well for testing the dynamic command execution feature.
tests/fixtures/scenarios/atmos-terraform-version/stacks/deploy/nonprod.yaml (1)
1-13: LGTM! Consistent test fixture structure.The configuration maintains consistency with the tofu version test fixture while serving the terraform scenario. This parallel structure will enable comprehensive testing of both command execution paths.
internal/exec/helmfile.go (2)
36-43: LGTM! Solid dynamic command resolution logic.The implementation correctly prioritizes existing command settings, then falls back to configuration, and finally to the default constant. This defensive approach maintains backward compatibility while enabling the new configurable command feature.
46-53: LGTM! Proper use of dynamic command.The version command execution now correctly uses
info.Commandinstead of the hardcoded "helmfile" string, which enables the configured command (like custom helmfile paths or alternative tools) to be respected.internal/exec/terraform.go (2)
50-58: Nice implementation of the dynamic command selection!The logic correctly prioritizes explicitly set commands over configuration, with a sensible fallback to the default. This maintains backwards compatibility while enabling the new configurable command feature.
59-67: Good update to use the dynamic command.The version command now properly respects the configured executable, which aligns perfectly with the PR objectives.
tests/fixtures/scenarios/atmos-tofu-version/atmos.yaml (1)
1-23: Well-structured test fixture for OpenTofu scenario.This configuration properly sets up a test environment to verify that the dynamic command selection works with alternative Terraform implementations like OpenTofu. The configuration is clean and follows standard atmos patterns.
internal/exec/utils.go (3)
61-61: Function signature updated appropriately.Adding the atmosConfig parameter enables access to the configuration needed for dynamic command selection.
188-191: Smart conditional command assignment.Only setting the command when it's non-empty prevents overriding with empty values and maintains clean separation between configured and default behaviors.
345-345:Details
✅ Verification successful
Verify all ProcessComponentConfig callers are updated.
The visible calls have been updated to pass the atmosConfig parameter. Let me verify there aren't any other callers that need updating.
Also applies to: 379-379
🏁 Script executed:
#!/bin/bash # Search for all calls to ProcessComponentConfig to ensure they all pass the new parameter rg "ProcessComponentConfig\(" -A 3 -B 1Length of output: 882
All ProcessComponentConfig Callers Updated
I searched the entire codebase for
ProcessComponentConfig(and confirmed that every call now passes the new&atmosConfigparameter (all occurrences are in internal/exec/utils.go).No further changes are required.
tests/fixtures/scenarios/atmos-terraform-version/atmos.yaml (1)
1-23: Solid test fixture for standard Terraform scenario.This configuration pairs well with the OpenTofu fixture to provide comprehensive test coverage for the dynamic command feature. The setup is clean and properly configured.
website/docs/cli/configuration/components.mdx (3)
49-58: Enhanced command configuration documentation looks great.The additional examples and clarity around the
commandconfiguration option perfectly align with the PR objectives. The variety of examples (standard terraform, custom paths, tofu) covers the main use cases users will encounter.
82-127: Comprehensive documentation structure improves usability.The detailed description list format makes configuration options much more accessible and searchable. Each property is clearly explained with environment variable and CLI overrides documented.
135-141: Helmfile documentation follows consistent patterns.The helmfile component documentation mirrors the terraform structure effectively, providing users with a consistent experience across both component types.
Also applies to: 162-210
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1274 +/- ##
==========================================
+ Coverage 49.16% 49.36% +0.19%
==========================================
Files 233 234 +1
Lines 25548 25576 +28
==========================================
+ Hits 12561 12625 +64
+ Misses 11328 11286 -42
- Partials 1659 1665 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
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 |
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
internal/exec/helmfile_test.go (1)
12-77: Solid test implementation but address code duplication.The test correctly validates the Helmfile version command functionality with proper setup, execution, and output verification. However, this code is nearly identical to the Terraform version test.
This test has the same duplication issue as noted in the Terraform test. Consider using the shared helper function suggested in the terraform_test.go review to eliminate the redundancy between these two test files.
🧰 Tools
🪛 golangci-lint (1.64.8)
[error] 25-25: 25-76 lines are duplicate of
internal/exec/terraform_test.go:459-510(dupl)
🪛 GitHub Check: golangci-lint
[failure] 25-25:
25-76 lines are duplicate ofinternal/exec/terraform_test.go:459-510
🧹 Nitpick comments (1)
internal/exec/terraform_test.go (1)
441-511: Well-structured test but consider extracting common test logic.The table-driven test approach is solid and properly tests both Terraform and OpenTofu version commands. However, there's significant code duplication with the Helmfile version test that could be eliminated.
Consider extracting a common test helper function to reduce duplication:
// Helper function for version command tests func testVersionCommand(t *testing.T, executeFunc func(schema.ConfigAndStacksInfo) error, workDir, expectedOutput string) { // Capture the starting working directory startingDir, err := os.Getwd() if err != nil { t.Fatalf("Failed to get the current working directory: %v", err) } defer func() { if err := os.Chdir(startingDir); err != nil { t.Fatalf("Failed to change back to the starting directory: %v", err) } }() // Change to test directory if err := os.Chdir(workDir); err != nil { t.Fatalf("Failed to change directory to %q: %v", workDir, err) } // Create version command info info := schema.ConfigAndStacksInfo{ SubCommand: "version", } // Capture stdout oldStdout := os.Stdout r, w, _ := os.Pipe() os.Stdout = w err = executeFunc(info) if err != nil { t.Fatalf("Failed to execute command: %v", err) } w.Close() os.Stdout = oldStdout // Check output var buf bytes.Buffer _, err = buf.ReadFrom(r) if err != nil { t.Fatalf("Failed to read from pipe: %v", err) } output := buf.String() if !strings.Contains(output, expectedOutput) { t.Errorf("%s not found in the output", expectedOutput) } }Then simplify the test:
func TestExecuteTerraform_Version(t *testing.T) { tests := []struct { name string workDir string expectedOutput string }{ { name: "terraform version", workDir: "../../tests/fixtures/scenarios/atmos-terraform-version", expectedOutput: "Terraform v", }, { name: "tofu version", workDir: "../../tests/fixtures/scenarios/atmos-tofu-version", expectedOutput: "OpenTofu v", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { testVersionCommand(t, ExecuteTerraform, tt.workDir, tt.expectedOutput) }) } }🧰 Tools
🪛 golangci-lint (1.64.8)
[error] 459-459: 459-510 lines are duplicate of
internal/exec/helmfile_test.go:25-76(dupl)
🪛 GitHub Check: golangci-lint
[failure] 459-459:
459-510 lines are duplicate ofinternal/exec/helmfile_test.go:25-76
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.github/workflows/test.yml(3 hunks)cmd/helmfile_version.go(1 hunks)internal/exec/helmfile_test.go(1 hunks)internal/exec/terraform_test.go(1 hunks)tests/fixtures/scenarios/atmos-helmfile-version/atmos.yaml(1 hunks)tests/fixtures/scenarios/atmos-helmfile-version/stacks/deploy/nonprod.yaml(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- tests/fixtures/scenarios/atmos-helmfile-version/stacks/deploy/nonprod.yaml
- tests/fixtures/scenarios/atmos-helmfile-version/atmos.yaml
🧰 Additional context used
🪛 golangci-lint (1.64.8)
internal/exec/helmfile_test.go
[error] 25-25: 25-76 lines are duplicate of internal/exec/terraform_test.go:459-510
(dupl)
internal/exec/terraform_test.go
[error] 459-459: 459-510 lines are duplicate of internal/exec/helmfile_test.go:25-76
(dupl)
🪛 GitHub Check: golangci-lint
internal/exec/helmfile_test.go
[failure] 25-25:
25-76 lines are duplicate of internal/exec/terraform_test.go:459-510
internal/exec/terraform_test.go
[failure] 459-459:
459-510 lines are duplicate of internal/exec/helmfile_test.go:25-76
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Summary
🔇 Additional comments (4)
.github/workflows/test.yml (3)
4-4: Clean formatting improvement.The addition of spaces around the PR trigger types improves readability without changing functionality.
131-132: Good addition for Helmfile testing support.Installing Helmfile in the CI environment is necessary to support the new Helmfile version command testing. The approach aligns with how other tools are installed in the workflow.
523-523: Consistent formatting with the PR triggers.The spacing addition maintains consistency with the formatting changes made earlier in the file.
cmd/helmfile_version.go (1)
1-21: Clean implementation following established patterns.The Helmfile version command is well-implemented with:
- Proper Cobra command structure
- Appropriate command metadata (usage, description)
- Correct flag handling for unknown flags
- Proper integration with existing
helmfileRunfunctionThe implementation matches the pattern used for other version commands in the codebase.
|
Thank you for the quick fix on this. Really appreciate it |
|
These changes were released in v1.178.0. |
what
atmos terraform versionandatmos helmfile versioncommandswhy
atmos terraform versionandatmos helmfile versioncommands, take into account thecommandsetting inatmos.yaml. Thecommandsetting specifies the executable, which can beterraform,tofu,helmfile, or a path to an executable.Summary by CodeRabbit
versioncommand to display the Helmfile version.