Skip to content

Update atmos terraform version and atmos helmfile version commands#1274

Merged
aknysh merged 10 commits intomainfrom
update-executable-command
May 30, 2025
Merged

Update atmos terraform version and atmos helmfile version commands#1274
aknysh merged 10 commits intomainfrom
update-executable-command

Conversation

@aknysh
Copy link
Member

@aknysh aknysh commented May 30, 2025

what

why

  • When executing atmos terraform version and atmos helmfile version commands, take into account the command setting in atmos.yaml. The command setting specifies the executable, which can be terraform, tofu, helmfile, or a path to an executable.
components:
  terraform:
    # Optional `command` specifies the executable to be called by Atmos when running Terraform commands
    # If not defined, `terraform` is used
    # Examples:
    # command: terraform
    # command: /usr/local/bin/terraform
    # command: /usr/local/bin/terraform-1.8
    # command: tofu
    # command: /usr/local/bin/tofu-1.7.1
    # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_COMMAND' ENV var, or '--terraform-command' command-line argument
    command: terraform
components:
  helmfile:
    # Optional `command` specifies the executable to be called by Atmos when running Helmfile commands
    # If not defined, `helmfile` is used
    # Examples:
    # command: helmfile
    # command: /usr/local/bin/helmfile
    # Can also be set using 'ATMOS_COMPONENTS_HELMFILE_COMMAND' ENV var, or '--helmfile-command' command-line argument
    command: helmfile
atmos terraform version

  Terraform v1.7.3
  on darwin_arm64
atmos terraform version

  OpenTofu v1.7.1
  on darwin_arm64
atmos helmfile version

  Version            v1.1.0
  Git Commit         "brew"
  Build Date         19 May 25 18:20 EDT (1 week ago)
  Commit Date        19 May 25 18:20 EDT (1 week ago)
  Dirty Build        no
  Go version         1.24.3
  Compiler           gc
  Platform           darwin/arm64

Summary by CodeRabbit

  • New Features
    • Added support for customizing the executable command for Terraform and Helmfile components via configuration.
    • Introduced a new Helmfile CLI version command to display the Helmfile version.
  • Tests
    • Introduced new test scenarios to verify dynamic command execution for both Terraform and OpenTofu.
    • Added tests to validate Helmfile version command execution.
  • Documentation
    • Enhanced documentation to clarify configuration options for Terraform and Helmfile components.
  • Chores
    • Updated several dependencies to their latest versions for improved stability and compatibility.

@aknysh aknysh self-assigned this May 30, 2025
@aknysh aknysh requested a review from a team as a code owner May 30, 2025 02:32
@aknysh aknysh added the no-release Do not create a new release (wait for additional code changes) label May 30, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 30, 2025

📝 Walkthrough

"""

Walkthrough

This 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

File(s) Change Summary
go.mod Updated and removed several dependencies.
internal/exec/helmfile.go
internal/exec/terraform.go
Set executable command dynamically from config for Helmfile and Terraform; use this command for version subcommands.
internal/exec/utils.go Updated ProcessComponentConfig to accept config pointer and set command only if non-empty.
internal/exec/terraform_test.go Added tests for executing Terraform and Tofu version commands and verifying output.
internal/exec/helmfile_test.go Added tests for executing Helmfile version command and verifying output.
tests/fixtures/scenarios/atmos-terraform-version/* Added new fixture scenario with config and stack for Terraform version testing.
tests/fixtures/scenarios/atmos-tofu-version/* Added new fixture scenario with config and stack for Tofu version testing.
tests/fixtures/scenarios/atmos-helmfile-version/* Added new fixture scenario with config and stack for Helmfile version testing.
website/docs/cli/configuration/components.mdx Expanded documentation for terraform and helmfile component configuration options.
.github/workflows/test.yml Added Helmfile installation step to test job; reformatted array syntax.
cmd/helmfile_version.go Added new Helmfile CLI "version" subcommand.

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
Loading
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
Loading

Possibly related PRs

Suggested labels

minor

Suggested reviewers

  • osterman
  • milldr
    """

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3dcbc49 and e6e9a2a.

📒 Files selected for processing (3)
  • tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden (1 hunks)
  • tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • tests/snapshots/TestCLICommands_atmos_helmfile.stderr.golden
  • tests/snapshots/TestCLICommands_atmos_helmfile_help.stdout.golden
  • tests/snapshots/TestCLICommands_atmos_helmfile_--help.stdout.golden
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: website-deploy-preview
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Summary

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c2db173 and 6e3fcce.

⛔ Files ignored due to path filters (1)
  • go.sum is 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.Command instead 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 1

Length of output: 882


All ProcessComponentConfig Callers Updated

I searched the entire codebase for ProcessComponentConfig( and confirmed that every call now passes the new &atmosConfig parameter (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 command configuration 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
Copy link

codecov bot commented May 30, 2025

Codecov Report

Attention: Patch coverage is 80.64516% with 6 lines in your changes missing coverage. Please review.

Project coverage is 49.36%. Comparing base (c2db173) to head (e6e9a2a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/helmfile_version.go 40.00% 3 Missing ⚠️
internal/exec/helmfile.go 78.57% 2 Missing and 1 partial ⚠️
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     
Flag Coverage Δ
unittests 49.36% <80.64%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

coderabbitai[bot]
coderabbitai bot previously approved these changes May 30, 2025
@mergify
Copy link

mergify bot commented May 30, 2025

Important

Cloud Posse Engineering Team Review Required

This 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 #pr-reviews channel.

@mergify mergify bot added the needs-cloudposse Needs Cloud Posse assistance label May 30, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 of internal/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 of internal/exec/helmfile_test.go:25-76

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e3fcce and c137753.

📒 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 helmfileRun function

The implementation matches the pattern used for other version commands in the codebase.

coderabbitai[bot]
coderabbitai bot previously approved these changes May 30, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes May 30, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes May 30, 2025
@aknysh aknysh merged commit 6462315 into main May 30, 2025
51 checks passed
@aknysh aknysh deleted the update-executable-command branch May 30, 2025 14:29
@mergify mergify bot removed the needs-cloudposse Needs Cloud Posse assistance label May 30, 2025
@RoseSecurity
Copy link
Contributor

Thank you for the quick fix on this. Really appreciate it

@github-actions
Copy link

github-actions bot commented Jun 3, 2025

These changes were released in v1.178.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release Do not create a new release (wait for additional code changes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants