-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix terraform command generation in different order #4322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix terraform command generation in different order #4322
Conversation
Test output: ``` > go test ./run_test.go 20:19:30.614 DEBUG Running command: i-dont-exist 20:19:30.614 DEBUG Engine is not enabled, running command directly in . 20:19:30.616 ERROR unknown invocation failed in . 20:19:30.649 DEBUG Skipping var-file optional.tfvars as it does not exist --- FAIL: TestFilterTerraformExtraArgs (0.06s) run_test.go:451: Error Trace: /home/monkeypac/dev/terragrunt/cli/commands/run/run_test.go:451 Error: Not equal: expected: []string{"--foo", "bar", "foo"} actual : []string{"--foo", "-var-file=test.tfvars", "bar", "-var='key=value'", "foo", "-var-file=required.tfvars", "-var-file=/tmp/TestFilterTerraformExtraArgs3197671377/001/3320748883"} Diff: --- Expected +++ Actual @@ -1,5 +1,9 @@ -([]string) (len=3) { +([]string) (len=7) { (string) (len=5) "--foo", + (string) (len=21) "-var-file=test.tfvars", (string) (len=3) "bar", - (string) (len=3) "foo" + (string) (len=16) "-var='key=value'", + (string) (len=3) "foo", + (string) (len=25) "-var-file=required.tfvars", + (string) (len=68) "-var-file=/tmp/TestFilterTerraformExtraArgs3197671377/001/3320748883" } Test: TestFilterTerraformExtraArgs FAIL FAIL command-line-arguments 0.095s FAIL ```
Test output: ``` > go test ./run_test.go ok command-line-arguments 0.136s ```
📝 Walkthrough""" WalkthroughThe update changes how the last Terraform CLI argument is determined in the filtering logic for extra arguments, replacing a method that fetches the last argument with one that retrieves the first command name. Additionally, a new test case is introduced to verify correct argument filtering when file arguments are not at the end of the command list. Changes
Assessment against linked issues
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (20)
✨ Finishing Touches
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
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Global tests are still failing on some non-related code. |
Description
Fixes #4220.
When using
-no-color
a var setting and a plan file, the terraform command generated looks like[...] <file> -no-color
which makes the usage of "Last" wrong.Since terraform's apply doc says it can take zero or one non-optional parameter, this should do it.
I ran tests and linters as says the doc but the overall tests fail on main, even in the cli package I get failing tests if I run
go test ./cli/...
.For the linters,
make run-lint
went well,make run-strict-lint
was failing on main.Test run for `run_test.go` with the new test, before the fix
Test run for `run_test.go` with the new test, after the fix
Test run for the whole `cli/commands/run` package after the fix
TODOs
Read the Gruntwork contribution guidelines.
Release Notes (draft)
Updated terraform command generation with extra args when using a plan file.
Migration Guide
Summary by CodeRabbit
Bug Fixes
Tests