-
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
cli: Remove legacy positional path arguments #27664
Conversation
Codecov Report
|
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 read though this as thoroughly as I could, although of course with this sort of systematic updating it's easy to get lost in the patterns and miss details, so I tried to look particularly carefully at the test cases just to see if they agreed with what I'd expect the new behavior to be, and they do seem to.
My sense is that it's better to get this in earlier rather than latter so that it has some time to soak in at least one alpha and then the betas, since then there's more chance of us or someone else exercising these things indirectly as part of testing something else.
Noting that we still have some commands other than terraform apply
which take a plan file as a positional argument, I had a further idea here although I'm just noting it for completeness and not intending to try to increase the scope of this PR:
While terraform apply tfplan
has nice ergonomics because the plan file is obviously the "direct object" of the "apply" verb, the positional form for other commands has always felt less clear to me. Given that we're already making some breaking changes here anyway, perhaps a further PR could go further by replacing those plan file position arguments with named arguments instead, like this:
terraform graph -plan=tfplan
This would avoid relying on the plan file having a meaningful name in order for the meaning of that argument to be clear, and also just generally standardize that we typically use named arguments because they are better for allowing backward-compatible additions in future. (with terraform apply tfplan
of course remaining one special exception, justified due to its prominence in the CLI workflow.)
3d95f7e
to
9a00767
Compare
Several commands continued to support the legacy positional path argument to specify a working directory. This functionality has been replaced with the global -chdir flag, which is specified before any other arguments, including the sub-command name. This commit removes support for the trailing path parameter from most commands. The only command which still supports a path argument is fmt, which also supports "-" to indicate receiving configuration from standard input. Any invocation of a command with an invalid trailing path parameter will result in a short error message, pointing at the -chdir alternative. There are many test updates in this commit, almost all of which are migrations from using positional arguments to specify a working directory. Because of the layer at which these tests run, we are unable to use the -chdir argument, so the churn in test files is larger than ideal. Sorry!
To make the command arguments easier to understand and extend, we are moving away from positional arguments. This commit changes the graph command to take a `-plan` flag instead of an optional trailing path.
9a00767
to
888f36a
Compare
Thanks for the review! Your suggestion makes sense to me, so I updated the |
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. |
Several commands continued to support the legacy positional path argument to specify a working directory. This functionality has been replaced with the global
-chdir
flag (#26087), which is specified before any other arguments, including the sub-command name.This commit removes support for the trailing path parameter from most commands. The only command which still supports a path argument is
fmt
, which also supports "-" to indicate receiving configuration from standard input.Any invocation of a command with an invalid trailing path parameter will result in a short error message, pointing at the
-chdir
alternative.There are many test updates in this commit, almost all of which are migrations from using positional arguments to specify a working directory. Because of the layer at which these tests run, we are unable to use the
-chdir
argument, so the churn in test files is larger than ideal. Sorry!