-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move WorkspaceClient
to libs/command
#2444
Conversation
WorkspaceClient
to libs/command
) | ||
|
||
func SetWorkspaceClient(ctx context.Context, w *databricks.WorkspaceClient) context.Context { | ||
if v := ctx.Value(workspaceClientKey); v != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might okay to do so, for example, overriding with a different workspace client or smth like this, any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like having this restriction because ideally every command should only configure a working workspace client once. This keep reasoning about auth simple and would force the upstream code to be designed better.
We can ofcourse remove it if we ever have a usercase where we need to override with a different workspace.
@@ -240,7 +241,7 @@ func new{{.PascalName}}() *cobra.Command { | |||
cmd.PreRunE = root.Must{{if .Service.IsAccounts}}Account{{else}}Workspace{{end}}Client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MustZZZ
functions should also move to the new pkg.
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 #2440.
Tests
Existing tests and one new unit test.
NO_CHANGELOG=true