diff --git a/.codegen/service.go.tmpl b/.codegen/service.go.tmpl index 33833dfa1..44763165e 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 := command.AccountClient(ctx){{else}}w := root.WorkspaceClient(ctx){{end}} {{- if .Request }} {{ if $canUseJson }} if cmd.Flags().Changed("json") { diff --git a/cmd/account/access-control/access-control.go b/cmd/account/access-control/access-control.go index 07a7fce9b..6467b6cc3 100755 --- a/cmd/account/access-control/access-control.go +++ b/cmd/account/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" @@ -79,7 +80,7 @@ func newGetAssignableRolesForResource() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getAssignableRolesForResourceReq.Resource = args[0] @@ -147,7 +148,7 @@ func newGetRuleSet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getRuleSetReq.Name = args[0] getRuleSetReq.Etag = args[1] @@ -202,7 +203,7 @@ func newUpdateRuleSet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateRuleSetJson.Unmarshal(&updateRuleSetReq) diff --git a/cmd/account/billable-usage/billable-usage.go b/cmd/account/billable-usage/billable-usage.go index 2a2cca605..e8e10ad96 100755 --- a/cmd/account/billable-usage/billable-usage.go +++ b/cmd/account/billable-usage/billable-usage.go @@ -5,6 +5,7 @@ package billable_usage 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/billing" "github.com/spf13/cobra" ) @@ -85,7 +86,7 @@ func newDownload() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) downloadReq.StartMonth = args[0] downloadReq.EndMonth = args[1] diff --git a/cmd/account/budget-policy/budget-policy.go b/cmd/account/budget-policy/budget-policy.go index 8e338f91f..edea49407 100755 --- a/cmd/account/budget-policy/budget-policy.go +++ b/cmd/account/budget-policy/budget-policy.go @@ -5,6 +5,7 @@ package budget_policy 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/billing" "github.com/spf13/cobra" @@ -77,7 +78,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -146,7 +147,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) deleteReq.PolicyId = args[0] @@ -204,7 +205,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getReq.PolicyId = args[0] @@ -265,7 +266,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.BudgetPolicy.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -327,7 +328,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.Policy) diff --git a/cmd/account/budgets/budgets.go b/cmd/account/budgets/budgets.go index 748dc6994..97ce0155f 100755 --- a/cmd/account/budgets/budgets.go +++ b/cmd/account/budgets/budgets.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/billing" "github.com/spf13/cobra" @@ -75,7 +76,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -147,7 +148,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) deleteReq.BudgetId = args[0] @@ -206,7 +207,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getReq.BudgetId = args[0] @@ -263,7 +264,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.Budgets.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -319,7 +320,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/credentials/credentials.go b/cmd/account/credentials/credentials.go index 4ab70ef00..e7337c6d3 100755 --- a/cmd/account/credentials/credentials.go +++ b/cmd/account/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/provisioning" "github.com/spf13/cobra" @@ -87,7 +88,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -155,7 +156,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -226,7 +227,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -289,7 +290,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Credentials.List(ctx) if err != nil { return err diff --git a/cmd/account/csp-enablement-account/csp-enablement-account.go b/cmd/account/csp-enablement-account/csp-enablement-account.go index 9fb94a616..a3a483a66 100755 --- a/cmd/account/csp-enablement-account/csp-enablement-account.go +++ b/cmd/account/csp-enablement-account/csp-enablement-account.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.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Settings.CspEnablementAccount().Get(ctx, getReq) if err != nil { @@ -126,7 +127,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/custom-app-integration/custom-app-integration.go b/cmd/account/custom-app-integration/custom-app-integration.go index 61cfe0a09..5d968f7f7 100755 --- a/cmd/account/custom-app-integration/custom-app-integration.go +++ b/cmd/account/custom-app-integration/custom-app-integration.go @@ -5,6 +5,7 @@ package custom_app_integration 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/oauth2" "github.com/spf13/cobra" @@ -86,7 +87,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -153,7 +154,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) deleteReq.IntegrationId = args[0] @@ -211,7 +212,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getReq.IntegrationId = args[0] @@ -271,7 +272,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.CustomAppIntegration.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -329,7 +330,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/disable-legacy-features/disable-legacy-features.go b/cmd/account/disable-legacy-features/disable-legacy-features.go index 5e732b87b..f251a9201 100755 --- a/cmd/account/disable-legacy-features/disable-legacy-features.go +++ b/cmd/account/disable-legacy-features/disable-legacy-features.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" @@ -77,7 +78,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Settings.DisableLegacyFeatures().Delete(ctx, deleteReq) if err != nil { @@ -132,7 +133,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Settings.DisableLegacyFeatures().Get(ctx, getReq) if err != nil { @@ -182,7 +183,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/enable-ip-access-lists/enable-ip-access-lists.go b/cmd/account/enable-ip-access-lists/enable-ip-access-lists.go index 24d30c9c6..e724e6197 100755 --- a/cmd/account/enable-ip-access-lists/enable-ip-access-lists.go +++ b/cmd/account/enable-ip-access-lists/enable-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" @@ -74,7 +75,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Settings.EnableIpAccessLists().Delete(ctx, deleteReq) if err != nil { @@ -129,7 +130,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Settings.EnableIpAccessLists().Get(ctx, getReq) if err != nil { @@ -179,7 +180,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/encryption-keys/encryption-keys.go b/cmd/account/encryption-keys/encryption-keys.go index 3f7082cd7..e26f6341c 100755 --- a/cmd/account/encryption-keys/encryption-keys.go +++ b/cmd/account/encryption-keys/encryption-keys.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/provisioning" "github.com/spf13/cobra" @@ -104,7 +105,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -176,7 +177,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) deleteReq.CustomerManagedKeyId = args[0] @@ -248,7 +249,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getReq.CustomerManagedKeyId = args[0] @@ -305,7 +306,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.EncryptionKeys.List(ctx) if err != nil { return err diff --git a/cmd/account/esm-enablement-account/esm-enablement-account.go b/cmd/account/esm-enablement-account/esm-enablement-account.go index 1f820e3a9..becdb48c4 100755 --- a/cmd/account/esm-enablement-account/esm-enablement-account.go +++ b/cmd/account/esm-enablement-account/esm-enablement-account.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.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Settings.EsmEnablementAccount().Get(ctx, getReq) if err != nil { @@ -124,7 +125,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/federation-policy/federation-policy.go b/cmd/account/federation-policy/federation-policy.go index ad45c0405..63d8e0489 100755 --- a/cmd/account/federation-policy/federation-policy.go +++ b/cmd/account/federation-policy/federation-policy.go @@ -5,6 +5,7 @@ package federation_policy 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/oauth2" "github.com/spf13/cobra" @@ -126,7 +127,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.Policy) @@ -193,7 +194,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) deleteReq.PolicyId = args[0] @@ -249,7 +250,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getReq.PolicyId = args[0] @@ -305,7 +306,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.FederationPolicy.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -364,7 +365,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.Policy) diff --git a/cmd/account/groups/groups.go b/cmd/account/groups/groups.go index 7c2e83319..c95c3f737 100755 --- a/cmd/account/groups/groups.go +++ b/cmd/account/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.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -158,7 +159,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -228,7 +229,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -308,7 +309,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.Groups.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -361,7 +362,7 @@ func newPatch() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -455,7 +456,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/ip-access-lists/ip-access-lists.go b/cmd/account/ip-access-lists/ip-access-lists.go index 61fa944ab..44fac7b4f 100755 --- a/cmd/account/ip-access-lists/ip-access-lists.go +++ b/cmd/account/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" @@ -129,7 +130,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -202,7 +203,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -272,7 +273,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -334,7 +335,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.IpAccessLists.List(ctx) return cmdio.RenderIterator(ctx, response) } @@ -414,7 +415,7 @@ func newReplace() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := replaceJson.Unmarshal(&replaceReq) @@ -514,7 +515,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/log-delivery/log-delivery.go b/cmd/account/log-delivery/log-delivery.go index cb083f3ba..bd0ff8e2a 100755 --- a/cmd/account/log-delivery/log-delivery.go +++ b/cmd/account/log-delivery/log-delivery.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/billing" "github.com/spf13/cobra" @@ -159,7 +160,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -224,7 +225,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -301,7 +302,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.LogDelivery.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -372,7 +373,7 @@ func newPatchStatus() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := patchStatusJson.Unmarshal(&patchStatusReq) diff --git a/cmd/account/metastore-assignments/metastore-assignments.go b/cmd/account/metastore-assignments/metastore-assignments.go index 9d2490754..a13bf2124 100755 --- a/cmd/account/metastore-assignments/metastore-assignments.go +++ b/cmd/account/metastore-assignments/metastore-assignments.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.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -158,7 +159,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) _, err = fmt.Sscan(args[0], &deleteReq.WorkspaceId) if err != nil { @@ -223,7 +224,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) _, err = fmt.Sscan(args[0], &getReq.WorkspaceId) if err != nil { @@ -285,7 +286,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) listReq.MetastoreId = args[0] @@ -346,7 +347,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/metastores/metastores.go b/cmd/account/metastores/metastores.go index eb5755782..dd33ee000 100755 --- a/cmd/account/metastores/metastores.go +++ b/cmd/account/metastores/metastores.go @@ -5,6 +5,7 @@ package metastores 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 newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -148,7 +149,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) deleteReq.MetastoreId = args[0] @@ -206,7 +207,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getReq.MetastoreId = args[0] @@ -251,7 +252,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.Metastores.List(ctx) return cmdio.RenderIterator(ctx, response) } @@ -307,7 +308,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/network-connectivity/network-connectivity.go b/cmd/account/network-connectivity/network-connectivity.go index 168de9c1d..f2377a624 100755 --- a/cmd/account/network-connectivity/network-connectivity.go +++ b/cmd/account/network-connectivity/network-connectivity.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 newCreateNetworkConnectivityConfiguration() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createNetworkConnectivityConfigurationJson.Unmarshal(&createNetworkConnectivityConfigurationReq) @@ -190,7 +191,7 @@ func newCreatePrivateEndpointRule() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createPrivateEndpointRuleJson.Unmarshal(&createPrivateEndpointRuleReq) @@ -269,7 +270,7 @@ func newDeleteNetworkConnectivityConfiguration() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) deleteNetworkConnectivityConfigurationReq.NetworkConnectivityConfigId = args[0] @@ -333,7 +334,7 @@ func newDeletePrivateEndpointRule() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) deletePrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0] deletePrivateEndpointRuleReq.PrivateEndpointRuleId = args[1] @@ -392,7 +393,7 @@ func newGetNetworkConnectivityConfiguration() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getNetworkConnectivityConfigurationReq.NetworkConnectivityConfigId = args[0] @@ -451,7 +452,7 @@ func newGetPrivateEndpointRule() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getPrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0] getPrivateEndpointRuleReq.PrivateEndpointRuleId = args[1] @@ -509,7 +510,7 @@ func newListNetworkConnectivityConfigurations() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.NetworkConnectivity.ListNetworkConnectivityConfigurations(ctx, listNetworkConnectivityConfigurationsReq) return cmdio.RenderIterator(ctx, response) @@ -564,7 +565,7 @@ func newListPrivateEndpointRules() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) listPrivateEndpointRulesReq.NetworkConnectivityConfigId = args[0] diff --git a/cmd/account/networks/networks.go b/cmd/account/networks/networks.go index 086d24be8..59d17b78b 100755 --- a/cmd/account/networks/networks.go +++ b/cmd/account/networks/networks.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/provisioning" "github.com/spf13/cobra" @@ -94,7 +95,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -166,7 +167,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -237,7 +238,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -303,7 +304,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Networks.List(ctx) if err != nil { return err diff --git a/cmd/account/o-auth-published-apps/o-auth-published-apps.go b/cmd/account/o-auth-published-apps/o-auth-published-apps.go index f1af17d2e..e25201512 100755 --- a/cmd/account/o-auth-published-apps/o-auth-published-apps.go +++ b/cmd/account/o-auth-published-apps/o-auth-published-apps.go @@ -5,6 +5,7 @@ package o_auth_published_apps 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/oauth2" "github.com/spf13/cobra" ) @@ -73,7 +74,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.OAuthPublishedApps.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) diff --git a/cmd/account/personal-compute/personal-compute.go b/cmd/account/personal-compute/personal-compute.go index dac7e2e30..7045975db 100755 --- a/cmd/account/personal-compute/personal-compute.go +++ b/cmd/account/personal-compute/personal-compute.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 newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Settings.PersonalCompute().Delete(ctx, deleteReq) if err != nil { @@ -136,7 +137,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Settings.PersonalCompute().Get(ctx, getReq) if err != nil { @@ -186,7 +187,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/private-access/private-access.go b/cmd/account/private-access/private-access.go index 312f6d023..9ff518d59 100755 --- a/cmd/account/private-access/private-access.go +++ b/cmd/account/private-access/private-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/provisioning" "github.com/spf13/cobra" @@ -106,7 +107,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -183,7 +184,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -260,7 +261,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -323,7 +324,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.PrivateAccess.List(ctx) if err != nil { return err @@ -414,7 +415,7 @@ func newReplace() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := replaceJson.Unmarshal(&replaceReq) diff --git a/cmd/account/published-app-integration/published-app-integration.go b/cmd/account/published-app-integration/published-app-integration.go index c97bcfc61..80aaea44a 100755 --- a/cmd/account/published-app-integration/published-app-integration.go +++ b/cmd/account/published-app-integration/published-app-integration.go @@ -5,6 +5,7 @@ package published_app_integration 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/oauth2" "github.com/spf13/cobra" @@ -82,7 +83,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -149,7 +150,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) deleteReq.IntegrationId = args[0] @@ -204,7 +205,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getReq.IntegrationId = args[0] @@ -263,7 +264,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.PublishedAppIntegration.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -318,7 +319,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/service-principal-federation-policy/service-principal-federation-policy.go b/cmd/account/service-principal-federation-policy/service-principal-federation-policy.go index 451523b7e..8f74af734 100755 --- a/cmd/account/service-principal-federation-policy/service-principal-federation-policy.go +++ b/cmd/account/service-principal-federation-policy/service-principal-federation-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/oauth2" "github.com/spf13/cobra" @@ -136,7 +137,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq.Policy) @@ -208,7 +209,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) _, err = fmt.Sscan(args[0], &deleteReq.ServicePrincipalId) if err != nil { @@ -269,7 +270,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) _, err = fmt.Sscan(args[0], &getReq.ServicePrincipalId) if err != nil { @@ -332,7 +333,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) _, err = fmt.Sscan(args[0], &listReq.ServicePrincipalId) if err != nil { @@ -397,7 +398,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq.Policy) diff --git a/cmd/account/service-principal-secrets/service-principal-secrets.go b/cmd/account/service-principal-secrets/service-principal-secrets.go index ea6658c17..ec00320d0 100755 --- a/cmd/account/service-principal-secrets/service-principal-secrets.go +++ b/cmd/account/service-principal-secrets/service-principal-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/oauth2" "github.com/spf13/cobra" @@ -91,7 +92,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -165,7 +166,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) _, err = fmt.Sscan(args[0], &deleteReq.ServicePrincipalId) if err != nil { @@ -231,7 +232,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) _, err = fmt.Sscan(args[0], &listReq.ServicePrincipalId) if err != nil { diff --git a/cmd/account/service-principals/service-principals.go b/cmd/account/service-principals/service-principals.go index f6ec1fa54..2015a8350 100755 --- a/cmd/account/service-principals/service-principals.go +++ b/cmd/account/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.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -156,7 +157,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -227,7 +228,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -307,7 +308,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.ServicePrincipals.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -361,7 +362,7 @@ func newPatch() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -457,7 +458,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/storage-credentials/storage-credentials.go b/cmd/account/storage-credentials/storage-credentials.go index b3b8ad367..19d4fc325 100755 --- a/cmd/account/storage-credentials/storage-credentials.go +++ b/cmd/account/storage-credentials/storage-credentials.go @@ -5,6 +5,7 @@ package storage_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" @@ -85,7 +86,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -159,7 +160,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) deleteReq.MetastoreId = args[0] deleteReq.StorageCredentialName = args[1] @@ -221,7 +222,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) getReq.MetastoreId = args[0] getReq.StorageCredentialName = args[1] @@ -281,7 +282,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) listReq.MetastoreId = args[0] @@ -343,7 +344,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/storage/storage.go b/cmd/account/storage/storage.go index 24bb6d80b..ee42e28d7 100755 --- a/cmd/account/storage/storage.go +++ b/cmd/account/storage/storage.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/provisioning" "github.com/spf13/cobra" @@ -84,7 +85,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -151,7 +152,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -221,7 +222,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -284,7 +285,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Storage.List(ctx) if err != nil { return err diff --git a/cmd/account/usage-dashboards/usage-dashboards.go b/cmd/account/usage-dashboards/usage-dashboards.go index a482b466d..487a2407c 100755 --- a/cmd/account/usage-dashboards/usage-dashboards.go +++ b/cmd/account/usage-dashboards/usage-dashboards.go @@ -5,6 +5,7 @@ package usage_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/billing" "github.com/spf13/cobra" @@ -77,7 +78,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -146,7 +147,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.UsageDashboards.Get(ctx, getReq) if err != nil { diff --git a/cmd/account/users/users.go b/cmd/account/users/users.go index 10990084f..ccb50434a 100755 --- a/cmd/account/users/users.go +++ b/cmd/account/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" @@ -100,7 +101,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -165,7 +166,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -243,7 +244,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -323,7 +324,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response := a.Users.List(ctx, listReq) return cmdio.RenderIterator(ctx, response) @@ -377,7 +378,7 @@ func newPatch() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := patchJson.Unmarshal(&patchReq) @@ -474,7 +475,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/vpc-endpoints/vpc-endpoints.go b/cmd/account/vpc-endpoints/vpc-endpoints.go index c1aab0d24..aee4a73cb 100755 --- a/cmd/account/vpc-endpoints/vpc-endpoints.go +++ b/cmd/account/vpc-endpoints/vpc-endpoints.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/provisioning" "github.com/spf13/cobra" @@ -101,7 +102,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -176,7 +177,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -250,7 +251,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -317,7 +318,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.VpcEndpoints.List(ctx) if err != nil { return err diff --git a/cmd/account/workspace-assignment/workspace-assignment.go b/cmd/account/workspace-assignment/workspace-assignment.go index c5385c92a..9e2813233 100755 --- a/cmd/account/workspace-assignment/workspace-assignment.go +++ b/cmd/account/workspace-assignment/workspace-assignment.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" @@ -79,7 +80,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) _, err = fmt.Sscan(args[0], &deleteReq.WorkspaceId) if err != nil { @@ -144,7 +145,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) _, err = fmt.Sscan(args[0], &getReq.WorkspaceId) if err != nil { @@ -206,7 +207,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) _, err = fmt.Sscan(args[0], &listReq.WorkspaceId) if err != nil { @@ -270,7 +271,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/account/workspaces/workspaces.go b/cmd/account/workspaces/workspaces.go index bee01eb41..0d6921019 100755 --- a/cmd/account/workspaces/workspaces.go +++ b/cmd/account/workspaces/workspaces.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/provisioning" "github.com/spf13/cobra" @@ -131,7 +132,7 @@ func newCreate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := createJson.Unmarshal(&createReq) @@ -217,7 +218,7 @@ func newDelete() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -303,7 +304,7 @@ func newGet() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if len(args) == 0 { promptSpinner := cmdio.Spinner(ctx) @@ -372,7 +373,7 @@ func newList() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) response, err := a.Workspaces.List(ctx) if err != nil { return err @@ -556,7 +557,7 @@ func newUpdate() *cobra.Command { cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) if cmd.Flags().Changed("json") { diags := updateJson.Unmarshal(&updateReq) diff --git a/cmd/auth/describe.go b/cmd/auth/describe.go index 74a691787..b045df7ee 100644 --- a/cmd/auth/describe.go +++ b/cmd/auth/describe.go @@ -88,7 +88,7 @@ func getAuthStatus(cmd *cobra.Command, args []string, showSensitive bool, fn try } if isAccount { - a := root.AccountClient(ctx) + a := command.AccountClient(ctx) // Doing a simple API call to check if the auth is valid _, err := a.Workspaces.List(ctx) diff --git a/cmd/auth/describe_test.go b/cmd/auth/describe_test.go index 35e0c6e64..030028f1a 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" @@ -169,7 +170,7 @@ func TestGetWorkspaceAuthStatusSensitive(t *testing.T) { func TestGetAccountAuthStatus(t *testing.T) { ctx := context.Background() m := mocks.NewMockAccountClient(t) - ctx = root.SetAccountClient(ctx, m.AccountClient) + ctx = command.SetAccountClient(ctx, m.AccountClient) cmd := &cobra.Command{} cmd.SetContext(ctx) diff --git a/cmd/root/auth.go b/cmd/root/auth.go index 21b8c8a96..3475ddfef 100644 --- a/cmd/root/auth.go +++ b/cmd/root/auth.go @@ -18,7 +18,6 @@ import ( // Placeholders to use as unique keys in context.Context. var ( workspaceClient int - accountClient int ) type ErrNoWorkspaceProfiles struct { @@ -146,7 +145,7 @@ func MustAccountClient(cmd *cobra.Command, args []string) error { return err } - ctx = context.WithValue(ctx, &accountClient, a) + ctx = command.SetAccountClient(ctx, a) cmd.SetContext(ctx) return nil } @@ -238,10 +237,6 @@ func SetWorkspaceClient(ctx context.Context, w *databricks.WorkspaceClient) cont return context.WithValue(ctx, &workspaceClient, w) } -func SetAccountClient(ctx context.Context, a *databricks.AccountClient) context.Context { - return context.WithValue(ctx, &accountClient, a) -} - func AskForWorkspaceProfile(ctx context.Context) (string, error) { profiler := profile.GetProfiler(ctx) path, err := profiler.GetPath(ctx) @@ -328,11 +323,3 @@ func WorkspaceClient(ctx context.Context) *databricks.WorkspaceClient { } return w } - -func AccountClient(ctx context.Context) *databricks.AccountClient { - a, ok := ctx.Value(&accountClient).(*databricks.AccountClient) - if !ok { - panic("cannot get *databricks.AccountClient. Please report it as a bug") - } - return a -} diff --git a/cmd/root/auth_test.go b/cmd/root/auth_test.go index 784598796..0d568f18c 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" @@ -292,7 +293,7 @@ func TestMustAnyClientCanCreateAccountClient(t *testing.T) { require.NoError(t, err) require.True(t, isAccount) - a := AccountClient(cmd.Context()) + a := command.AccountClient(cmd.Context()) require.NotNil(t, a) } diff --git a/libs/command/account_client.go b/libs/command/account_client.go new file mode 100644 index 000000000..52ed6884a --- /dev/null +++ b/libs/command/account_client.go @@ -0,0 +1,37 @@ +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) +// } + +func SetAccountClient(ctx context.Context, a *databricks.AccountClient) context.Context { + if v := ctx.Value(accountClientKey); v != nil { + panic("command.SetAccountClient called twice on the same context") + } + return context.WithValue(ctx, accountClientKey, a) +} + +func AccountClient(ctx context.Context) *databricks.AccountClient { + a, ok := ctx.Value(accountClientKey).(*databricks.AccountClient) + if !ok { + panic("command.AccountClient called without calling command.SetAccountClient first") + } + return a +} diff --git a/libs/command/context.go b/libs/command/context.go index 8f84f01e6..3fdf19cf7 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) + + // accountClientKey is the context key for an already configured account + // client that can be used to make authenticated requests. + accountClientKey = key(4) )