Skip to content
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

Strip flags from internal_plugin args (fixes TF_CLI_ARGS usage) #17400

Merged

Conversation

aars
Copy link
Contributor

@aars aars commented Feb 21, 2018

This fixes #14847, #17094

Hi,

This PR fixes the internal plugins breaking over the amount of args received. Though it might be a bit naïve.

My first approach was to add an exception to mergeEnvArgs, to simply skip the merge if the command was internal-plugin. Something something, separation of concerns, so I decided to let the internal plugin command handle this. I think the cli package guarantees that all command options/flags are prefixed with a dash, making it easy and reliable to filter these.

I added a unit test for the newly added function. I couldn't find any test that actually called the Run function, but I might have overlooked something.

@aars
Copy link
Contributor Author

aars commented Jun 22, 2018

Any input on this?

@lorengordon
Copy link
Contributor

Just ran into this problem. Would be nice to get a fix.

@apparentlymart
Copy link
Contributor

Thanks for working on this, @aars!

I follow and agree with your rationale for doing this as a post-processing step within the command itself, since this is a concern rather specific to this command, and the execution of it is totally under Terraform's control anyway so we can be sure that arguments starting with - cannot be a legitimate part of the interface of this command.

There are other commands that don't support -var-file etc too which would still be subject to the problem, and that's why we also offer the command-specific variants of TF_CLI_ARGS like TF_CLI_ARGS_plan, but addressing this for internal-plugin specifically does at least ensure that the main Terraform workflow commands can work successfully with the general TF_CLI_ARGS set.

Thanks again!

@apparentlymart apparentlymart merged commit 3dfeb67 into hashicorp:master Dec 5, 2019
@apparentlymart apparentlymart added this to the v0.12.18 milestone Dec 5, 2019
@aars aars deleted the internal-plugin_strip-args-flags branch March 4, 2020 13:26
@ghost
Copy link

ghost commented Mar 5, 2020

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.

@ghost ghost locked and limited conversation to collaborators Mar 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TF_CLI_ARGS with -var-file causes terraform plugin error.
3 participants