Commit Graph

7 Commits

Author SHA1 Message Date
Pieter Noordhuis 3fa400f00f
Remove dependency on global state in generated commands (#595)
## Changes

Generated commands relied on global variables for flags and request
payloads. This is difficult to test if a sequence of tests tries to run
the same command with various arguments because the global state causes
test interference. Moreover, it is impossible to run tests in parallel.

This change modifies the approach and turns every command group and
command itself into a function that returns a `*cobra.Command`. All
flags and request payloads are variables scoped to the command's
initialization function. This means it is possible to construct
independent copies of the CLI structure and fixes the test isolation
issue.

The scope of this change is only the generated commands. The other
commands will be changed accordingly in subsequent changes.

## Tests

Unit and integration tests pass.
2023-07-25 20:19:07 +02:00
Andrew Nester 17ed7a317b
Fixed ignoring required positional parameters when --json flag is provided (#535)
## 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:
https://github.com/databricks/cli/pull/405

Fixes https://github.com/databricks/cli/issues/533,
https://github.com/databricks/cli/issues/537

Note: Code generation is based on the change in this PR:
https://github.com/databricks/databricks-sdk-go/pull/536

## Tests
1. Running `cli groups patch 123 --json {...}` works correctly

Backward compatibility tests with previous changes from
https://github.com/databricks/cli/pull/405
1. `cli clusters events --json '{"cluster_id": "1029-xxxx"}'` - works,
returns list of events
2. `cli clusters events 1029-xxxx` - works, returns list of events
3. `cli clusters events` - works, first prompts for Cluster ID and then
returns the list of events
2023-07-03 13:20:30 +02:00
dependabot[bot] 7fb34e4767
Bump github.com/databricks/databricks-sdk-go from 0.9.1-0.20230614092458-b5bbc1c8dabb to 0.10.0 (#497) 2023-06-21 07:43:07 +00:00
Pieter Noordhuis dd92b3f989
Disable shell completions for generated commands (#483)
## Changes

Disable shell completions for generated commands.

Default completion behavior completes local files which never makes
sense.

Automatic contextual completion of required arguments would be super
powerful but a lot of work to get right. Until then, we could do manual
completion functions in `overrides.go` as needed.

This fixes #374.

## Tests

Confirmed manually that commands no longer complete local files.
2023-06-15 14:56:36 +00:00
Pieter Noordhuis 96643fd746
Hide commands under preview from help output (#469)
## Changes

TSIA

Depends on https://github.com/databricks/databricks-sdk-go/pull/497.

## Tests

Manually looked at the help output and no longer see the hidden commands.
2023-06-14 14:59:57 +00:00
Pieter Noordhuis f219a0da5a
Annotate generated commands with OpenAPI package name (#466)
Co-authored-by: Serge Smertin <259697+nfx@users.noreply.github.com>
2023-06-13 17:20:42 +02:00
Serge Smertin 2aa61a7c1b
Update with the latest Go SDK (#457)
## Changes
- removed deprecated methods
- regenerated with the latest OpenAPI spec
- picked up the latest go SDK version

## Tests
`make test`
2023-06-12 14:23:21 +02:00