-
Notifications
You must be signed in to change notification settings - Fork 72
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
Fixed ignoring required positional parameters when --json flag is provided #535
Conversation
patchReq.Id = args[0] | ||
args = append(args, id) | ||
} | ||
if len(args) != 1 { |
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.
This will break I believe?
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.
@mgyucht no, why? This is a general logic for prompts. If no args provided it will go to the condition on line 284 and ask user to choose group ID from the list and append it to args on line 296 so len(args) == 1
Or if customer provided positional argument, the prompt condition will be skipped
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.
My mistake, didn't realize args itself was modified in that block.
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.
Nice fix! Though let's hold off merging this until the Go SDK PR merges, and let's update the name of the new method here.
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.
Nice work! I'd like to decouple the SDK bump from the function change, though.
9de3679
to
2772621
Compare
## Changes CLI: * Fix secrets put-secret command ([#545](#545)). * Fixed ignoring required positional parameters when --json flag is provided ([#535](#535)). * Update cp help message to not require file scheme ([#554](#554)). Bundles: * Fix: bundle destroy fails when bundle.tf.json file is deleted ([#519](#519)). * Fixed error reporting when included invalid files in include section ([#543](#543)). * Make top level workspace optional in JSON schema ([#562](#562)). * Propagate TF_CLI_CONFIG_FILE env variable ([#555](#555)). * Update Terraform provider schema structs ([#563](#563)). * Update inline JSON schema documentation ([#557](#557)). Dependencies: * Bump Go SDK to v0.12.0 ([#540](#540)). * Bump github.com/hashicorp/terraform-json from 0.17.0 to 0.17.1 ([#541](#541)).
Changes
When there are positional required parameters in the command which can't be unmarshalled from JSON, we should require them despite the fact
--json
flag is provided.The reason is that for some of the command, for example,
databricks groups patch ID
these arguments are actually path arguments in API and can't be set as part of--json
body provided.Original change which introduced this ignore logic is here: #405
Fixes #533, #537
Note: Code generation is based on the change in this PR: databricks/databricks-sdk-go#536
Tests
cli groups patch 123 --json {...}
works correctlyBackward compatibility tests with previous changes from #405
cli clusters events --json '{"cluster_id": "1029-xxxx"}'
- works, returns list of eventscli clusters events 1029-xxxx
- works, returns list of eventscli clusters events
- works, first prompts for Cluster ID and then returns the list of events