-
-
Notifications
You must be signed in to change notification settings - Fork 125
8000
fix: Don't use terraform workspace in terraform.output
when backend is http
#1268
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
Conversation
📝 Walkthrough""" WalkthroughA conditional check was added to skip Terraform workspace creation and selection when the backend type is set to "http". The workspace-related operations are now only executed if the backend type is not "http", while the rest of the function remains unchanged. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant TerraformOutputs
participant Terraform
Caller->>TerraformOutputs: Execute function
alt Backend type != "http"
TerraformOutputs->>Terraform: WorkspaceNew()
TerraformOutputs->>Terraform: WorkspaceSelect()
else Backend type == "http"
Note right of TerraformOutputs: Skip workspace operations
end
TerraformOutputs->>Terraform: terraform output
Terraform->>TerraformOutputs: Return outputs
TerraformOutputs->>Caller: Return processed outputs
Suggested labels
✨ 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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/exec/terraform_outputs.go
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Summary
🔇 Additional comments (1)
internal/exec/terraform_outputs.go (1)
225-253
: Good fix for HTTP backend workspace issue.The conditional logic correctly skips workspace operations when using HTTP backend, addressing the "workspaces not supported" error mentioned in the PR.
🧰 Tools
🪛 golangci-lint (1.64.8)
[error] 225-225: File is not properly formatted
(gofumpt)
[error] 252-252: File is not properly formatted
(gofumpt)
This fix disables terraform workspace commands for !terraform.output if backend_type is http.
There was a problem hiding this 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
♻️ Duplicate comments (1)
internal/exec/terraform_outputs.go (1)
224-225
: Good job implementing the safe type assertion pattern.The comma-ok idiom properly handles nil values and prevents runtime panics. This addresses the previous concern raised in the review.
🧰 Tools
🪛 golangci-lint (1.64.8)
[error] 224-224: File is not properly formatted
(gofumpt)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
internal/exec/terraform.go
(1 hunks)internal/exec/terraform_outputs.go
(2 hunks)
🧰 Additional context used
🪛 golangci-lint (1.64.8)
internal/exec/terraform.go
[error] 440-440: File is not properly formatted
(gofumpt)
internal/exec/terraform_outputs.go
[error] 224-224: File is not properly formatted
(gofumpt)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Summary
terraform.output
when backend is http
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1268 +/- ##
==========================================
+ Coverage 49.25% 49.32% +0.06%
==========================================
Files 234 234
Lines 25576 25581 +5
==========================================
+ Hits 12598 12618 +20
+ Misses 11318 11299 -19
- Partials 1660 1664 +4
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:
|
There was a problem hiding this 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
🧹 Nitpick comments (1)
internal/exec/terraform.go (1)
449-451
: Clean implementation of HTTP backend check.The conditional logic correctly prevents workspace commands from executing when using HTTP backends, which aligns perfectly with the PR objectives. The refactored structure is much cleaner than the previous complex nested condition.
However, there's a minor formatting issue to address.
- if info.SubCommand != "init" && !(info.SubCommand == "workspace" && info.SubCommand2 != "") { - // Don't use workspace commands in http backend - if info.ComponentBackendType != "http" { + if info.SubCommand != "init" && !(info.SubCommand == "workspace" && info.SubCommand2 != "") { + // Don't use workspace commands in http backend + if info.ComponentBackendType != "http" {🧰 Tools
🪛 golangci-lint (1.64.8)
[error] 451-451: unnecessary leading newline
(whitespace)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/exec/terraform.go
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/exec/terraform.go (2)
internal/exec/shell_utils.go (1)
ExecuteShellCommand
(21-75)pkg/schema/schema.go (1)
Command
(568-578)
🪛 golangci-lint (1.64.8)
internal/exec/terraform.go
[error] 451-451: unnecessary leading newline
(whitespace)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Summary
🔇 Additional comments (1)
internal/exec/terraform.go (1)
453-494
: Solid workspace selection and creation logic.The workspace handling implementation is well-structured:
- Properly checks for
TF_WORKSPACE
environment variable- Implements appropriate fallback logic when workspace selection fails
- Correctly handles exit code 1 to distinguish between "workspace doesn't exist" and other errors
- Maintains consistent error redirection handling
The addition of workspace creation as a fallback when selection fails with exit code 1 is a thoughtful improvement that makes the workspace handling more robust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @astephanh
These changes were released in v1.178.0. |
This fix disables terraform workspace commands for !terraform.output if backend_type is http.
what
This change checks if terraform http backend is used, to skip terraform workspace commands in !terraform.output
why
Using http backend for remote state will end in an error, because atmos is still trying to select a workspace.
references
Summary by CodeRabbit