databricks-cli/libs/command/workspace_client.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
621 B
Go
Raw Normal View History

package command
import (
"context"
"github.com/databricks/databricks-sdk-go"
)
func SetWorkspaceClient(ctx context.Context, w *databricks.WorkspaceClient) context.Context {
if v := ctx.Value(workspaceClientKey); v != nil {
panic("command.SetWorkspaceClient called twice on the same context.")
}
return context.WithValue(ctx, workspaceClientKey, w)
}
func WorkspaceClient(ctx context.Context) *databricks.WorkspaceClient {
v := ctx.Value(workspaceClientKey)
if v == nil {
panic("command.WorkspaceClient called without calling command.SetWorkspaceClient first.")
}
return v.(*databricks.WorkspaceClient)
}