databricks-cli/cmd/root
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
..
auth.go Support tab completion for profiles (#572) 2023-07-12 12:05:51 +02:00
bundle.go Correctly use --profile flag passed for all bundle commands (#571) 2023-07-12 14:09:25 +02:00
bundle_test.go Correctly use --profile flag passed for all bundle commands (#571) 2023-07-12 14:09:25 +02:00
io.go Rename: bricks -> databricks (#393) 2023-05-22 16:40:50 +02:00
logger.go Do not use white color as string output (#489) 2023-06-16 13:55:22 +00:00
progress_logger.go Rename: bricks -> databricks (#393) 2023-05-22 16:40:50 +02:00
progress_logger_test.go Rename bricks -> databricks (#389) 2023-05-16 18:35:39 +02:00
root.go Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
user_agent.go Rename bricks -> databricks (#389) 2023-05-16 18:35:39 +02:00
user_agent_command.go Move code for including command name in user agent (#203) 2023-02-15 10:33:35 +01:00
user_agent_command_test.go Move code for including command name in user agent (#203) 2023-02-15 10:33:35 +01:00
user_agent_upstream.go Rename: bricks -> databricks (#393) 2023-05-22 16:40:50 +02:00
user_agent_upstream_test.go Let caller set BRICKS_UPSTREAM for user agent (#196) 2023-02-03 17:05:58 +01:00