databricks-cli/cmd/workspace
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
..
alerts Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
catalogs Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
clean-rooms Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
cluster-policies Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
clusters Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
connections Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
current-user Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
dashboards Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
data-sources Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
experiments Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
external-locations Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
functions Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
git-credentials Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
global-init-scripts Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
grants 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
instance-pools Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
instance-profiles 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
jobs Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
libraries 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
model-registry Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
permissions Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
pipelines Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
policy-families Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
providers Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
queries Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
query-history Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
recipient-activation Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
recipients Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
repos Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
schemas Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
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
serving-endpoints Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
shares 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
system-schemas Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
table-constraints Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
tables Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
token-management Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
tokens 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
volumes Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
warehouses Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
workspace Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
workspace-bindings Remove dependency on global state in generated commands (#595) 2023-07-25 20:19:07 +02:00
workspace-conf 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