Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The Terraform plugin requires the project credentials for
terraform workspace, but the OpenTofu plugin's otherwise identical list of subcommands omits it, sotofu workspace select stagingran with nothing injected and no warning. This adds the missingForCommand("workspace")rule, which covers everyworkspacesubcommand, making the two plugins behave the same.Neither plugin had any test coverage. This adds matching
NeedsAuthtables to both, identical on purpose: the two command lists are hand-maintained copies of each other and this bug was them drifting apart, so either side drifting now fails a test.Type of change
Related Issue(s)
How To Test
Unit tests, including a regression test for the reported bug:
go test ./plugins/tofu/ ./plugins/terraform/ -vTestTofuCLIProjectCredentialsNeedsAuthcovers threeworkspaceforms and guards that the nine already-working remote subcommands stay gated whilefmtandvalidatestay exempt.TestTerraformCLIProjectCredentialsNeedsAuthasserts the same table against Terraform, as the parity guard.TestTofuCLINeedsAuthpins the executable-level gate, which passes both before and after this change — it is there so a future fix for a similar bug is not misapplied at that level.End to end with the CLI:
No specific credential should be needed. What we're checking is when 1Password is asked for the credential, not whether the OpenTofu command itself succeeds.
From a directory with a
.tfconfiguration, these should now resolve the project credentials, where before this change they ran with nothing injected and no prompt:Terraform has always behaved this way, so the two should now agree:
And these should still run with no credentials, which is the guard against the rule being too broad:
Changelog
The OpenTofu plugin now provides the project credentials to
tofu workspacecommands, matching the Terraform plugin's behaviour.