diff --git a/.codegen/service.go.tmpl b/.codegen/service.go.tmpl index 33833dfa1..623ad746a 100644 --- a/.codegen/service.go.tmpl +++ b/.codegen/service.go.tmpl @@ -4,6 +4,7 @@ package {{(.TrimPrefix "account").SnakeName}} import ( "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/cmd/root" @@ -240,7 +241,7 @@ func new{{.PascalName}}() *cobra.Command { cmd.PreRunE = root.Must{{if .Service.IsAccounts}}Account{{else}}Workspace{{end}}Client cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - {{if .Service.IsAccounts}}a := root.AccountClient(ctx){{else}}w := root.WorkspaceClient(ctx){{end}} + {{if .Service.IsAccounts}}a := root.AccountClient(ctx){{else}}w := command.WorkspaceClient(ctx){{end}} {{- if .Request }} {{ if $canUseJson }} if cmd.Flags().Changed("json") { diff --git a/cmd/auth/describe.go b/cmd/auth/describe.go index 74a691787..5e3075cf2 100644 --- a/cmd/auth/describe.go +++ b/cmd/auth/describe.go @@ -110,7 +110,7 @@ func getAuthStatus(cmd *cobra.Command, args []string, showSensitive bool, fn try return &status, nil } - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) me, err := w.CurrentUser.Me(ctx) if err != nil { return &authStatus{ diff --git a/cmd/auth/describe_test.go b/cmd/auth/describe_test.go index 35e0c6e64..ea480c86f 100644 --- a/cmd/auth/describe_test.go +++ b/cmd/auth/describe_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/config" "github.com/databricks/databricks-sdk-go/experimental/mocks" "github.com/databricks/databricks-sdk-go/service/iam" @@ -17,7 +18,7 @@ import ( func TestGetWorkspaceAuthStatus(t *testing.T) { ctx := context.Background() m := mocks.NewMockWorkspaceClient(t) - ctx = root.SetWorkspaceClient(ctx, m.WorkspaceClient) + ctx = command.SetWorkspaceClient(ctx, m.WorkspaceClient) cmd := &cobra.Command{} cmd.SetContext(ctx) @@ -75,7 +76,7 @@ func TestGetWorkspaceAuthStatus(t *testing.T) { func TestGetWorkspaceAuthStatusError(t *testing.T) { ctx := context.Background() m := mocks.NewMockWorkspaceClient(t) - ctx = root.SetWorkspaceClient(ctx, m.WorkspaceClient) + ctx = command.SetWorkspaceClient(ctx, m.WorkspaceClient) cmd := &cobra.Command{} cmd.SetContext(ctx) @@ -124,7 +125,7 @@ func TestGetWorkspaceAuthStatusError(t *testing.T) { func TestGetWorkspaceAuthStatusSensitive(t *testing.T) { ctx := context.Background() m := mocks.NewMockWorkspaceClient(t) - ctx = root.SetWorkspaceClient(ctx, m.WorkspaceClient) + ctx = command.SetWorkspaceClient(ctx, m.WorkspaceClient) cmd := &cobra.Command{} cmd.SetContext(ctx) diff --git a/cmd/fs/helpers.go b/cmd/fs/helpers.go index bda3239cf..dd4b016aa 100644 --- a/cmd/fs/helpers.go +++ b/cmd/fs/helpers.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/filer/completer" "github.com/spf13/cobra" @@ -35,7 +36,7 @@ func filerForPath(ctx context.Context, fullPath string) (filer.Filer, string, er } path := parts[1] - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) // If the specified path has the "Volumes" prefix, use the Files API. if strings.HasPrefix(path, "/Volumes/") { diff --git a/cmd/fs/helpers_test.go b/cmd/fs/helpers_test.go index a01035cc7..8c30b6d8b 100644 --- a/cmd/fs/helpers_test.go +++ b/cmd/fs/helpers_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/fakefs" "github.com/databricks/cli/libs/filer" "github.com/databricks/databricks-sdk-go/experimental/mocks" @@ -73,7 +73,7 @@ func mockMustWorkspaceClientFunc(cmd *cobra.Command, args []string) error { func setupCommand(t *testing.T) (*cobra.Command, *mocks.MockWorkspaceClient) { m := mocks.NewMockWorkspaceClient(t) ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, m.WorkspaceClient) + ctx = command.SetWorkspaceClient(ctx, m.WorkspaceClient) cmd := &cobra.Command{} cmd.SetContext(ctx) diff --git a/cmd/root/auth.go b/cmd/root/auth.go index 21b8c8a96..b6e081001 100644 --- a/cmd/root/auth.go +++ b/cmd/root/auth.go @@ -17,8 +17,7 @@ import ( // Placeholders to use as unique keys in context.Context. var ( - workspaceClient int - accountClient int + accountClient int ) type ErrNoWorkspaceProfiles struct { @@ -229,15 +228,11 @@ func MustWorkspaceClient(cmd *cobra.Command, args []string) error { return err } - ctx = context.WithValue(ctx, &workspaceClient, w) + ctx = command.SetWorkspaceClient(ctx, w) cmd.SetContext(ctx) return nil } -func SetWorkspaceClient(ctx context.Context, w *databricks.WorkspaceClient) context.Context { - return context.WithValue(ctx, &workspaceClient, w) -} - func SetAccountClient(ctx context.Context, a *databricks.AccountClient) context.Context { return context.WithValue(ctx, &accountClient, a) } @@ -321,14 +316,6 @@ func emptyHttpRequest(ctx context.Context) *http.Request { return req } -func WorkspaceClient(ctx context.Context) *databricks.WorkspaceClient { - w, ok := ctx.Value(&workspaceClient).(*databricks.WorkspaceClient) - if !ok { - panic("cannot get *databricks.WorkspaceClient. Please report it as a bug") - } - return w -} - func AccountClient(ctx context.Context) *databricks.AccountClient { a, ok := ctx.Value(&accountClient).(*databricks.AccountClient) if !ok { diff --git a/cmd/root/auth_test.go b/cmd/root/auth_test.go index 784598796..7c4523058 100644 --- a/cmd/root/auth_test.go +++ b/cmd/root/auth_test.go @@ -9,6 +9,7 @@ import ( "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -263,7 +264,7 @@ func TestMustAnyClientCanCreateWorkspaceClient(t *testing.T) { require.False(t, isAccount) require.NoError(t, err) - w := WorkspaceClient(cmd.Context()) + w := command.WorkspaceClient(cmd.Context()) require.NotNil(t, w) } diff --git a/cmd/sync/sync.go b/cmd/sync/sync.go index 0f4a4aacc..8a3bf1242 100644 --- a/cmd/sync/sync.go +++ b/cmd/sync/sync.go @@ -12,6 +12,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/deploy/files" "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/git" "github.com/databricks/cli/libs/log" @@ -65,7 +66,7 @@ func (f *syncFlags) syncOptionsFromArgs(cmd *cobra.Command, args []string) (*syn } ctx := cmd.Context() - client := root.WorkspaceClient(ctx) + client := command.WorkspaceClient(ctx) localRoot := vfs.MustNew(args[0]) info, err := git.FetchRepositoryInfo(ctx, localRoot.Native(), client) @@ -186,7 +187,7 @@ func New() *cobra.Command { case 0: return nil, cobra.ShellCompDirectiveFilterDirs case 1: - wsc := root.WorkspaceClient(cmd.Context()) + wsc := command.WorkspaceClient(cmd.Context()) return completeRemotePath(cmd.Context(), wsc, toComplete) default: return nil, cobra.ShellCompDirectiveNoFileComp diff --git a/cmd/sync/sync_test.go b/cmd/sync/sync_test.go index 8f65aedba..76f6e184c 100644 --- a/cmd/sync/sync_test.go +++ b/cmd/sync/sync_test.go @@ -8,7 +8,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" - "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/vfs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -58,7 +58,7 @@ func TestSyncOptionsFromArgs(t *testing.T) { f := syncFlags{} cmd := New() - cmd.SetContext(root.SetWorkspaceClient(context.Background(), nil)) + cmd.SetContext(command.SetWorkspaceClient(context.Background(), nil)) opts, err := f.syncOptionsFromArgs(cmd, []string{local, remote}) require.NoError(t, err) assert.Equal(t, local, opts.LocalRoot.Native()) diff --git a/cmd/workspace/access-control/access-control.go b/cmd/workspace/access-control/access-control.go index 7668265fb..ce89f9235 100755 --- a/cmd/workspace/access-control/access-control.go +++ b/cmd/workspace/access-control/access-control.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" @@ -70,7 +71,7 @@ func newCheckPolicy() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := checkPolicyJson.Unmarshal(&checkPolicyReq) diff --git a/cmd/workspace/aibi-dashboard-embedding-access-policy/aibi-dashboard-embedding-access-policy.go b/cmd/workspace/aibi-dashboard-embedding-access-policy/aibi-dashboard-embedding-access-policy.go index 3f905e521..328492dd1 100755 --- a/cmd/workspace/aibi-dashboard-embedding-access-policy/aibi-dashboard-embedding-access-policy.go +++ b/cmd/workspace/aibi-dashboard-embedding-access-policy/aibi-dashboard-embedding-access-policy.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -73,7 +74,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.AibiDashboardEmbeddingAccessPolicy().Delete(ctx, deleteReq) if err != nil { @@ -130,7 +131,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.AibiDashboardEmbeddingAccessPolicy().Get(ctx, getReq) if err != nil { @@ -180,7 +181,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/aibi-dashboard-embedding-approved-domains/aibi-dashboard-embedding-approved-domains.go b/cmd/workspace/aibi-dashboard-embedding-approved-domains/aibi-dashboard-embedding-approved-domains.go index 69db66504..fcd1dadcb 100755 --- a/cmd/workspace/aibi-dashboard-embedding-approved-domains/aibi-dashboard-embedding-approved-domains.go +++ b/cmd/workspace/aibi-dashboard-embedding-approved-domains/aibi-dashboard-embedding-approved-domains.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -73,7 +74,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.AibiDashboardEmbeddingApprovedDomains().Delete(ctx, deleteReq) if err != nil { @@ -128,7 +129,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.AibiDashboardEmbeddingApprovedDomains().Get(ctx, getReq) if err != nil { @@ -180,7 +181,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/alerts-legacy/alerts-legacy.go b/cmd/workspace/alerts-legacy/alerts-legacy.go index 4f7d5f966..f450d7743 100755 --- a/cmd/workspace/alerts-legacy/alerts-legacy.go +++ b/cmd/workspace/alerts-legacy/alerts-legacy.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" @@ -90,7 +91,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -160,7 +161,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -232,7 +233,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -299,7 +300,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.AlertsLegacy.List(ctx) if err != nil { return err @@ -360,7 +361,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/alerts/alerts.go b/cmd/workspace/alerts/alerts.go index 79467c405..5749642f6 100755 --- a/cmd/workspace/alerts/alerts.go +++ b/cmd/workspace/alerts/alerts.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" @@ -82,7 +83,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -145,7 +146,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -212,7 +213,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -289,7 +290,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Alerts.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -364,7 +365,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/apps/apps.go b/cmd/workspace/apps/apps.go index aa88fe072..23f358fb0 100755 --- a/cmd/workspace/apps/apps.go +++ b/cmd/workspace/apps/apps.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/apps" "github.com/spf13/cobra" @@ -114,7 +115,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.App) @@ -205,7 +206,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Name = args[0] @@ -277,7 +278,7 @@ func newDeploy() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deployJson.Unmarshal(&deployReq.AppDeployment) @@ -366,7 +367,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Name = args[0] @@ -426,7 +427,7 @@ func newGetDeployment() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getDeploymentReq.AppName = args[0] getDeploymentReq.DeploymentId = args[1] @@ -485,7 +486,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPermissionLevelsReq.AppName = args[0] @@ -544,7 +545,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPermissionsReq.AppName = args[0] @@ -602,7 +603,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Apps.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -658,7 +659,7 @@ func newListDeployments() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listDeploymentsReq.AppName = args[0] @@ -719,7 +720,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -794,7 +795,7 @@ func newStart() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) startReq.Name = args[0] @@ -876,7 +877,7 @@ func newStop() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) stopReq.Name = args[0] @@ -965,7 +966,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.App) @@ -1040,7 +1041,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/artifact-allowlists/artifact-allowlists.go b/cmd/workspace/artifact-allowlists/artifact-allowlists.go index e66833697..5b4eae827 100755 --- a/cmd/workspace/artifact-allowlists/artifact-allowlists.go +++ b/cmd/workspace/artifact-allowlists/artifact-allowlists.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -77,7 +78,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) _, err = fmt.Sscan(args[0], &getReq.ArtifactType) if err != nil { @@ -142,7 +143,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/automatic-cluster-update/automatic-cluster-update.go b/cmd/workspace/automatic-cluster-update/automatic-cluster-update.go index dca88f3d1..ba8b11248 100755 --- a/cmd/workspace/automatic-cluster-update/automatic-cluster-update.go +++ b/cmd/workspace/automatic-cluster-update/automatic-cluster-update.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -70,7 +71,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.AutomaticClusterUpdate().Get(ctx, getReq) if err != nil { @@ -124,7 +125,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/catalogs/catalogs.go b/cmd/workspace/catalogs/catalogs.go index ce37b6d54..5e5474e2b 100755 --- a/cmd/workspace/catalogs/catalogs.go +++ b/cmd/workspace/catalogs/catalogs.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -102,7 +103,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -177,7 +178,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Name = args[0] @@ -239,7 +240,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Name = args[0] @@ -302,7 +303,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Catalogs.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -367,7 +368,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/clean-room-assets/clean-room-assets.go b/cmd/workspace/clean-room-assets/clean-room-assets.go index 872f0ecef..9278415a3 100755 --- a/cmd/workspace/clean-room-assets/clean-room-assets.go +++ b/cmd/workspace/clean-room-assets/clean-room-assets.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/cleanrooms" "github.com/spf13/cobra" @@ -96,7 +97,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.Asset) @@ -169,7 +170,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.CleanRoomName = args[0] _, err = fmt.Sscan(args[1], &deleteReq.AssetType) @@ -235,7 +236,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.CleanRoomName = args[0] _, err = fmt.Sscan(args[1], &getReq.AssetType) @@ -298,7 +299,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listReq.CleanRoomName = args[0] @@ -376,7 +377,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.Asset) diff --git a/cmd/workspace/clean-room-task-runs/clean-room-task-runs.go b/cmd/workspace/clean-room-task-runs/clean-room-task-runs.go index b41e380cc..d66151220 100755 --- a/cmd/workspace/clean-room-task-runs/clean-room-task-runs.go +++ b/cmd/workspace/clean-room-task-runs/clean-room-task-runs.go @@ -5,6 +5,7 @@ package clean_room_task_runs import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/service/cleanrooms" "github.com/spf13/cobra" ) @@ -74,7 +75,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listReq.CleanRoomName = args[0] diff --git a/cmd/workspace/clean-rooms/clean-rooms.go b/cmd/workspace/clean-rooms/clean-rooms.go index 4fe61d56b..4f25d1c33 100755 --- a/cmd/workspace/clean-rooms/clean-rooms.go +++ b/cmd/workspace/clean-rooms/clean-rooms.go @@ -5,6 +5,7 @@ package clean_rooms import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/cleanrooms" "github.com/spf13/cobra" @@ -92,7 +93,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.CleanRoom) @@ -166,7 +167,7 @@ func newCreateOutputCatalog() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createOutputCatalogJson.Unmarshal(&createOutputCatalogReq.OutputCatalog) @@ -239,7 +240,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Name = args[0] @@ -294,7 +295,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Name = args[0] @@ -353,7 +354,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.CleanRooms.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -413,7 +414,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/cluster-policies/cluster-policies.go b/cmd/workspace/cluster-policies/cluster-policies.go index 9e50065f9..0a1ae8d2a 100755 --- a/cmd/workspace/cluster-policies/cluster-policies.go +++ b/cmd/workspace/cluster-policies/cluster-policies.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" @@ -110,7 +111,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -188,7 +189,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -293,7 +294,7 @@ func newEdit() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := editJson.Unmarshal(&editReq) @@ -376,7 +377,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -446,7 +447,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -517,7 +518,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -592,7 +593,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ClusterPolicies.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -646,7 +647,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -733,7 +734,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/clusters/clusters.go b/cmd/workspace/clusters/clusters.go index 343cdf074..b43f28388 100755 --- a/cmd/workspace/clusters/clusters.go +++ b/cmd/workspace/clusters/clusters.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" @@ -131,7 +132,7 @@ func newChangeOwner() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := changeOwnerJson.Unmarshal(&changeOwnerReq) @@ -277,7 +278,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -377,7 +378,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -546,7 +547,7 @@ func newEdit() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := editJson.Unmarshal(&editReq) @@ -650,7 +651,7 @@ func newEvents() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := eventsJson.Unmarshal(&eventsReq) @@ -736,7 +737,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -806,7 +807,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -877,7 +878,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -956,7 +957,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Clusters.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -997,7 +998,7 @@ func newListNodeTypes() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Clusters.ListNodeTypes(ctx) if err != nil { return err @@ -1040,7 +1041,7 @@ func newListZones() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Clusters.ListZones(ctx) if err != nil { return err @@ -1108,7 +1109,7 @@ func newPermanentDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := permanentDeleteJson.Unmarshal(&permanentDeleteReq) @@ -1206,7 +1207,7 @@ func newPin() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := pinJson.Unmarshal(&pinReq) @@ -1311,7 +1312,7 @@ func newResize() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := resizeJson.Unmarshal(&resizeReq) @@ -1427,7 +1428,7 @@ func newRestart() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := restartJson.Unmarshal(&restartReq) @@ -1528,7 +1529,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -1603,7 +1604,7 @@ func newSparkVersions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Clusters.SparkVersions(ctx) if err != nil { return err @@ -1678,7 +1679,7 @@ func newStart() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := startJson.Unmarshal(&startReq) @@ -1788,7 +1789,7 @@ func newUnpin() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := unpinJson.Unmarshal(&unpinReq) @@ -1906,7 +1907,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -1993,7 +1994,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/compliance-security-profile/compliance-security-profile.go b/cmd/workspace/compliance-security-profile/compliance-security-profile.go index 58f3eddad..369b6d2c1 100755 --- a/cmd/workspace/compliance-security-profile/compliance-security-profile.go +++ b/cmd/workspace/compliance-security-profile/compliance-security-profile.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -73,7 +74,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.ComplianceSecurityProfile().Get(ctx, getReq) if err != nil { @@ -127,7 +128,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/connections/connections.go b/cmd/workspace/connections/connections.go index 161f5ab41..2ff726fc3 100755 --- a/cmd/workspace/connections/connections.go +++ b/cmd/workspace/connections/connections.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -89,7 +90,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -155,7 +156,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -225,7 +226,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -300,7 +301,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Connections.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -358,7 +359,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/consumer-fulfillments/consumer-fulfillments.go b/cmd/workspace/consumer-fulfillments/consumer-fulfillments.go index 46fd27c6f..477e7587f 100755 --- a/cmd/workspace/consumer-fulfillments/consumer-fulfillments.go +++ b/cmd/workspace/consumer-fulfillments/consumer-fulfillments.go @@ -5,6 +5,7 @@ package consumer_fulfillments import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" ) @@ -71,7 +72,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.ListingId = args[0] @@ -130,7 +131,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listReq.ListingId = args[0] diff --git a/cmd/workspace/consumer-installations/consumer-installations.go b/cmd/workspace/consumer-installations/consumer-installations.go index 1848cb8fc..3be76ea0e 100755 --- a/cmd/workspace/consumer-installations/consumer-installations.go +++ b/cmd/workspace/consumer-installations/consumer-installations.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" @@ -83,7 +84,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -150,7 +151,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.ListingId = args[0] deleteReq.InstallationId = args[1] @@ -209,7 +210,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ConsumerInstallations.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -262,7 +263,7 @@ func newListListingInstallations() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listListingInstallationsReq.ListingId = args[0] @@ -322,7 +323,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/consumer-listings/consumer-listings.go b/cmd/workspace/consumer-listings/consumer-listings.go index 5a8f76e36..99190b514 100755 --- a/cmd/workspace/consumer-listings/consumer-listings.go +++ b/cmd/workspace/consumer-listings/consumer-listings.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" ) @@ -76,7 +77,7 @@ func newBatchGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.ConsumerListings.BatchGet(ctx, batchGetReq) if err != nil { @@ -125,7 +126,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -208,7 +209,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ConsumerListings.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -266,7 +267,7 @@ func newSearch() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) diff --git a/cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go b/cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go index 6d751c631..2dba5a119 100755 --- a/cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go +++ b/cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" @@ -82,7 +83,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -152,7 +153,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.ListingId = args[0] @@ -210,7 +211,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ConsumerPersonalizationRequests.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) diff --git a/cmd/workspace/consumer-providers/consumer-providers.go b/cmd/workspace/consumer-providers/consumer-providers.go index ab84249e9..702622520 100755 --- a/cmd/workspace/consumer-providers/consumer-providers.go +++ b/cmd/workspace/consumer-providers/consumer-providers.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" ) @@ -74,7 +75,7 @@ func newBatchGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.ConsumerProviders.BatchGet(ctx, batchGetReq) if err != nil { @@ -123,7 +124,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -200,7 +201,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ConsumerProviders.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) diff --git a/cmd/workspace/credentials-manager/credentials-manager.go b/cmd/workspace/credentials-manager/credentials-manager.go index e29bc0bd4..68d3714e1 100755 --- a/cmd/workspace/credentials-manager/credentials-manager.go +++ b/cmd/workspace/credentials-manager/credentials-manager.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -72,7 +73,7 @@ func newExchangeToken() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := exchangeTokenJson.Unmarshal(&exchangeTokenReq) diff --git a/cmd/workspace/credentials/credentials.go b/cmd/workspace/credentials/credentials.go index c54737e9a..e8dee15bc 100755 --- a/cmd/workspace/credentials/credentials.go +++ b/cmd/workspace/credentials/credentials.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -110,7 +111,7 @@ func newCreateCredential() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createCredentialJson.Unmarshal(&createCredentialReq) @@ -185,7 +186,7 @@ func newDeleteCredential() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteCredentialReq.NameArg = args[0] @@ -257,7 +258,7 @@ func newGenerateTemporaryServiceCredential() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := generateTemporaryServiceCredentialJson.Unmarshal(&generateTemporaryServiceCredentialReq) @@ -331,7 +332,7 @@ func newGetCredential() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getCredentialReq.NameArg = args[0] @@ -395,7 +396,7 @@ func newListCredentials() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Credentials.ListCredentials(ctx, listCredentialsReq) return cmdio.RenderIterator(ctx, response) @@ -466,7 +467,7 @@ func newUpdateCredential() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateCredentialJson.Unmarshal(&updateCredentialReq) @@ -558,7 +559,7 @@ func newValidateCredential() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := validateCredentialJson.Unmarshal(&validateCredentialReq) diff --git a/cmd/workspace/current-user/current-user.go b/cmd/workspace/current-user/current-user.go index a42c3ead5..4bb088dc9 100755 --- a/cmd/workspace/current-user/current-user.go +++ b/cmd/workspace/current-user/current-user.go @@ -5,6 +5,7 @@ package current_user import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/spf13/cobra" ) @@ -57,7 +58,7 @@ func newMe() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.CurrentUser.Me(ctx) if err != nil { return err diff --git a/cmd/workspace/dashboard-widgets/dashboard-widgets.go b/cmd/workspace/dashboard-widgets/dashboard-widgets.go index e42818266..62cc20009 100755 --- a/cmd/workspace/dashboard-widgets/dashboard-widgets.go +++ b/cmd/workspace/dashboard-widgets/dashboard-widgets.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" @@ -72,7 +73,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -141,7 +142,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Id = args[0] @@ -199,7 +200,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/dashboards/dashboards.go b/cmd/workspace/dashboards/dashboards.go index 5bdd7b137..c1a54c77a 100755 --- a/cmd/workspace/dashboards/dashboards.go +++ b/cmd/workspace/dashboards/dashboards.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" @@ -75,7 +76,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -139,7 +140,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -207,7 +208,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -287,7 +288,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Dashboards.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -332,7 +333,7 @@ func newRestore() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -408,7 +409,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/data-sources/data-sources.go b/cmd/workspace/data-sources/data-sources.go index 9f8a9dcd7..60dbc65e0 100755 --- a/cmd/workspace/data-sources/data-sources.go +++ b/cmd/workspace/data-sources/data-sources.go @@ -5,6 +5,7 @@ package data_sources import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/spf13/cobra" ) @@ -77,7 +78,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.DataSources.List(ctx) if err != nil { return err diff --git a/cmd/workspace/default-namespace/default-namespace.go b/cmd/workspace/default-namespace/default-namespace.go index e5039cbaf..38741cac1 100755 --- a/cmd/workspace/default-namespace/default-namespace.go +++ b/cmd/workspace/default-namespace/default-namespace.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -85,7 +86,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.DefaultNamespace().Delete(ctx, deleteReq) if err != nil { @@ -140,7 +141,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.DefaultNamespace().Get(ctx, getReq) if err != nil { @@ -196,7 +197,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/disable-legacy-access/disable-legacy-access.go b/cmd/workspace/disable-legacy-access/disable-legacy-access.go index c50de446b..f5da6a530 100755 --- a/cmd/workspace/disable-legacy-access/disable-legacy-access.go +++ b/cmd/workspace/disable-legacy-access/disable-legacy-access.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -79,7 +80,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.DisableLegacyAccess().Delete(ctx, deleteReq) if err != nil { @@ -134,7 +135,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.DisableLegacyAccess().Get(ctx, getReq) if err != nil { @@ -184,7 +185,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/disable-legacy-dbfs/disable-legacy-dbfs.go b/cmd/workspace/disable-legacy-dbfs/disable-legacy-dbfs.go index d09755370..e4d69f825 100755 --- a/cmd/workspace/disable-legacy-dbfs/disable-legacy-dbfs.go +++ b/cmd/workspace/disable-legacy-dbfs/disable-legacy-dbfs.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -76,7 +77,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.DisableLegacyDbfs().Delete(ctx, deleteReq) if err != nil { @@ -131,7 +132,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.DisableLegacyDbfs().Get(ctx, getReq) if err != nil { @@ -181,7 +182,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go b/cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go index 3d99ecef8..9999466ec 100755 --- a/cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go +++ b/cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -75,7 +76,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.EnhancedSecurityMonitoring().Get(ctx, getReq) if err != nil { @@ -129,7 +130,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/experiments/experiments.go b/cmd/workspace/experiments/experiments.go index 05a301897..7f1a8b35f 100755 --- a/cmd/workspace/experiments/experiments.go +++ b/cmd/workspace/experiments/experiments.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/ml" "github.com/spf13/cobra" @@ -127,7 +128,7 @@ func newCreateExperiment() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createExperimentJson.Unmarshal(&createExperimentReq) @@ -207,7 +208,7 @@ func newCreateRun() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createRunJson.Unmarshal(&createRunReq) @@ -287,7 +288,7 @@ func newDeleteExperiment() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteExperimentJson.Unmarshal(&deleteExperimentReq) @@ -368,7 +369,7 @@ func newDeleteRun() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteRunJson.Unmarshal(&deleteRunReq) @@ -456,7 +457,7 @@ func newDeleteRuns() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteRunsJson.Unmarshal(&deleteRunsReq) @@ -545,7 +546,7 @@ func newDeleteTag() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteTagJson.Unmarshal(&deleteTagReq) @@ -628,7 +629,7 @@ func newGetByName() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getByNameReq.ExperimentName = args[0] @@ -686,7 +687,7 @@ func newGetExperiment() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getExperimentReq.ExperimentId = args[0] @@ -749,7 +750,7 @@ func newGetHistory() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getHistoryReq.MetricKey = args[0] @@ -804,7 +805,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPermissionLevelsReq.ExperimentId = args[0] @@ -863,7 +864,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPermissionsReq.ExperimentId = args[0] @@ -928,7 +929,7 @@ func newGetRun() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getRunReq.RunId = args[0] @@ -993,7 +994,7 @@ func newListArtifacts() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Experiments.ListArtifacts(ctx, listArtifactsReq) return cmdio.RenderIterator(ctx, response) @@ -1047,7 +1048,7 @@ func newListExperiments() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Experiments.ListExperiments(ctx, listExperimentsReq) return cmdio.RenderIterator(ctx, response) @@ -1146,7 +1147,7 @@ func newLogBatch() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := logBatchJson.Unmarshal(&logBatchReq) @@ -1229,7 +1230,7 @@ func newLogInputs() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := logInputsJson.Unmarshal(&logInputsReq) @@ -1318,7 +1319,7 @@ func newLogMetric() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := logMetricJson.Unmarshal(&logMetricReq) @@ -1405,7 +1406,7 @@ func newLogModel() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := logModelJson.Unmarshal(&logModelReq) @@ -1490,7 +1491,7 @@ func newLogParam() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := logParamJson.Unmarshal(&logParamReq) @@ -1579,7 +1580,7 @@ func newRestoreExperiment() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := restoreExperimentJson.Unmarshal(&restoreExperimentReq) @@ -1664,7 +1665,7 @@ func newRestoreRun() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := restoreRunJson.Unmarshal(&restoreRunReq) @@ -1752,7 +1753,7 @@ func newRestoreRuns() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := restoreRunsJson.Unmarshal(&restoreRunsReq) @@ -1835,7 +1836,7 @@ func newSearchExperiments() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := searchExperimentsJson.Unmarshal(&searchExperimentsReq) @@ -1909,7 +1910,7 @@ func newSearchRuns() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := searchRunsJson.Unmarshal(&searchRunsReq) @@ -1987,7 +1988,7 @@ func newSetExperimentTag() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setExperimentTagJson.Unmarshal(&setExperimentTagReq) @@ -2071,7 +2072,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -2156,7 +2157,7 @@ func newSetTag() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setTagJson.Unmarshal(&setTagReq) @@ -2242,7 +2243,7 @@ func newUpdateExperiment() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateExperimentJson.Unmarshal(&updateExperimentReq) @@ -2319,7 +2320,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -2394,7 +2395,7 @@ func newUpdateRun() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateRunJson.Unmarshal(&updateRunReq) diff --git a/cmd/workspace/external-locations/external-locations.go b/cmd/workspace/external-locations/external-locations.go index 82fd8d7e1..f09c5bba8 100755 --- a/cmd/workspace/external-locations/external-locations.go +++ b/cmd/workspace/external-locations/external-locations.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -109,7 +110,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -190,7 +191,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Name = args[0] @@ -252,7 +253,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Name = args[0] @@ -314,7 +315,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ExternalLocations.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -384,7 +385,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/functions/functions.go b/cmd/workspace/functions/functions.go index 86b292674..be1183011 100755 --- a/cmd/workspace/functions/functions.go +++ b/cmd/workspace/functions/functions.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -82,7 +83,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -156,7 +157,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -235,7 +236,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -321,7 +322,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listReq.CatalogName = args[0] listReq.SchemaName = args[1] @@ -384,7 +385,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/genie/genie.go b/cmd/workspace/genie/genie.go index 3ede258ea..9cfe33536 100755 --- a/cmd/workspace/genie/genie.go +++ b/cmd/workspace/genie/genie.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/dashboards" "github.com/spf13/cobra" @@ -105,7 +106,7 @@ func newCreateMessage() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createMessageJson.Unmarshal(&createMessageReq) @@ -194,7 +195,7 @@ func newExecuteMessageQuery() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) executeMessageQueryReq.SpaceId = args[0] executeMessageQueryReq.ConversationId = args[1] @@ -258,7 +259,7 @@ func newGetMessage() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getMessageReq.SpaceId = args[0] getMessageReq.ConversationId = args[1] @@ -322,7 +323,7 @@ func newGetMessageQueryResult() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getMessageQueryResultReq.SpaceId = args[0] getMessageQueryResultReq.ConversationId = args[1] @@ -387,7 +388,7 @@ func newGetMessageQueryResultByAttachment() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getMessageQueryResultByAttachmentReq.SpaceId = args[0] getMessageQueryResultByAttachmentReq.ConversationId = args[1] @@ -448,7 +449,7 @@ func newGetSpace() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getSpaceReq.SpaceId = args[0] @@ -522,7 +523,7 @@ func newStartConversation() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := startConversationJson.Unmarshal(&startConversationReq) diff --git a/cmd/workspace/git-credentials/git-credentials.go b/cmd/workspace/git-credentials/git-credentials.go index 978ca6bac..7c9811525 100755 --- a/cmd/workspace/git-credentials/git-credentials.go +++ b/cmd/workspace/git-credentials/git-credentials.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/workspace" "github.com/spf13/cobra" @@ -100,7 +101,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -167,7 +168,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -240,7 +241,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -306,7 +307,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.GitCredentials.List(ctx) return cmdio.RenderIterator(ctx, response) } @@ -374,7 +375,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/global-init-scripts/global-init-scripts.go b/cmd/workspace/global-init-scripts/global-init-scripts.go index 52adde3fb..f068fbe66 100755 --- a/cmd/workspace/global-init-scripts/global-init-scripts.go +++ b/cmd/workspace/global-init-scripts/global-init-scripts.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" @@ -98,7 +99,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -168,7 +169,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -238,7 +239,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -303,7 +304,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.GlobalInitScripts.List(ctx) return cmdio.RenderIterator(ctx, response) } @@ -370,7 +371,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/grants/grants.go b/cmd/workspace/grants/grants.go index b1dd4e8cb..7b22893ee 100755 --- a/cmd/workspace/grants/grants.go +++ b/cmd/workspace/grants/grants.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -88,7 +89,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) _, err = fmt.Sscan(args[0], &getReq.SecurableType) if err != nil { @@ -153,7 +154,7 @@ func newGetEffective() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) _, err = fmt.Sscan(args[0], &getEffectiveReq.SecurableType) if err != nil { @@ -220,7 +221,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/groups/groups.go b/cmd/workspace/groups/groups.go index a2d323106..fc3506f50 100755 --- a/cmd/workspace/groups/groups.go +++ b/cmd/workspace/groups/groups.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" @@ -94,7 +95,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -158,7 +159,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -228,7 +229,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -308,7 +309,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Groups.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -361,7 +362,7 @@ func newPatch() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -455,7 +456,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/instance-pools/instance-pools.go b/cmd/workspace/instance-pools/instance-pools.go index 40c76a5dd..9e4d1592d 100755 --- a/cmd/workspace/instance-pools/instance-pools.go +++ b/cmd/workspace/instance-pools/instance-pools.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" @@ -125,7 +126,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -209,7 +210,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -318,7 +319,7 @@ func newEdit() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := editJson.Unmarshal(&editReq) @@ -391,7 +392,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -461,7 +462,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -532,7 +533,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -594,7 +595,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.InstancePools.List(ctx) return cmdio.RenderIterator(ctx, response) } @@ -647,7 +648,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -734,7 +735,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/instance-profiles/instance-profiles.go b/cmd/workspace/instance-profiles/instance-profiles.go index 5c4bc8d9b..b9add5321 100755 --- a/cmd/workspace/instance-profiles/instance-profiles.go +++ b/cmd/workspace/instance-profiles/instance-profiles.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" @@ -96,7 +97,7 @@ func newAdd() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := addJson.Unmarshal(&addReq) @@ -195,7 +196,7 @@ func newEdit() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := editJson.Unmarshal(&editReq) @@ -256,7 +257,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.InstanceProfiles.List(ctx) return cmdio.RenderIterator(ctx, response) } @@ -320,7 +321,7 @@ func newRemove() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := removeJson.Unmarshal(&removeReq) diff --git a/cmd/workspace/ip-access-lists/ip-access-lists.go b/cmd/workspace/ip-access-lists/ip-access-lists.go index 070f279ec..09e6f2b9d 100755 --- a/cmd/workspace/ip-access-lists/ip-access-lists.go +++ b/cmd/workspace/ip-access-lists/ip-access-lists.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -130,7 +131,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -203,7 +204,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -273,7 +274,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -335,7 +336,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.IpAccessLists.List(ctx) return cmdio.RenderIterator(ctx, response) } @@ -417,7 +418,7 @@ func newReplace() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := replaceJson.Unmarshal(&replaceReq) @@ -519,7 +520,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/jobs/jobs.go b/cmd/workspace/jobs/jobs.go index 0f911d400..fd9783d20 100755 --- a/cmd/workspace/jobs/jobs.go +++ b/cmd/workspace/jobs/jobs.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/spf13/cobra" @@ -113,7 +114,7 @@ func newCancelAllRuns() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := cancelAllRunsJson.Unmarshal(&cancelAllRunsReq) @@ -196,7 +197,7 @@ func newCancelRun() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := cancelRunJson.Unmarshal(&cancelRunReq) @@ -300,7 +301,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -379,7 +380,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -478,7 +479,7 @@ func newDeleteRun() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteRunJson.Unmarshal(&deleteRunReq) @@ -566,7 +567,7 @@ func newExportRun() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -648,7 +649,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -721,7 +722,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -792,7 +793,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -878,7 +879,7 @@ func newGetRun() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -960,7 +961,7 @@ func newGetRunOutput() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -1041,7 +1042,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Jobs.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -1102,7 +1103,7 @@ func newListRuns() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Jobs.ListRuns(ctx, listRunsReq) return cmdio.RenderIterator(ctx, response) @@ -1184,7 +1185,7 @@ func newRepairRun() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := repairRunJson.Unmarshal(&repairRunReq) @@ -1289,7 +1290,7 @@ func newReset() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := resetJson.Unmarshal(&resetReq) @@ -1387,7 +1388,7 @@ func newRunNow() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := runNowJson.Unmarshal(&runNowReq) @@ -1498,7 +1499,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -1607,7 +1608,7 @@ func newSubmit() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := submitJson.Unmarshal(&submitReq) @@ -1707,7 +1708,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -1798,7 +1799,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/lakeview-embedded/lakeview-embedded.go b/cmd/workspace/lakeview-embedded/lakeview-embedded.go index ef04c2c13..1d369f715 100755 --- a/cmd/workspace/lakeview-embedded/lakeview-embedded.go +++ b/cmd/workspace/lakeview-embedded/lakeview-embedded.go @@ -4,6 +4,7 @@ package lakeview_embedded import ( "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/service/dashboards" "github.com/spf13/cobra" ) @@ -72,7 +73,7 @@ func newGetPublishedDashboardEmbedded() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPublishedDashboardEmbeddedReq.DashboardId = args[0] diff --git a/cmd/workspace/lakeview/lakeview.go b/cmd/workspace/lakeview/lakeview.go index eb2f5d8fa..be038432a 100755 --- a/cmd/workspace/lakeview/lakeview.go +++ b/cmd/workspace/lakeview/lakeview.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/dashboards" "github.com/spf13/cobra" @@ -96,7 +97,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.Dashboard) @@ -170,7 +171,7 @@ func newCreateSchedule() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createScheduleJson.Unmarshal(&createScheduleReq.Schedule) @@ -242,7 +243,7 @@ func newCreateSubscription() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createSubscriptionJson.Unmarshal(&createSubscriptionReq.Subscription) @@ -312,7 +313,7 @@ func newDeleteSchedule() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteScheduleReq.DashboardId = args[0] deleteScheduleReq.ScheduleId = args[1] @@ -371,7 +372,7 @@ func newDeleteSubscription() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteSubscriptionReq.DashboardId = args[0] deleteSubscriptionReq.ScheduleId = args[1] @@ -431,7 +432,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.DashboardId = args[0] @@ -489,7 +490,7 @@ func newGetPublished() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPublishedReq.DashboardId = args[0] @@ -546,7 +547,7 @@ func newGetSchedule() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getScheduleReq.DashboardId = args[0] getScheduleReq.ScheduleId = args[1] @@ -605,7 +606,7 @@ func newGetSubscription() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getSubscriptionReq.DashboardId = args[0] getSubscriptionReq.ScheduleId = args[1] @@ -664,7 +665,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Lakeview.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -717,7 +718,7 @@ func newListSchedules() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listSchedulesReq.DashboardId = args[0] @@ -773,7 +774,7 @@ func newListSubscriptions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listSubscriptionsReq.DashboardId = args[0] listSubscriptionsReq.ScheduleId = args[1] @@ -842,7 +843,7 @@ func newMigrate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := migrateJson.Unmarshal(&migrateReq) @@ -919,7 +920,7 @@ func newPublish() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := publishJson.Unmarshal(&publishReq) @@ -989,7 +990,7 @@ func newTrash() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) trashReq.DashboardId = args[0] @@ -1047,7 +1048,7 @@ func newUnpublish() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) unpublishReq.DashboardId = args[0] @@ -1112,7 +1113,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.Dashboard) @@ -1188,7 +1189,7 @@ func newUpdateSchedule() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateScheduleJson.Unmarshal(&updateScheduleReq.Schedule) diff --git a/cmd/workspace/libraries/libraries.go b/cmd/workspace/libraries/libraries.go index e6b332aef..b7c192358 100755 --- a/cmd/workspace/libraries/libraries.go +++ b/cmd/workspace/libraries/libraries.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" @@ -79,7 +80,7 @@ func newAllClusterStatuses() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Libraries.AllClusterStatuses(ctx) return cmdio.RenderIterator(ctx, response) } @@ -137,7 +138,7 @@ func newClusterStatus() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) clusterStatusReq.ClusterId = args[0] @@ -187,7 +188,7 @@ func newInstall() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := installJson.Unmarshal(&installReq) @@ -254,7 +255,7 @@ func newUninstall() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := uninstallJson.Unmarshal(&uninstallReq) diff --git a/cmd/workspace/metastores/metastores.go b/cmd/workspace/metastores/metastores.go index 563beb2f4..7cd4b97f4 100755 --- a/cmd/workspace/metastores/metastores.go +++ b/cmd/workspace/metastores/metastores.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -109,7 +110,7 @@ func newAssign() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := assignJson.Unmarshal(&assignReq) @@ -204,7 +205,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -263,7 +264,7 @@ func newCurrent() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Metastores.Current(ctx) if err != nil { return err @@ -315,7 +316,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -386,7 +387,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -450,7 +451,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Metastores.List(ctx) return cmdio.RenderIterator(ctx, response) } @@ -490,7 +491,7 @@ func newSummary() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Metastores.Summary(ctx) if err != nil { return err @@ -546,7 +547,7 @@ func newUnassign() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) _, err = fmt.Sscan(args[0], &unassignReq.WorkspaceId) if err != nil { @@ -615,7 +616,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -705,7 +706,7 @@ func newUpdateAssignment() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateAssignmentJson.Unmarshal(&updateAssignmentReq) diff --git a/cmd/workspace/model-registry/model-registry.go b/cmd/workspace/model-registry/model-registry.go index 194464691..374b20245 100755 --- a/cmd/workspace/model-registry/model-registry.go +++ b/cmd/workspace/model-registry/model-registry.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/ml" "github.com/spf13/cobra" @@ -138,7 +139,7 @@ func newApproveTransitionRequest() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := approveTransitionRequestJson.Unmarshal(&approveTransitionRequestReq) @@ -238,7 +239,7 @@ func newCreateComment() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createCommentJson.Unmarshal(&createCommentReq) @@ -331,7 +332,7 @@ func newCreateModel() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createModelJson.Unmarshal(&createModelReq) @@ -418,7 +419,7 @@ func newCreateModelVersion() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createModelVersionJson.Unmarshal(&createModelVersionReq) @@ -514,7 +515,7 @@ func newCreateTransitionRequest() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createTransitionRequestJson.Unmarshal(&createTransitionRequestReq) @@ -597,7 +598,7 @@ func newCreateWebhook() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createWebhookJson.Unmarshal(&createWebhookReq) @@ -665,7 +666,7 @@ func newDeleteComment() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteCommentReq.Id = args[0] @@ -723,7 +724,7 @@ func newDeleteModel() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteModelReq.Name = args[0] @@ -783,7 +784,7 @@ func newDeleteModelTag() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteModelTagReq.Name = args[0] deleteModelTagReq.Key = args[1] @@ -843,7 +844,7 @@ func newDeleteModelVersion() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteModelVersionReq.Name = args[0] deleteModelVersionReq.Version = args[1] @@ -905,7 +906,7 @@ func newDeleteModelVersionTag() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteModelVersionTagReq.Name = args[0] deleteModelVersionTagReq.Version = args[1] @@ -980,7 +981,7 @@ func newDeleteTransitionRequest() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteTransitionRequestReq.Name = args[0] deleteTransitionRequestReq.Version = args[1] @@ -1045,7 +1046,7 @@ func newDeleteWebhook() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) err = w.ModelRegistry.DeleteWebhook(ctx, deleteWebhookReq) if err != nil { @@ -1112,7 +1113,7 @@ func newGetLatestVersions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := getLatestVersionsJson.Unmarshal(&getLatestVersionsReq) @@ -1185,7 +1186,7 @@ func newGetModel() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getModelReq.Name = args[0] @@ -1244,7 +1245,7 @@ func newGetModelVersion() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getModelVersionReq.Name = args[0] getModelVersionReq.Version = args[1] @@ -1304,7 +1305,7 @@ func newGetModelVersionDownloadUri() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getModelVersionDownloadUriReq.Name = args[0] getModelVersionDownloadUriReq.Version = args[1] @@ -1363,7 +1364,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPermissionLevelsReq.RegisteredModelId = args[0] @@ -1422,7 +1423,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPermissionsReq.RegisteredModelId = args[0] @@ -1481,7 +1482,7 @@ func newListModels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ModelRegistry.ListModels(ctx, listModelsReq) return cmdio.RenderIterator(ctx, response) @@ -1535,7 +1536,7 @@ func newListTransitionRequests() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listTransitionRequestsReq.Name = args[0] listTransitionRequestsReq.Version = args[1] @@ -1594,7 +1595,7 @@ func newListWebhooks() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ModelRegistry.ListWebhooks(ctx, listWebhooksReq) return cmdio.RenderIterator(ctx, response) @@ -1668,7 +1669,7 @@ func newRejectTransitionRequest() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := rejectTransitionRequestJson.Unmarshal(&rejectTransitionRequestReq) @@ -1760,7 +1761,7 @@ func newRenameModel() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := renameModelJson.Unmarshal(&renameModelReq) @@ -1834,7 +1835,7 @@ func newSearchModelVersions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ModelRegistry.SearchModelVersions(ctx, searchModelVersionsReq) return cmdio.RenderIterator(ctx, response) @@ -1889,7 +1890,7 @@ func newSearchModels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ModelRegistry.SearchModels(ctx, searchModelsReq) return cmdio.RenderIterator(ctx, response) @@ -1958,7 +1959,7 @@ func newSetModelTag() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setModelTagJson.Unmarshal(&setModelTagReq) @@ -2053,7 +2054,7 @@ func newSetModelVersionTag() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setModelVersionTagJson.Unmarshal(&setModelVersionTagReq) @@ -2140,7 +2141,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -2236,7 +2237,7 @@ func newTestRegistryWebhook() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := testRegistryWebhookJson.Unmarshal(&testRegistryWebhookReq) @@ -2335,7 +2336,7 @@ func newTransitionStage() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := transitionStageJson.Unmarshal(&transitionStageReq) @@ -2432,7 +2433,7 @@ func newUpdateComment() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateCommentJson.Unmarshal(&updateCommentReq) @@ -2518,7 +2519,7 @@ func newUpdateModel() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateModelJson.Unmarshal(&updateModelReq) @@ -2602,7 +2603,7 @@ func newUpdateModelVersion() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateModelVersionJson.Unmarshal(&updateModelVersionReq) @@ -2682,7 +2683,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) @@ -2769,7 +2770,7 @@ func newUpdateWebhook() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateWebhookJson.Unmarshal(&updateWebhookReq) diff --git a/cmd/workspace/model-versions/model-versions.go b/cmd/workspace/model-versions/model-versions.go index 439e5f657..dec402414 100755 --- a/cmd/workspace/model-versions/model-versions.go +++ b/cmd/workspace/model-versions/model-versions.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -90,7 +91,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.FullName = args[0] _, err = fmt.Sscan(args[1], &deleteReq.Version) @@ -161,7 +162,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.FullName = args[0] _, err = fmt.Sscan(args[1], &getReq.Version) @@ -231,7 +232,7 @@ func newGetByAlias() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getByAliasReq.FullName = args[0] getByAliasReq.Alias = args[1] @@ -307,7 +308,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listReq.FullName = args[0] @@ -374,7 +375,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/notification-destinations/notification-destinations.go b/cmd/workspace/notification-destinations/notification-destinations.go index b06652c71..11970cda1 100755 --- a/cmd/workspace/notification-destinations/notification-destinations.go +++ b/cmd/workspace/notification-destinations/notification-destinations.go @@ -5,6 +5,7 @@ package notification_destinations import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -81,7 +82,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -147,7 +148,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Id = args[0] @@ -202,7 +203,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Id = args[0] @@ -260,7 +261,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.NotificationDestinations.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -319,7 +320,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/online-tables/online-tables.go b/cmd/workspace/online-tables/online-tables.go index f050017ec..0fa347b84 100755 --- a/cmd/workspace/online-tables/online-tables.go +++ b/cmd/workspace/online-tables/online-tables.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -86,7 +87,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.Table) @@ -170,7 +171,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Name = args[0] @@ -228,7 +229,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Name = args[0] diff --git a/cmd/workspace/permission-migration/permission-migration.go b/cmd/workspace/permission-migration/permission-migration.go index 15ff1b751..b07890807 100755 --- a/cmd/workspace/permission-migration/permission-migration.go +++ b/cmd/workspace/permission-migration/permission-migration.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" @@ -89,7 +90,7 @@ func newMigratePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := migratePermissionsJson.Unmarshal(&migratePermissionsReq) diff --git a/cmd/workspace/permissions/permissions.go b/cmd/workspace/permissions/permissions.go index ca570351e..62881a4bf 100755 --- a/cmd/workspace/permissions/permissions.go +++ b/cmd/workspace/permissions/permissions.go @@ -5,6 +5,7 @@ package permissions import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" @@ -133,7 +134,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.RequestObjectType = args[0] getReq.RequestObjectId = args[1] @@ -193,7 +194,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPermissionLevelsReq.RequestObjectType = args[0] getPermissionLevelsReq.RequestObjectId = args[1] @@ -263,7 +264,7 @@ func newSet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setJson.Unmarshal(&setReq) @@ -344,7 +345,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/pipelines/pipelines.go b/cmd/workspace/pipelines/pipelines.go index e94d4c5a8..be4bb5a01 100755 --- a/cmd/workspace/pipelines/pipelines.go +++ b/cmd/workspace/pipelines/pipelines.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/spf13/cobra" @@ -95,7 +96,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -158,7 +159,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -228,7 +229,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -298,7 +299,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -369,7 +370,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -445,7 +446,7 @@ func newGetUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getUpdateReq.PipelineId = args[0] getUpdateReq.UpdateId = args[1] @@ -501,7 +502,7 @@ func newListPipelineEvents() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -575,7 +576,7 @@ func newListPipelines() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Pipelines.ListPipelines(ctx, listPipelinesReq) return cmdio.RenderIterator(ctx, response) @@ -627,7 +628,7 @@ func newListUpdates() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -703,7 +704,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -798,7 +799,7 @@ func newStartUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := startUpdateJson.Unmarshal(&startUpdateReq) @@ -883,7 +884,7 @@ func newStop() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -995,7 +996,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -1082,7 +1083,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/policy-compliance-for-clusters/policy-compliance-for-clusters.go b/cmd/workspace/policy-compliance-for-clusters/policy-compliance-for-clusters.go index d128d80b8..de27b1ec6 100755 --- a/cmd/workspace/policy-compliance-for-clusters/policy-compliance-for-clusters.go +++ b/cmd/workspace/policy-compliance-for-clusters/policy-compliance-for-clusters.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" @@ -107,7 +108,7 @@ func newEnforceCompliance() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := enforceComplianceJson.Unmarshal(&enforceComplianceReq) @@ -180,7 +181,7 @@ func newGetCompliance() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getComplianceReq.ClusterId = args[0] @@ -243,7 +244,7 @@ func newListCompliance() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listComplianceReq.PolicyId = args[0] diff --git a/cmd/workspace/policy-compliance-for-jobs/policy-compliance-for-jobs.go b/cmd/workspace/policy-compliance-for-jobs/policy-compliance-for-jobs.go index 384dab2c9..8ff346ffc 100755 --- a/cmd/workspace/policy-compliance-for-jobs/policy-compliance-for-jobs.go +++ b/cmd/workspace/policy-compliance-for-jobs/policy-compliance-for-jobs.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/spf13/cobra" @@ -101,7 +102,7 @@ func newEnforceCompliance() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := enforceComplianceJson.Unmarshal(&enforceComplianceReq) @@ -178,7 +179,7 @@ func newGetCompliance() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) _, err = fmt.Sscan(args[0], &getComplianceReq.JobId) if err != nil { @@ -245,7 +246,7 @@ func newListCompliance() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listComplianceReq.PolicyId = args[0] diff --git a/cmd/workspace/policy-families/policy-families.go b/cmd/workspace/policy-families/policy-families.go index cac23405b..d9cf8083e 100755 --- a/cmd/workspace/policy-families/policy-families.go +++ b/cmd/workspace/policy-families/policy-families.go @@ -5,6 +5,7 @@ package policy_families import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/service/compute" "github.com/spf13/cobra" ) @@ -82,7 +83,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.PolicyFamilyId = args[0] @@ -141,7 +142,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.PolicyFamilies.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) diff --git a/cmd/workspace/provider-exchange-filters/provider-exchange-filters.go b/cmd/workspace/provider-exchange-filters/provider-exchange-filters.go index fea836d20..04511a8ac 100755 --- a/cmd/workspace/provider-exchange-filters/provider-exchange-filters.go +++ b/cmd/workspace/provider-exchange-filters/provider-exchange-filters.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" @@ -70,7 +71,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -133,7 +134,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -208,7 +209,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listReq.ExchangeId = args[0] @@ -262,7 +263,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/provider-exchanges/provider-exchanges.go b/cmd/workspace/provider-exchanges/provider-exchanges.go index a96f0673e..f9d34ae3d 100755 --- a/cmd/workspace/provider-exchanges/provider-exchanges.go +++ b/cmd/workspace/provider-exchanges/provider-exchanges.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" @@ -88,7 +89,7 @@ func newAddListingToExchange() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := addListingToExchangeJson.Unmarshal(&addListingToExchangeReq) @@ -157,7 +158,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -225,7 +226,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Id = args[0] @@ -280,7 +281,7 @@ func newDeleteListingFromExchange() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteListingFromExchangeReq.Id = args[0] @@ -335,7 +336,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Id = args[0] @@ -393,7 +394,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ProviderExchanges.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -446,7 +447,7 @@ func newListExchangesForListing() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listExchangesForListingReq.ListingId = args[0] @@ -501,7 +502,7 @@ func newListListingsForExchange() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listListingsForExchangeReq.ExchangeId = args[0] @@ -555,7 +556,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/provider-files/provider-files.go b/cmd/workspace/provider-files/provider-files.go index 392ed2890..2bd6008ce 100755 --- a/cmd/workspace/provider-files/provider-files.go +++ b/cmd/workspace/provider-files/provider-files.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" @@ -74,7 +75,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -137,7 +138,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -204,7 +205,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -276,7 +277,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := listJson.Unmarshal(&listReq) diff --git a/cmd/workspace/provider-listings/provider-listings.go b/cmd/workspace/provider-listings/provider-listings.go index 4c7c6c563..5623467b5 100755 --- a/cmd/workspace/provider-listings/provider-listings.go +++ b/cmd/workspace/provider-listings/provider-listings.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" @@ -72,7 +73,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -135,7 +136,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -202,7 +203,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -277,7 +278,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ProviderListings.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -329,7 +330,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/provider-personalization-requests/provider-personalization-requests.go b/cmd/workspace/provider-personalization-requests/provider-personalization-requests.go index 48c444f1f..b1edc9de6 100755 --- a/cmd/workspace/provider-personalization-requests/provider-personalization-requests.go +++ b/cmd/workspace/provider-personalization-requests/provider-personalization-requests.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" @@ -76,7 +77,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ProviderPersonalizationRequests.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -139,7 +140,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go b/cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go index a8d151a20..bfcbb1b51 100755 --- a/cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go +++ b/cmd/workspace/provider-provider-analytics-dashboards/provider-provider-analytics-dashboards.go @@ -5,6 +5,7 @@ package provider_provider_analytics_dashboards import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" @@ -62,7 +63,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.ProviderProviderAnalyticsDashboards.Create(ctx) if err != nil { return err @@ -104,7 +105,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.ProviderProviderAnalyticsDashboards.Get(ctx) if err != nil { return err @@ -146,7 +147,7 @@ func newGetLatestVersion() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.ProviderProviderAnalyticsDashboards.GetLatestVersion(ctx) if err != nil { return err @@ -205,7 +206,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/provider-providers/provider-providers.go b/cmd/workspace/provider-providers/provider-providers.go index 3c9c024e8..f2fc916dd 100755 --- a/cmd/workspace/provider-providers/provider-providers.go +++ b/cmd/workspace/provider-providers/provider-providers.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/marketplace" "github.com/spf13/cobra" @@ -71,7 +72,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -134,7 +135,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -201,7 +202,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -276,7 +277,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ProviderProviders.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -328,7 +329,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/providers/providers.go b/cmd/workspace/providers/providers.go index 4edef6a0e..7136cc298 100755 --- a/cmd/workspace/providers/providers.go +++ b/cmd/workspace/providers/providers.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sharing" "github.com/spf13/cobra" @@ -95,7 +96,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -169,7 +170,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -241,7 +242,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -320,7 +321,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Providers.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -380,7 +381,7 @@ func newListProviderShareAssets() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listProviderShareAssetsReq.ProviderName = args[0] listProviderShareAssetsReq.ShareName = args[1] @@ -439,7 +440,7 @@ func newListShares() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -516,7 +517,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/quality-monitors/quality-monitors.go b/cmd/workspace/quality-monitors/quality-monitors.go index 58075aa54..f2079b069 100755 --- a/cmd/workspace/quality-monitors/quality-monitors.go +++ b/cmd/workspace/quality-monitors/quality-monitors.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -101,7 +102,7 @@ func newCancelRefresh() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) cancelRefreshReq.TableName = args[0] cancelRefreshReq.RefreshId = args[1] @@ -193,7 +194,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -281,7 +282,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.TableName = args[0] @@ -350,7 +351,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.TableName = args[0] @@ -418,7 +419,7 @@ func newGetRefresh() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getRefreshReq.TableName = args[0] getRefreshReq.RefreshId = args[1] @@ -487,7 +488,7 @@ func newListRefreshes() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listRefreshesReq.TableName = args[0] @@ -562,7 +563,7 @@ func newRegenerateDashboard() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := regenerateDashboardJson.Unmarshal(®enerateDashboardReq) @@ -642,7 +643,7 @@ func newRunRefresh() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) runRefreshReq.TableName = args[0] @@ -733,7 +734,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/queries-legacy/queries-legacy.go b/cmd/workspace/queries-legacy/queries-legacy.go index e35e1828b..a90c9632d 100755 --- a/cmd/workspace/queries-legacy/queries-legacy.go +++ b/cmd/workspace/queries-legacy/queries-legacy.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" @@ -93,7 +94,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -163,7 +164,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -236,7 +237,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -322,7 +323,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.QueriesLegacy.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -373,7 +374,7 @@ func newRestore() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -457,7 +458,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/queries/queries.go b/cmd/workspace/queries/queries.go index bf74bb3f5..84708edc0 100755 --- a/cmd/workspace/queries/queries.go +++ b/cmd/workspace/queries/queries.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" @@ -82,7 +83,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -146,7 +147,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -213,7 +214,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -290,7 +291,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Queries.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -341,7 +342,7 @@ func newListVisualizations() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -435,7 +436,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/query-execution/query-execution.go b/cmd/workspace/query-execution/query-execution.go index ebbb90f89..2e57564eb 100755 --- a/cmd/workspace/query-execution/query-execution.go +++ b/cmd/workspace/query-execution/query-execution.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/dashboards" "github.com/spf13/cobra" @@ -75,7 +76,7 @@ func newCancelPublishedQueryExecution() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) cancelPublishedQueryExecutionReq.DashboardName = args[0] cancelPublishedQueryExecutionReq.DashboardRevisionId = args[1] @@ -146,7 +147,7 @@ func newExecutePublishedDashboardQuery() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := executePublishedDashboardQueryJson.Unmarshal(&executePublishedDashboardQueryReq) @@ -218,7 +219,7 @@ func newPollPublishedQueryStatus() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) pollPublishedQueryStatusReq.DashboardName = args[0] pollPublishedQueryStatusReq.DashboardRevisionId = args[1] diff --git a/cmd/workspace/query-history/query-history.go b/cmd/workspace/query-history/query-history.go index bfa013f28..19ee002f4 100755 --- a/cmd/workspace/query-history/query-history.go +++ b/cmd/workspace/query-history/query-history.go @@ -5,6 +5,7 @@ package query_history import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" ) @@ -78,7 +79,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.QueryHistory.List(ctx, listReq) if err != nil { diff --git a/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go b/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go index f48acff1e..57a08ec68 100755 --- a/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go +++ b/cmd/workspace/query-visualizations-legacy/query-visualizations-legacy.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" @@ -84,7 +85,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -160,7 +161,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Id = args[0] @@ -225,7 +226,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/query-visualizations/query-visualizations.go b/cmd/workspace/query-visualizations/query-visualizations.go index 2d50229ba..d876f2997 100755 --- a/cmd/workspace/query-visualizations/query-visualizations.go +++ b/cmd/workspace/query-visualizations/query-visualizations.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" @@ -81,7 +82,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -147,7 +148,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Id = args[0] @@ -227,7 +228,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/recipient-activation/recipient-activation.go b/cmd/workspace/recipient-activation/recipient-activation.go index 457fa9042..33e911813 100755 --- a/cmd/workspace/recipient-activation/recipient-activation.go +++ b/cmd/workspace/recipient-activation/recipient-activation.go @@ -5,6 +5,7 @@ package recipient_activation import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/service/sharing" "github.com/spf13/cobra" ) @@ -80,7 +81,7 @@ func newGetActivationUrlInfo() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getActivationUrlInfoReq.ActivationUrl = args[0] @@ -139,7 +140,7 @@ func newRetrieveToken() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) retrieveTokenReq.ActivationUrl = args[0] diff --git a/cmd/workspace/recipients/recipients.go b/cmd/workspace/recipients/recipients.go index 6d6ce42f1..06b045780 100755 --- a/cmd/workspace/recipients/recipients.go +++ b/cmd/workspace/recipients/recipients.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sharing" "github.com/spf13/cobra" @@ -115,7 +116,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -194,7 +195,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Name = args[0] @@ -254,7 +255,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Name = args[0] @@ -316,7 +317,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Recipients.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -383,7 +384,7 @@ func newRotateToken() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := rotateTokenJson.Unmarshal(&rotateTokenReq) @@ -463,7 +464,7 @@ func newSharePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) sharePermissionsReq.Name = args[0] @@ -532,7 +533,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/redash-config/redash-config.go b/cmd/workspace/redash-config/redash-config.go index 1a0f37759..6a057236e 100755 --- a/cmd/workspace/redash-config/redash-config.go +++ b/cmd/workspace/redash-config/redash-config.go @@ -5,6 +5,7 @@ package redash_config import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/spf13/cobra" ) @@ -57,7 +58,7 @@ func newGetConfig() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.RedashConfig.GetConfig(ctx) if err != nil { return err diff --git a/cmd/workspace/registered-models/registered-models.go b/cmd/workspace/registered-models/registered-models.go index 63f307a32..94f9eb08e 100755 --- a/cmd/workspace/registered-models/registered-models.go +++ b/cmd/workspace/registered-models/registered-models.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -132,7 +133,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -211,7 +212,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -292,7 +293,7 @@ func newDeleteAlias() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteAliasReq.FullName = args[0] deleteAliasReq.Alias = args[1] @@ -354,7 +355,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -443,7 +444,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.RegisteredModels.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -512,7 +513,7 @@ func newSetAlias() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setAliasJson.Unmarshal(&setAliasReq) @@ -598,7 +599,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/repos/overrides.go b/cmd/workspace/repos/overrides.go index 561921623..bd9bef98d 100644 --- a/cmd/workspace/repos/overrides.go +++ b/cmd/workspace/repos/overrides.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go" @@ -35,7 +36,7 @@ func createOverride(createCmd *cobra.Command, createReq *workspace.CreateRepoReq createJson := createCmd.Flag("json").Value.(*flags.JsonFlag) createCmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(createReq) if diags.HasError() { @@ -71,7 +72,7 @@ func deleteOverride(deleteCmd *cobra.Command, deleteReq *workspace.DeleteRepoReq deleteCmd.Use = "delete REPO_ID_OR_PATH" deleteCmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.RepoId, err = repoArgumentToRepoID(ctx, w, args) if err != nil { @@ -89,7 +90,7 @@ func getOverride(getCmd *cobra.Command, getReq *workspace.GetRepoRequest) { getCmd.Use = "get REPO_ID_OR_PATH" getCmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.RepoId, err = repoArgumentToRepoID(ctx, w, args) if err != nil { return err @@ -110,7 +111,7 @@ func updateOverride(updateCmd *cobra.Command, updateReq *workspace.UpdateRepoReq updateCmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() var diags diag.Diagnostics - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags = updateJson.Unmarshal(&updateReq) if diags.HasError() { diff --git a/cmd/workspace/repos/repos.go b/cmd/workspace/repos/repos.go index 799472650..e6a0f6084 100755 --- a/cmd/workspace/repos/repos.go +++ b/cmd/workspace/repos/repos.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/workspace" "github.com/spf13/cobra" @@ -108,7 +109,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -178,7 +179,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -251,7 +252,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -324,7 +325,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -395,7 +396,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -471,7 +472,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Repos.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -525,7 +526,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -614,7 +615,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -704,7 +705,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/resource-quotas/resource-quotas.go b/cmd/workspace/resource-quotas/resource-quotas.go index 9a0c30687..12d2e0605 100755 --- a/cmd/workspace/resource-quotas/resource-quotas.go +++ b/cmd/workspace/resource-quotas/resource-quotas.go @@ -5,6 +5,7 @@ package resource_quotas import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" ) @@ -85,7 +86,7 @@ func newGetQuota() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getQuotaReq.ParentSecurableType = args[0] getQuotaReq.ParentFullName = args[1] @@ -147,7 +148,7 @@ func newListQuotas() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ResourceQuotas.ListQuotas(ctx, listQuotasReq) return cmdio.RenderIterator(ctx, response) diff --git a/cmd/workspace/restrict-workspace-admins/restrict-workspace-admins.go b/cmd/workspace/restrict-workspace-admins/restrict-workspace-admins.go index 5d0fba923..6bd5a9dfb 100755 --- a/cmd/workspace/restrict-workspace-admins/restrict-workspace-admins.go +++ b/cmd/workspace/restrict-workspace-admins/restrict-workspace-admins.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -85,7 +86,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.RestrictWorkspaceAdmins().Delete(ctx, deleteReq) if err != nil { @@ -140,7 +141,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Settings.RestrictWorkspaceAdmins().Get(ctx, getReq) if err != nil { @@ -194,7 +195,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/schemas/schemas.go b/cmd/workspace/schemas/schemas.go index 3ce573bad..1b9bee4ce 100755 --- a/cmd/workspace/schemas/schemas.go +++ b/cmd/workspace/schemas/schemas.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -97,7 +98,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -170,7 +171,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -244,7 +245,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -327,7 +328,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listReq.CatalogName = args[0] @@ -389,7 +390,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/secrets/put_secret.go b/cmd/workspace/secrets/put_secret.go index b446524f7..d21d4bdd1 100644 --- a/cmd/workspace/secrets/put_secret.go +++ b/cmd/workspace/secrets/put_secret.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/workspace" @@ -62,7 +63,7 @@ func newPutSecret() *cobra.Command { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() var diags diag.Diagnostics - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) bytesValueChanged := cmd.Flags().Changed("bytes-value") stringValueChanged := cmd.Flags().Changed("string-value") diff --git a/cmd/workspace/secrets/secrets.go b/cmd/workspace/secrets/secrets.go index e9547b621..55ca794e5 100755 --- a/cmd/workspace/secrets/secrets.go +++ b/cmd/workspace/secrets/secrets.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/workspace" "github.com/spf13/cobra" @@ -107,7 +108,7 @@ func newCreateScope() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createScopeJson.Unmarshal(&createScopeReq) @@ -194,7 +195,7 @@ func newDeleteAcl() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteAclJson.Unmarshal(&deleteAclReq) @@ -282,7 +283,7 @@ func newDeleteScope() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteScopeJson.Unmarshal(&deleteScopeReq) @@ -369,7 +370,7 @@ func newDeleteSecret() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteSecretJson.Unmarshal(&deleteSecretReq) @@ -450,7 +451,7 @@ func newGetAcl() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getAclReq.Scope = args[0] getAclReq.Principal = args[1] @@ -521,7 +522,7 @@ func newGetSecret() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getSecretReq.Scope = args[0] getSecretReq.Key = args[1] @@ -585,7 +586,7 @@ func newListAcls() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listAclsReq.Scope = args[0] @@ -630,7 +631,7 @@ func newListScopes() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Secrets.ListScopes(ctx) return cmdio.RenderIterator(ctx, response) } @@ -689,7 +690,7 @@ func newListSecrets() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listSecretsReq.Scope = args[0] @@ -780,7 +781,7 @@ func newPutAcl() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := putAclJson.Unmarshal(&putAclReq) diff --git a/cmd/workspace/service-principals/service-principals.go b/cmd/workspace/service-principals/service-principals.go index 317779f30..b4c899659 100755 --- a/cmd/workspace/service-principals/service-principals.go +++ b/cmd/workspace/service-principals/service-principals.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" @@ -92,7 +93,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -156,7 +157,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -227,7 +228,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -307,7 +308,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ServicePrincipals.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -361,7 +362,7 @@ func newPatch() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -457,7 +458,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/serving-endpoints/serving-endpoints.go b/cmd/workspace/serving-endpoints/serving-endpoints.go index 645111646..9384b9e4f 100755 --- a/cmd/workspace/serving-endpoints/serving-endpoints.go +++ b/cmd/workspace/serving-endpoints/serving-endpoints.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/serving" "github.com/spf13/cobra" @@ -23,7 +24,7 @@ func New() *cobra.Command { Short: `The Serving Endpoints API allows you to create, update, and delete model serving endpoints.`, Long: `The Serving Endpoints API allows you to create, update, and delete model serving endpoints. - + You can use a serving endpoint to serve models from the Databricks Model Registry or from Unity Catalog. Endpoints expose the underlying models as scalable REST API endpoints using serverless compute. This means the endpoints @@ -87,7 +88,7 @@ func newBuildLogs() *cobra.Command { cmd.Use = "build-logs NAME SERVED_MODEL_NAME" cmd.Short = `Get build logs for a served model.` cmd.Long = `Get build logs for a served model. - + Retrieves the build logs associated with the provided served model. Arguments: @@ -106,7 +107,7 @@ func newBuildLogs() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) buildLogsReq.Name = args[0] buildLogsReq.ServedModelName = args[1] @@ -185,7 +186,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -265,7 +266,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Name = args[0] @@ -307,7 +308,7 @@ func newExportMetrics() *cobra.Command { cmd.Use = "export-metrics NAME" cmd.Short = `Get metrics of a serving endpoint.` cmd.Long = `Get metrics of a serving endpoint. - + Retrieves the metrics associated with the provided serving endpoint in either Prometheus or OpenMetrics exposition format. @@ -325,7 +326,7 @@ func newExportMetrics() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) exportMetricsReq.Name = args[0] @@ -368,7 +369,7 @@ func newGet() *cobra.Command { cmd.Use = "get NAME" cmd.Short = `Get a single serving endpoint.` cmd.Long = `Get a single serving endpoint. - + Retrieves the details for a single serving endpoint. Arguments: @@ -384,7 +385,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Name = args[0] @@ -426,7 +427,7 @@ func newGetOpenApi() *cobra.Command { cmd.Use = "get-open-api NAME" cmd.Short = `Get the schema for a serving endpoint.` cmd.Long = `Get the schema for a serving endpoint. - + Get the query schema of the serving endpoint in OpenAPI format. The schema contains information for the supported paths, input and output format and datatypes. @@ -445,7 +446,7 @@ func newGetOpenApi() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getOpenApiReq.Name = args[0] @@ -488,7 +489,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.Use = "get-permission-levels SERVING_ENDPOINT_ID" cmd.Short = `Get serving endpoint permission levels.` cmd.Long = `Get serving endpoint permission levels. - + Gets the permission levels that a user can have on an object. Arguments: @@ -504,7 +505,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPermissionLevelsReq.ServingEndpointId = args[0] @@ -546,7 +547,7 @@ func newGetPermissions() *cobra.Command { cmd.Use = "get-permissions SERVING_ENDPOINT_ID" cmd.Short = `Get serving endpoint permissions.` cmd.Long = `Get serving endpoint permissions. - + Gets the permissions of a serving endpoint. Serving endpoints can inherit permissions from their root object. @@ -563,7 +564,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPermissionsReq.ServingEndpointId = args[0] @@ -629,7 +630,7 @@ func newHttpRequest() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) httpRequestReq.ConnectionName = args[0] _, err = fmt.Sscan(args[1], &httpRequestReq.Method) @@ -678,7 +679,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.ServingEndpoints.List(ctx) return cmdio.RenderIterator(ctx, response) } @@ -714,7 +715,7 @@ func newLogs() *cobra.Command { cmd.Use = "logs NAME SERVED_MODEL_NAME" cmd.Short = `Get the latest logs for a served model.` cmd.Long = `Get the latest logs for a served model. - + Retrieves the service logs associated with the provided served model. Arguments: @@ -733,7 +734,7 @@ func newLogs() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) logsReq.Name = args[0] logsReq.ServedModelName = args[1] @@ -781,7 +782,7 @@ func newPatch() *cobra.Command { cmd.Use = "patch NAME" cmd.Short = `Update tags of a serving endpoint.` cmd.Long = `Update tags of a serving endpoint. - + Used to batch add and delete tags from a serving endpoint with a single API call. @@ -799,7 +800,7 @@ func newPatch() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -857,7 +858,7 @@ func newPut() *cobra.Command { cmd.Use = "put NAME" cmd.Short = `Update rate limits of a serving endpoint.` cmd.Long = `Update rate limits of a serving endpoint. - + Used to update the rate limits of a serving endpoint. NOTE: Only foundation model endpoints are currently supported. For external models, use AI Gateway to manage rate limits. @@ -876,7 +877,7 @@ func newPut() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := putJson.Unmarshal(&putReq) @@ -937,7 +938,7 @@ func newPutAiGateway() *cobra.Command { cmd.Use = "put-ai-gateway NAME" cmd.Short = `Update AI Gateway of a serving endpoint.` cmd.Long = `Update AI Gateway of a serving endpoint. - + Used to update the AI Gateway of a serving endpoint. NOTE: Only external model and provisioned throughput endpoints are currently supported. @@ -955,7 +956,7 @@ func newPutAiGateway() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := putAiGatewayJson.Unmarshal(&putAiGatewayReq) @@ -1039,7 +1040,7 @@ func newQuery() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := queryJson.Unmarshal(&queryReq) @@ -1097,7 +1098,7 @@ func newSetPermissions() *cobra.Command { cmd.Use = "set-permissions SERVING_ENDPOINT_ID" cmd.Short = `Set serving endpoint permissions.` cmd.Long = `Set serving endpoint permissions. - + Sets permissions on an object, replacing existing permissions if they exist. Deletes all direct permissions if none are specified. Objects can inherit permissions from their root object. @@ -1115,7 +1116,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -1181,7 +1182,7 @@ func newUpdateConfig() *cobra.Command { cmd.Use = "update-config NAME" cmd.Short = `Update config of a serving endpoint.` cmd.Long = `Update config of a serving endpoint. - + Updates any combination of the serving endpoint's served entities, the compute configuration of those served entities, and the endpoint's traffic config. An endpoint that already has an update in progress can not be updated until the @@ -1200,7 +1201,7 @@ func newUpdateConfig() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateConfigJson.Unmarshal(&updateConfigReq) @@ -1271,7 +1272,7 @@ func newUpdatePermissions() *cobra.Command { cmd.Use = "update-permissions SERVING_ENDPOINT_ID" cmd.Short = `Update serving endpoint permissions.` cmd.Long = `Update serving endpoint permissions. - + Updates the permissions on a serving endpoint. Serving endpoints can inherit permissions from their root object. @@ -1288,7 +1289,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/shares/shares.go b/cmd/workspace/shares/shares.go index 59167224b..937374ba0 100755 --- a/cmd/workspace/shares/shares.go +++ b/cmd/workspace/shares/shares.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sharing" "github.com/spf13/cobra" @@ -97,7 +98,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -170,7 +171,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.Name = args[0] @@ -231,7 +232,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Name = args[0] @@ -291,7 +292,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Shares.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -348,7 +349,7 @@ func newSharePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) sharePermissionsReq.Name = args[0] @@ -430,7 +431,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -508,7 +509,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/storage-credentials/storage-credentials.go b/cmd/workspace/storage-credentials/storage-credentials.go index 4dc028065..2b02d03ae 100755 --- a/cmd/workspace/storage-credentials/storage-credentials.go +++ b/cmd/workspace/storage-credentials/storage-credentials.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -108,7 +109,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -178,7 +179,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -255,7 +256,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Name = args[0] @@ -317,7 +318,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.StorageCredentials.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -380,7 +381,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -487,7 +488,7 @@ func newValidate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := validateJson.Unmarshal(&validateReq) diff --git a/cmd/workspace/system-schemas/system-schemas.go b/cmd/workspace/system-schemas/system-schemas.go index 292afbe84..5d0e6e3c7 100755 --- a/cmd/workspace/system-schemas/system-schemas.go +++ b/cmd/workspace/system-schemas/system-schemas.go @@ -5,6 +5,7 @@ package system_schemas import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" ) @@ -76,7 +77,7 @@ func newDisable() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) disableReq.MetastoreId = args[0] disableReq.SchemaName = args[1] @@ -137,7 +138,7 @@ func newEnable() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) enableReq.MetastoreId = args[0] enableReq.SchemaName = args[1] @@ -200,7 +201,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listReq.MetastoreId = args[0] diff --git a/cmd/workspace/table-constraints/table-constraints.go b/cmd/workspace/table-constraints/table-constraints.go index 4ac7cb9fb..04d738677 100755 --- a/cmd/workspace/table-constraints/table-constraints.go +++ b/cmd/workspace/table-constraints/table-constraints.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -89,7 +90,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -172,7 +173,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteReq.FullName = args[0] deleteReq.ConstraintName = args[1] diff --git a/cmd/workspace/tables/tables.go b/cmd/workspace/tables/tables.go index 1ef247b6d..d251360ad 100755 --- a/cmd/workspace/tables/tables.go +++ b/cmd/workspace/tables/tables.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -85,7 +86,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -162,7 +163,7 @@ func newExists() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -242,7 +243,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -332,7 +333,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listReq.CatalogName = args[0] listReq.SchemaName = args[1] @@ -399,7 +400,7 @@ func newListSummaries() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -477,7 +478,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/temporary-table-credentials/temporary-table-credentials.go b/cmd/workspace/temporary-table-credentials/temporary-table-credentials.go index 210a59f8e..71b27c5bd 100755 --- a/cmd/workspace/temporary-table-credentials/temporary-table-credentials.go +++ b/cmd/workspace/temporary-table-credentials/temporary-table-credentials.go @@ -5,6 +5,7 @@ package temporary_table_credentials import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -91,7 +92,7 @@ func newGenerateTemporaryTableCredentials() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := generateTemporaryTableCredentialsJson.Unmarshal(&generateTemporaryTableCredentialsReq) diff --git a/cmd/workspace/token-management/token-management.go b/cmd/workspace/token-management/token-management.go index fcc70c126..2859e410a 100755 --- a/cmd/workspace/token-management/token-management.go +++ b/cmd/workspace/token-management/token-management.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -93,7 +94,7 @@ func newCreateOboToken() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createOboTokenJson.Unmarshal(&createOboTokenReq) @@ -176,7 +177,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -246,7 +247,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -308,7 +309,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.TokenManagement.GetPermissionLevels(ctx) if err != nil { return err @@ -351,7 +352,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.TokenManagement.GetPermissions(ctx) if err != nil { return err @@ -406,7 +407,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.TokenManagement.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -462,7 +463,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -533,7 +534,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/tokens/tokens.go b/cmd/workspace/tokens/tokens.go index 5c9b4994d..b525e2ac4 100755 --- a/cmd/workspace/tokens/tokens.go +++ b/cmd/workspace/tokens/tokens.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -81,7 +82,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -161,7 +162,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -236,7 +237,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Tokens.List(ctx) return cmdio.RenderIterator(ctx, response) } diff --git a/cmd/workspace/users/users.go b/cmd/workspace/users/users.go index e787446af..a2c6e5246 100755 --- a/cmd/workspace/users/users.go +++ b/cmd/workspace/users/users.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/iam" "github.com/spf13/cobra" @@ -104,7 +105,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -169,7 +170,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -247,7 +248,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -309,7 +310,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Users.GetPermissionLevels(ctx) if err != nil { return err @@ -352,7 +353,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Users.GetPermissions(ctx) if err != nil { return err @@ -412,7 +413,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Users.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -466,7 +467,7 @@ func newPatch() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -556,7 +557,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -635,7 +636,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -724,7 +725,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go b/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go index 0cfb76172..c6d1b4522 100755 --- a/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go +++ b/cmd/workspace/vector-search-endpoints/vector-search-endpoints.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/vectorsearch" "github.com/spf13/cobra" @@ -92,7 +93,7 @@ func newCreateEndpoint() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createEndpointJson.Unmarshal(&createEndpointReq) @@ -187,7 +188,7 @@ func newDeleteEndpoint() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteEndpointReq.EndpointName = args[0] @@ -243,7 +244,7 @@ func newGetEndpoint() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getEndpointReq.EndpointName = args[0] @@ -298,7 +299,7 @@ func newListEndpoints() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.VectorSearchEndpoints.ListEndpoints(ctx, listEndpointsReq) return cmdio.RenderIterator(ctx, response) diff --git a/cmd/workspace/vector-search-indexes/vector-search-indexes.go b/cmd/workspace/vector-search-indexes/vector-search-indexes.go index 74d724a0a..ea1c94f2a 100755 --- a/cmd/workspace/vector-search-indexes/vector-search-indexes.go +++ b/cmd/workspace/vector-search-indexes/vector-search-indexes.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/vectorsearch" "github.com/spf13/cobra" @@ -111,7 +112,7 @@ func newCreateIndex() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createIndexJson.Unmarshal(&createIndexReq) @@ -198,7 +199,7 @@ func newDeleteDataVectorIndex() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteDataVectorIndexJson.Unmarshal(&deleteDataVectorIndexReq) @@ -270,7 +271,7 @@ func newDeleteIndex() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) deleteIndexReq.IndexName = args[0] @@ -328,7 +329,7 @@ func newGetIndex() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getIndexReq.IndexName = args[0] @@ -388,7 +389,7 @@ func newListIndexes() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listIndexesReq.EndpointName = args[0] @@ -453,7 +454,7 @@ func newQueryIndex() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := queryIndexJson.Unmarshal(&queryIndexReq) @@ -531,7 +532,7 @@ func newQueryNextPage() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := queryNextPageJson.Unmarshal(&queryNextPageReq) @@ -607,7 +608,7 @@ func newScanIndex() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := scanIndexJson.Unmarshal(&scanIndexReq) @@ -677,7 +678,7 @@ func newSyncIndex() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) syncIndexReq.IndexName = args[0] @@ -746,7 +747,7 @@ func newUpsertDataVectorIndex() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := upsertDataVectorIndexJson.Unmarshal(&upsertDataVectorIndexReq) diff --git a/cmd/workspace/volumes/volumes.go b/cmd/workspace/volumes/volumes.go index 2f4555736..5021bc423 100755 --- a/cmd/workspace/volumes/volumes.go +++ b/cmd/workspace/volumes/volumes.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -116,7 +117,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -199,7 +200,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -289,7 +290,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listReq.CatalogName = args[0] listReq.SchemaName = args[1] @@ -347,7 +348,7 @@ func newRead() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -430,7 +431,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/workspace/warehouses/warehouses.go b/cmd/workspace/warehouses/warehouses.go index 03925bd70..95bd60e70 100755 --- a/cmd/workspace/warehouses/warehouses.go +++ b/cmd/workspace/warehouses/warehouses.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/sql" "github.com/spf13/cobra" @@ -106,7 +107,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -189,7 +190,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -280,7 +281,7 @@ func newEdit() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := editJson.Unmarshal(&editReq) @@ -386,7 +387,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -456,7 +457,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -527,7 +528,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -590,7 +591,7 @@ func newGetWorkspaceWarehouseConfig() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response, err := w.Warehouses.GetWorkspaceWarehouseConfig(ctx) if err != nil { return err @@ -644,7 +645,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) response := w.Warehouses.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -698,7 +699,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -795,7 +796,7 @@ func newSetWorkspaceWarehouseConfig() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setWorkspaceWarehouseConfigJson.Unmarshal(&setWorkspaceWarehouseConfigReq) @@ -864,7 +865,7 @@ func newStart() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -958,7 +959,7 @@ func newStop() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -1052,7 +1053,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/cmd/workspace/workspace-bindings/workspace-bindings.go b/cmd/workspace/workspace-bindings/workspace-bindings.go index 20f54e1dc..beffa3f14 100755 --- a/cmd/workspace/workspace-bindings/workspace-bindings.go +++ b/cmd/workspace/workspace-bindings/workspace-bindings.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/spf13/cobra" @@ -95,7 +96,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getReq.Name = args[0] @@ -158,7 +159,7 @@ func newGetBindings() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) _, err = fmt.Sscan(args[0], &getBindingsReq.SecurableType) if err != nil { @@ -223,7 +224,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) @@ -300,7 +301,7 @@ func newUpdateBindings() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updateBindingsJson.Unmarshal(&updateBindingsReq) diff --git a/cmd/workspace/workspace-conf/workspace-conf.go b/cmd/workspace/workspace-conf/workspace-conf.go index a17bc1630..d23ef9c6d 100755 --- a/cmd/workspace/workspace-conf/workspace-conf.go +++ b/cmd/workspace/workspace-conf/workspace-conf.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/settings" "github.com/spf13/cobra" @@ -71,7 +72,7 @@ func newGetStatus() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getStatusReq.Keys = args[0] @@ -124,7 +125,7 @@ func newSetStatus() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setStatusJson.Unmarshal(&setStatusReq) diff --git a/cmd/workspace/workspace/export_dir.go b/cmd/workspace/workspace/export_dir.go index febe4c3e1..f356987e8 100644 --- a/cmd/workspace/workspace/export_dir.go +++ b/cmd/workspace/workspace/export_dir.go @@ -10,6 +10,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/notebook" "github.com/databricks/databricks-sdk-go/service/workspace" @@ -99,7 +100,7 @@ func newExportDir() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) opts.sourceDir = args[0] opts.targetDir = args[1] diff --git a/cmd/workspace/workspace/import_dir.go b/cmd/workspace/workspace/import_dir.go index a197d7dd9..9dc5998c1 100644 --- a/cmd/workspace/workspace/import_dir.go +++ b/cmd/workspace/workspace/import_dir.go @@ -11,6 +11,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/filer" "github.com/databricks/cli/libs/notebook" "github.com/spf13/cobra" @@ -124,7 +125,7 @@ Notebooks will have their extensions (one of .scala, .py, .sql, .ipynb, .r) stri cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) opts.sourceDir = args[0] opts.targetDir = args[1] diff --git a/cmd/workspace/workspace/overrides.go b/cmd/workspace/workspace/overrides.go index 53438a764..45a63b4db 100644 --- a/cmd/workspace/workspace/overrides.go +++ b/cmd/workspace/workspace/overrides.go @@ -8,8 +8,8 @@ import ( "os" "strings" - "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/workspace" "github.com/spf13/cobra" @@ -34,7 +34,7 @@ func exportOverride(exportCmd *cobra.Command, exportReq *workspace.ExportRequest exportCmd.RunE = func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) != 1 { return errors.New("expected to have the absolute path of the object or directory") } diff --git a/cmd/workspace/workspace/workspace.go b/cmd/workspace/workspace/workspace.go index 7326f9bea..abac04f14 100755 --- a/cmd/workspace/workspace/workspace.go +++ b/cmd/workspace/workspace/workspace.go @@ -7,6 +7,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go/service/workspace" "github.com/spf13/cobra" @@ -103,7 +104,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := deleteJson.Unmarshal(&deleteReq) @@ -204,7 +205,7 @@ func newExport() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -280,7 +281,7 @@ func newGetPermissionLevels() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPermissionLevelsReq.WorkspaceObjectType = args[0] getPermissionLevelsReq.WorkspaceObjectId = args[1] @@ -341,7 +342,7 @@ func newGetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getPermissionsReq.WorkspaceObjectType = args[0] getPermissionsReq.WorkspaceObjectId = args[1] @@ -401,7 +402,7 @@ func newGetStatus() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) getStatusReq.Path = args[0] @@ -487,7 +488,7 @@ func newImport() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := importJson.Unmarshal(&importReq) @@ -563,7 +564,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) listReq.Path = args[0] @@ -633,7 +634,7 @@ func newMkdirs() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := mkdirsJson.Unmarshal(&mkdirsReq) @@ -728,7 +729,7 @@ func newSetPermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := setPermissionsJson.Unmarshal(&setPermissionsReq) @@ -805,7 +806,7 @@ func newUpdatePermissions() *cobra.Command { cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) if cmd.Flags().Changed("json") { diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq) diff --git a/integration/bundle/helpers_test.go b/integration/bundle/helpers_test.go index b4f9c9086..7b889bdd5 100644 --- a/integration/bundle/helpers_test.go +++ b/integration/bundle/helpers_test.go @@ -11,10 +11,10 @@ import ( "strings" "github.com/databricks/cli/bundle" - "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/internal/testcli" "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/env" "github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/folders" @@ -35,7 +35,7 @@ func initTestTemplateWithBundleRoot(t testutil.TestingT, ctx context.Context, te configFilePath := writeConfigFile(t, config) - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) cmd := cmdio.NewIO(ctx, flags.OutputJSON, strings.NewReader(""), os.Stdout, os.Stderr, "", "bundles") ctx = cmdio.InContext(ctx, cmd) diff --git a/libs/command/context.go b/libs/command/context.go index 8f84f01e6..e87a6f353 100644 --- a/libs/command/context.go +++ b/libs/command/context.go @@ -10,4 +10,8 @@ const ( // configUsedKey is the context key for the auth configuration used to run the // command. configUsedKey = key(2) + + // workspaceClientKey is the context key for an already configured workspace + // client that can be used to make authenticated requests. + workspaceClientKey = key(3) ) diff --git a/libs/command/workspace_client.go b/libs/command/workspace_client.go new file mode 100644 index 000000000..239cab683 --- /dev/null +++ b/libs/command/workspace_client.go @@ -0,0 +1,22 @@ +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) +} diff --git a/libs/command/workspace_client_test.go b/libs/command/workspace_client_test.go new file mode 100644 index 000000000..9f322e862 --- /dev/null +++ b/libs/command/workspace_client_test.go @@ -0,0 +1,39 @@ +package command_test + +import ( + "context" + "testing" + + "github.com/databricks/cli/libs/command" + "github.com/databricks/databricks-sdk-go" + "github.com/databricks/databricks-sdk-go/config" + "github.com/stretchr/testify/assert" +) + +func TestCommandWorkspaceClient(t *testing.T) { + ctx := context.Background() + client := &databricks.WorkspaceClient{ + Config: &config.Config{ + Host: "https://test.com", + }, + } + + // Panic if WorkspaceClient is called before SetWorkspaceClient. + assert.Panics(t, func() { + command.WorkspaceClient(ctx) + }) + + ctx = command.SetWorkspaceClient(context.Background(), client) + + // Multiple calls should return a pointer to the same client. + w := command.WorkspaceClient(ctx) + assert.Same(t, w, command.WorkspaceClient(ctx)) + + // The client should have the correct configuration. + assert.Equal(t, "https://test.com", command.WorkspaceClient(ctx).Config.Host) + + // Second call should panic. + assert.Panics(t, func() { + command.SetWorkspaceClient(ctx, client) + }) +} diff --git a/libs/filer/completer/completer_test.go b/libs/filer/completer/completer_test.go index 865d34c2f..58b012dd8 100644 --- a/libs/filer/completer/completer_test.go +++ b/libs/filer/completer/completer_test.go @@ -5,7 +5,7 @@ import ( "runtime" "testing" - "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/fakefs" "github.com/databricks/cli/libs/filer" "github.com/databricks/databricks-sdk-go/experimental/mocks" @@ -16,7 +16,7 @@ import ( func setupCompleter(t *testing.T, onlyDirs bool) *completer { ctx := context.Background() // Needed to make type context.valueCtx for mockFilerForPath - ctx = root.SetWorkspaceClient(ctx, mocks.NewMockWorkspaceClient(t).WorkspaceClient) + ctx = command.SetWorkspaceClient(ctx, mocks.NewMockWorkspaceClient(t).WorkspaceClient) fakeFiler := filer.NewFakeFiler(map[string]fakefs.FileInfo{ "dir": {FakeName: "root", FakeDir: true}, diff --git a/libs/template/helpers.go b/libs/template/helpers.go index 4550e5fa2..e5b6eda28 100644 --- a/libs/template/helpers.go +++ b/libs/template/helpers.go @@ -10,7 +10,7 @@ import ( "regexp" "text/template" - "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/iamutil" "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/iam" @@ -45,7 +45,7 @@ var ( var bundleUuid = uuid.New().String() func loadHelpers(ctx context.Context) template.FuncMap { - w := root.WorkspaceClient(ctx) + w := command.WorkspaceClient(ctx) return template.FuncMap{ "fail": func(format string, args ...any) (any, error) { return nil, ErrFail{fmt.Sprintf(format, args...)} diff --git a/libs/template/helpers_test.go b/libs/template/helpers_test.go index f8bc1f3da..ca24a896d 100644 --- a/libs/template/helpers_test.go +++ b/libs/template/helpers_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/flags" "github.com/databricks/databricks-sdk-go" workspaceConfig "github.com/databricks/databricks-sdk-go/config" @@ -19,7 +19,7 @@ import ( func TestTemplatePrintStringWithoutProcessing(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/print-without-processing/template", "./testdata/print-without-processing/library") require.NoError(t, err) @@ -35,7 +35,7 @@ func TestTemplatePrintStringWithoutProcessing(t *testing.T) { func TestTemplateBundleUuidFunction(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/bundle-uuid/template", "./testdata/bundle-uuid/library") require.NoError(t, err) @@ -58,7 +58,7 @@ func TestTemplateBundleUuidFunction(t *testing.T) { func TestTemplateRegexpCompileFunction(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/regexp-compile/template", "./testdata/regexp-compile/library") require.NoError(t, err) @@ -75,7 +75,7 @@ func TestTemplateRegexpCompileFunction(t *testing.T) { func TestTemplateRandIntFunction(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/random-int/template", "./testdata/random-int/library") require.NoError(t, err) @@ -92,7 +92,7 @@ func TestTemplateRandIntFunction(t *testing.T) { func TestTemplateUuidFunction(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/uuid/template", "./testdata/uuid/library") require.NoError(t, err) @@ -108,7 +108,7 @@ func TestTemplateUuidFunction(t *testing.T) { func TestTemplateUrlFunction(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/urlparse-function/template", "./testdata/urlparse-function/library") @@ -124,7 +124,7 @@ func TestTemplateUrlFunction(t *testing.T) { func TestTemplateMapPairFunction(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/map-pair/template", "./testdata/map-pair/library") @@ -145,7 +145,7 @@ func TestWorkspaceHost(t *testing.T) { Host: "https://myhost.com", }, } - ctx = root.SetWorkspaceClient(ctx, w) + ctx = command.SetWorkspaceClient(ctx, w) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/workspace-host/template", "./testdata/map-pair/library") @@ -168,7 +168,7 @@ func TestWorkspaceHostNotConfigured(t *testing.T) { w := &databricks.WorkspaceClient{ Config: &workspaceConfig.Config{}, } - ctx = root.SetWorkspaceClient(ctx, w) + ctx = command.SetWorkspaceClient(ctx, w) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/workspace-host/template", "./testdata/map-pair/library") diff --git a/libs/template/renderer_test.go b/libs/template/renderer_test.go index 41439846b..bcc4cd31d 100644 --- a/libs/template/renderer_test.go +++ b/libs/template/renderer_test.go @@ -14,8 +14,8 @@ import ( "github.com/databricks/cli/bundle" bundleConfig "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/phases" - "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/internal/testutil" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/dbr" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/filer" @@ -58,7 +58,7 @@ func assertBuiltinTemplateValid(t *testing.T, template string, settings map[stri cachedUser.UserName = "1d410060-a513-496f-a197-23cc82e5f46d" } cachedIsServicePrincipal = &isServicePrincipal - ctx = root.SetWorkspaceClient(ctx, w) + ctx = command.SetWorkspaceClient(ctx, w) helpers := loadHelpers(ctx) renderer, err := newRenderer(ctx, settings, helpers, templateFS, templateDirName, libraryDirName) @@ -192,7 +192,7 @@ func TestRendererWithAssociatedTemplateInLibrary(t *testing.T) { tmpDir := t.TempDir() ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/email/template", "./testdata/email/library") require.NoError(t, err) @@ -365,7 +365,7 @@ func TestRendererPersistToDisk(t *testing.T) { func TestRendererWalk(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/walk/template", "./testdata/walk/library") @@ -396,7 +396,7 @@ func TestRendererWalk(t *testing.T) { func TestRendererFailFunction(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/fail/template", "./testdata/fail/library") @@ -408,7 +408,7 @@ func TestRendererFailFunction(t *testing.T) { func TestRendererSkipsDirsEagerly(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/skip-dir-eagerly/template", "./testdata/skip-dir-eagerly/library") @@ -424,7 +424,7 @@ func TestRendererSkipsDirsEagerly(t *testing.T) { func TestRendererSkipAllFilesInCurrentDirectory(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) tmpDir := t.TempDir() helpers := loadHelpers(ctx) @@ -449,7 +449,7 @@ func TestRendererSkipAllFilesInCurrentDirectory(t *testing.T) { func TestRendererSkipPatternsAreRelativeToFileDirectory(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/skip-is-relative/template", "./testdata/skip-is-relative/library") @@ -466,7 +466,7 @@ func TestRendererSkipPatternsAreRelativeToFileDirectory(t *testing.T) { func TestRendererSkip(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) tmpDir := t.TempDir() helpers := loadHelpers(ctx) @@ -500,7 +500,7 @@ func TestRendererReadsPermissionsBits(t *testing.T) { t.SkipNow() } ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/executable-bit-read/template", "./testdata/executable-bit-read/library") @@ -588,7 +588,7 @@ func TestRendererNoErrorOnConflictingFileIfSkipped(t *testing.T) { func TestRendererNonTemplatesAreCreatedAsCopyFiles(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) helpers := loadHelpers(ctx) r, err := newRenderer(ctx, nil, helpers, os.DirFS("."), "./testdata/copy-file-walk/template", "./testdata/copy-file-walk/library") @@ -604,7 +604,7 @@ func TestRendererNonTemplatesAreCreatedAsCopyFiles(t *testing.T) { func TestRendererFileTreeRendering(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) tmpDir := t.TempDir() helpers := loadHelpers(ctx) @@ -633,7 +633,7 @@ func TestRendererFileTreeRendering(t *testing.T) { func TestRendererSubTemplateInPath(t *testing.T) { ctx := context.Background() - ctx = root.SetWorkspaceClient(ctx, nil) + ctx = command.SetWorkspaceClient(ctx, nil) // Copy the template directory to a temporary directory where we can safely include a templated file path. // These paths include characters that are forbidden in Go modules, so we can't use the testdata directory. diff --git a/libs/template/writer.go b/libs/template/writer.go index e3d5af583..6e6001dfb 100644 --- a/libs/template/writer.go +++ b/libs/template/writer.go @@ -8,8 +8,8 @@ import ( "path/filepath" "strings" - "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/dbr" "github.com/databricks/cli/libs/filer" ) @@ -54,7 +54,7 @@ func constructOutputFiler(ctx context.Context, outputDir string) (filer.Filer, e // when running the CLI on DBR and initializing a template to the workspace. // if strings.HasPrefix(outputDir, "/Workspace/") && dbr.RunsOnRuntime(ctx) { - return filer.NewWorkspaceFilesExtensionsClient(root.WorkspaceClient(ctx), outputDir) + return filer.NewWorkspaceFilesExtensionsClient(command.WorkspaceClient(ctx), outputDir) } return filer.NewLocalClient(outputDir) diff --git a/libs/template/writer_test.go b/libs/template/writer_test.go index a3e10d4fe..7c5ff2b67 100644 --- a/libs/template/writer_test.go +++ b/libs/template/writer_test.go @@ -5,7 +5,7 @@ import ( "runtime" "testing" - "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/command" "github.com/databricks/cli/libs/dbr" "github.com/databricks/cli/libs/filer" "github.com/databricks/databricks-sdk-go" @@ -32,7 +32,7 @@ func TestDefaultWriterConfigureOnDBR(t *testing.T) { } ctx := dbr.MockRuntime(context.Background(), dbr.Environment{IsDbr: true, Version: "15.4"}) - ctx = root.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{ + ctx = command.SetWorkspaceClient(ctx, &databricks.WorkspaceClient{ Config: &workspaceConfig.Config{Host: "https://myhost.com"}, }) w := &defaultWriter{}