-
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
command: add TF_CLI_ARGS to specify additional CLI args #11922
Conversation
main.go
Outdated
// after the first non-flag arg. | ||
idx := -1 | ||
for i, v := range args { | ||
if v[0] != '-' { |
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.
An arg can be 0 length -- even more likely in an automated system like TFE.
strings.HasPrefix
?
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.
Really good catch, really good. Fixing now.
main.go
Outdated
idx++ | ||
|
||
// Copy the args | ||
newArgs := make([]string, len(args)+len(extra)) |
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.
Do we need to worry about non-flag arguments in the TF_CLI_ARGS
variable? ( I can't think of a case where it matters, just tossing out the question)
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.
I think we just make explicit that we insert the args right after the command. If that works, great, if that doesn't for them for normal args, then its documented.
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. |
This introduces an env var
TF_CLI_ARGS
that can be used to specify additional CLI args.The primary use for this is easier CI and automation integration.
The flag is parsed like a shell line, so the value
TF_CLI_ARGS="-foo 'bar baz'"
will turn into["-foo", "bar baz"]
internally.The additional args are appended before any args specified on the CLI after the command. So, if you invoke
TF_CLI_ARGS="-force" terraform apply -input=false
then it is equivalent to specifyingterraform apply -force -input=false
. This ordering forces the CLI args to take precedent over the env var.Updating the docs now.