Commit Graph

3 Commits

Author SHA1 Message Date
shreyas-goenka af3914db61
Move `WorkspaceClient` to `libs/command` (#2444)
## Changes
Move the WorkspaceClient reader and setter from the root package to
`libs/command`.

## Why
This allows us to read the workspace client set in the context in all
CLI packages. This was not possible before because using
`root.WorkspaceClient` would often result in an import cycle.

This would also allow us to standardise reads of the workspace client to
be from the context in bundle commands. Today those are read from the
bundle object tree instead.

This is a natural followup to
https://github.com/databricks/cli/pull/2440.

## Tests
Existing tests and one new unit test.

NO_CHANGELOG=true
2025-03-07 16:47:19 +00:00
shreyas-goenka 5948339f92
Add unit test for `command.ConfigUsed` (#2446)
## Changes
I forgot to add a unit test in the original PR, so adding it here:
https://github.com/databricks/cli/pull/2440

## Why
Unit testing code is a good practice. I believe we all should unit test
code.

## Tests
N/A

NO_CHANGELOG=true
2025-03-07 11:42:43 +00:00
shreyas-goenka 10b245d10c
Move `ConfigUsed` to `libs/command` (#2440)
## Changes
This PR moves `ConfigUsed` from the root package to `libs/command`.

## Why
Having the ConfigUsed function in the root package is a problem because
that means we cannot use that function from outside the `root` package
since doing so often leads to an import cycle (because `root` imports
everything implicitly).

Moving it to a separate package that consolidates the read interaction
and solves the import cycle issue. Example where this would have
simplified code:
https://github.com/databricks/cli/pull/2432#discussion_r1983368092

I'd like to send PRs to do the same for the workspace client and account
client as well. I'll wait however until this one is merged incase people
have concerns about the approach here.

## Tests
Existing tests.
2025-03-06 17:08:55 +00:00