databricks-cli/cmd/account
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
..
access-control Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
billable-usage Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
budgets Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
credentials Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
custom-app-integration Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
encryption-keys Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
groups Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
ip-access-lists Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
log-delivery Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
metastore-assignments Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
metastores Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
networks Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
o-auth-enrollment Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
private-access Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
published-app-integration Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
service-principal-secrets Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
service-principals Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
settings Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
storage Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
storage-credentials Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
users Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
vpc-endpoints Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
workspace-assignment Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
workspaces Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
cmd.go Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
groups.go Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00