-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
backend/local: do not use backend operation variables #19175
Conversation
Previously the `local` backend didn’t merge variables but completely replaced them when any backend operation variables were set. Before [this change](67db9da000#diff-a0d5ae04114a139f2356fb16fbac7581R174) this was essentially a dead codepath as the backend operation would never have a value for these variables and so the complete set of variables created while getting the `ContextOpts` would be used instead: https://github.com/hashicorp/terraform/blob/v0.11/command/meta.go#L312 But the variables were added to the backend operation because the `remote` backend needs access to these command line variables so they can be set as run variables. Run variables are not yet supported in this release, but this value is still used in the current `remote` backend to detect if command line variables were set, in which case a proper error can be returned. We could also just remove the whole code path, instead of changing the behavior to merge instead of replace the variables. Will discuss that option before merging this. I added a few tests to guard against this issue in any future releases. Fixes #19163
In the earlier stages of the command initialization, variables are separated by But looking very closely through the code base, I noticed that the We can then assume that the field name matches the variable type that can be read from the So I suggest we, instead, add a very explicit comment to the EDIT: Created a second commit that reflects the suggestions in this comment. |
Alternative solution based on the additional comments in the PR.
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.
LGTM but we should probably change the title of this PR to match the current behavior!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Previously the
local
backend didn’t merge variables but completely replaced them when any backend operation variables were set.Before this change this was essentially a dead codepath (that didn't have any tests) as the backend operation would never have a value for these variables and so the complete set of variables created while getting the
ContextOpts
would be used instead: https://github.com/hashicorp/terraform/blob/v0.11/command/meta.go#L312But the variables were added to the backend operation because the
remote
backend needs access to these command line variables so they can be set as run variables. Run variables are not yet supported in this release, but this value is still used in the currentremote
backend to detect if command line variables were set, in which case a proper error can be returned.We could also just remove the whole code path, instead of changing the behavior to merge instead of replace the variables. Will discuss that option before merging this.
I added a few tests to guard against this issue in any future releases.
Fixes #19163
EDIT: See the first commit for this initial solution.