diff --git a/.codegen/service.go.tmpl b/.codegen/service.go.tmpl index 72aea3705..5bab09608 100644 --- a/.codegen/service.go.tmpl +++ b/.codegen/service.go.tmpl @@ -101,7 +101,7 @@ var {{.CamelName}}Cmd = &cobra.Command{ names, err := {{if .Service.IsAccounts}}a{{else}}w{{end}}.{{(.Service.TrimPrefix "account").PascalName}}.{{.Service.List.NamedIdMap.PascalName}}(ctx{{if .Service.List.Request}}, {{.Service.Package.Name}}.{{.Service.List.Request.PascalName}}{}{{end}}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for {{.Service.TitleName}} drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "{{range .Request.RequiredFields}}{{.Summary | trimSuffix "."}}{{end}}") if err != nil { diff --git a/cmd/account/budgets/budgets.go b/cmd/account/budgets/budgets.go index 8edbe0a6d..ff39aacfd 100755 --- a/cmd/account/budgets/budgets.go +++ b/cmd/account/budgets/budgets.go @@ -99,7 +99,7 @@ var deleteCmd = &cobra.Command{ names, err := a.Budgets.BudgetWithStatusNameToBudgetIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Budgets drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Budget ID") if err != nil { @@ -158,7 +158,7 @@ var getCmd = &cobra.Command{ names, err := a.Budgets.BudgetWithStatusNameToBudgetIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Budgets drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Budget ID") if err != nil { diff --git a/cmd/account/credentials/credentials.go b/cmd/account/credentials/credentials.go index 81f587709..0b2abb80d 100755 --- a/cmd/account/credentials/credentials.go +++ b/cmd/account/credentials/credentials.go @@ -118,7 +118,7 @@ var deleteCmd = &cobra.Command{ names, err := a.Credentials.CredentialCredentialsNameToCredentialsIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Credentials drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks Account API credential configuration ID") if err != nil { @@ -177,7 +177,7 @@ var getCmd = &cobra.Command{ names, err := a.Credentials.CredentialCredentialsNameToCredentialsIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Credentials drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks Account API credential configuration ID") if err != nil { diff --git a/cmd/account/groups/groups.go b/cmd/account/groups/groups.go index 143bbf92c..6b5db4140 100755 --- a/cmd/account/groups/groups.go +++ b/cmd/account/groups/groups.go @@ -116,7 +116,7 @@ var deleteCmd = &cobra.Command{ names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a group in the Databricks account") if err != nil { @@ -174,7 +174,7 @@ var getCmd = &cobra.Command{ names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a group in the Databricks account") if err != nil { @@ -289,7 +289,7 @@ var patchCmd = &cobra.Command{ names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a group in the Databricks account") if err != nil { @@ -355,7 +355,7 @@ var updateCmd = &cobra.Command{ names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks group ID") if err != nil { diff --git a/cmd/account/ip-access-lists/ip-access-lists.go b/cmd/account/ip-access-lists/ip-access-lists.go index d52917afe..1719dce81 100755 --- a/cmd/account/ip-access-lists/ip-access-lists.go +++ b/cmd/account/ip-access-lists/ip-access-lists.go @@ -137,7 +137,7 @@ var deleteCmd = &cobra.Command{ names, err := a.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list") if err != nil { @@ -195,7 +195,7 @@ var getCmd = &cobra.Command{ names, err := a.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list") if err != nil { diff --git a/cmd/account/log-delivery/log-delivery.go b/cmd/account/log-delivery/log-delivery.go index a20972ce7..f42b9d54c 100755 --- a/cmd/account/log-delivery/log-delivery.go +++ b/cmd/account/log-delivery/log-delivery.go @@ -188,7 +188,7 @@ var getCmd = &cobra.Command{ names, err := a.LogDelivery.LogDeliveryConfigurationConfigNameToConfigIdMap(ctx, billing.ListLogDeliveryRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Log Delivery drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks log delivery configuration ID") if err != nil { diff --git a/cmd/account/networks/networks.go b/cmd/account/networks/networks.go index 9a0b77391..e472f0ddb 100755 --- a/cmd/account/networks/networks.go +++ b/cmd/account/networks/networks.go @@ -63,7 +63,7 @@ var createCmd = &cobra.Command{ names, err := a.Networks.NetworkNetworkNameToNetworkIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Networks drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The human-readable name of the network configuration") if err != nil { @@ -126,7 +126,7 @@ var deleteCmd = &cobra.Command{ names, err := a.Networks.NetworkNetworkNameToNetworkIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Networks drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks Account API network configuration ID") if err != nil { @@ -185,7 +185,7 @@ var getCmd = &cobra.Command{ names, err := a.Networks.NetworkNetworkNameToNetworkIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Networks drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks Account API network configuration ID") if err != nil { diff --git a/cmd/account/private-access/private-access.go b/cmd/account/private-access/private-access.go index 0a6f06e50..bc91e1b51 100755 --- a/cmd/account/private-access/private-access.go +++ b/cmd/account/private-access/private-access.go @@ -128,7 +128,7 @@ var deleteCmd = &cobra.Command{ names, err := a.PrivateAccess.PrivateAccessSettingsPrivateAccessSettingsNameToPrivateAccessSettingsIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Private Access drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks Account API private access settings ID") if err != nil { @@ -193,7 +193,7 @@ var getCmd = &cobra.Command{ names, err := a.PrivateAccess.PrivateAccessSettingsPrivateAccessSettingsNameToPrivateAccessSettingsIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Private Access drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks Account API private access settings ID") if err != nil { diff --git a/cmd/account/service-principals/service-principals.go b/cmd/account/service-principals/service-principals.go index f2bce37ab..7be4bc5a2 100755 --- a/cmd/account/service-principals/service-principals.go +++ b/cmd/account/service-principals/service-principals.go @@ -115,7 +115,7 @@ var deleteCmd = &cobra.Command{ names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a service principal in the Databricks account") if err != nil { @@ -174,7 +174,7 @@ var getCmd = &cobra.Command{ names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a service principal in the Databricks account") if err != nil { @@ -290,7 +290,7 @@ var patchCmd = &cobra.Command{ names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a service principal in the Databricks account") if err != nil { @@ -359,7 +359,7 @@ var updateCmd = &cobra.Command{ names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks service principal ID") if err != nil { diff --git a/cmd/account/storage/storage.go b/cmd/account/storage/storage.go index 023d5894a..feedab5e2 100755 --- a/cmd/account/storage/storage.go +++ b/cmd/account/storage/storage.go @@ -114,7 +114,7 @@ var deleteCmd = &cobra.Command{ names, err := a.Storage.StorageConfigurationStorageConfigurationNameToStorageConfigurationIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Storage drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks Account API storage configuration ID") if err != nil { @@ -172,7 +172,7 @@ var getCmd = &cobra.Command{ names, err := a.Storage.StorageConfigurationStorageConfigurationNameToStorageConfigurationIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Storage drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks Account API storage configuration ID") if err != nil { diff --git a/cmd/account/users/users.go b/cmd/account/users/users.go index faf240d8e..8d976b9a6 100755 --- a/cmd/account/users/users.go +++ b/cmd/account/users/users.go @@ -124,7 +124,7 @@ var deleteCmd = &cobra.Command{ names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a user in the Databricks account") if err != nil { @@ -182,7 +182,7 @@ var getCmd = &cobra.Command{ names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a user in the Databricks account") if err != nil { @@ -298,7 +298,7 @@ var patchCmd = &cobra.Command{ names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a user in the Databricks account") if err != nil { @@ -367,7 +367,7 @@ var updateCmd = &cobra.Command{ names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks user ID") if err != nil { diff --git a/cmd/account/vpc-endpoints/vpc-endpoints.go b/cmd/account/vpc-endpoints/vpc-endpoints.go index 295d7621f..778e88966 100755 --- a/cmd/account/vpc-endpoints/vpc-endpoints.go +++ b/cmd/account/vpc-endpoints/vpc-endpoints.go @@ -70,7 +70,7 @@ var createCmd = &cobra.Command{ names, err := a.VpcEndpoints.VpcEndpointVpcEndpointNameToVpcEndpointIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Vpc Endpoints drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The human-readable name of the storage configuration") if err != nil { @@ -136,7 +136,7 @@ var deleteCmd = &cobra.Command{ names, err := a.VpcEndpoints.VpcEndpointVpcEndpointNameToVpcEndpointIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Vpc Endpoints drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks VPC endpoint ID") if err != nil { @@ -198,7 +198,7 @@ var getCmd = &cobra.Command{ names, err := a.VpcEndpoints.VpcEndpointVpcEndpointNameToVpcEndpointIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Vpc Endpoints drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks VPC endpoint ID") if err != nil { diff --git a/cmd/account/workspaces/workspaces.go b/cmd/account/workspaces/workspaces.go index 4dbfe24e4..2c7a996e6 100755 --- a/cmd/account/workspaces/workspaces.go +++ b/cmd/account/workspaces/workspaces.go @@ -89,7 +89,7 @@ var createCmd = &cobra.Command{ names, err := a.Workspaces.WorkspaceWorkspaceNameToWorkspaceIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Workspaces drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The workspace's human-readable name") if err != nil { @@ -171,7 +171,7 @@ var deleteCmd = &cobra.Command{ names, err := a.Workspaces.WorkspaceWorkspaceNameToWorkspaceIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Workspaces drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Workspace ID") if err != nil { @@ -245,7 +245,7 @@ var getCmd = &cobra.Command{ names, err := a.Workspaces.WorkspaceWorkspaceNameToWorkspaceIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Workspaces drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Workspace ID") if err != nil { @@ -459,7 +459,7 @@ var updateCmd = &cobra.Command{ names, err := a.Workspaces.WorkspaceWorkspaceNameToWorkspaceIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Workspaces drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Workspace ID") if err != nil { diff --git a/cmd/auth/profiles.go b/cmd/auth/profiles.go index 465d45bfb..d3b167b77 100644 --- a/cmd/auth/profiles.go +++ b/cmd/auth/profiles.go @@ -99,8 +99,8 @@ var profilesCmd = &cobra.Command{ Short: "Lists profiles from ~/.databrickscfg", Annotations: map[string]string{ "template": cmdio.Heredoc(` - {{white "Name"}} {{white "Host"}} {{white "Valid"}} - {{range .Profiles}}{{.Name | green}} {{.Host|white}} {{bool .Valid}} + {{header "Name"}} {{header "Host"}} {{header "Valid"}} + {{range .Profiles}}{{.Name | green}} {{.Host|cyan}} {{bool .Valid}} {{end}}`), }, RunE: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/workspace/alerts/alerts.go b/cmd/workspace/alerts/alerts.go index e1485d31a..5cdb0d483 100755 --- a/cmd/workspace/alerts/alerts.go +++ b/cmd/workspace/alerts/alerts.go @@ -111,7 +111,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Alerts.AlertNameToIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Alerts drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -169,7 +169,7 @@ var getCmd = &cobra.Command{ names, err := w.Alerts.AlertNameToIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Alerts drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { diff --git a/cmd/workspace/catalogs/overrides.go b/cmd/workspace/catalogs/overrides.go index 574c95778..5b8cffea9 100644 --- a/cmd/workspace/catalogs/overrides.go +++ b/cmd/workspace/catalogs/overrides.go @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "Name"}} {{white "Type"}} {{white "Comment"}} + {{header "Name"}} {{header "Type"}} {{header "Comment"}} {{range .}}{{.Name|green}} {{blue "%s" .CatalogType}} {{.Comment}} {{end}}`) } diff --git a/cmd/workspace/cluster-policies/cluster-policies.go b/cmd/workspace/cluster-policies/cluster-policies.go index dce0a604f..66d3d8352 100755 --- a/cmd/workspace/cluster-policies/cluster-policies.go +++ b/cmd/workspace/cluster-policies/cluster-policies.go @@ -83,7 +83,7 @@ var createCmd = &cobra.Command{ names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Cluster Policy name requested by the user") if err != nil { @@ -142,7 +142,7 @@ var deleteCmd = &cobra.Command{ names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID of the policy to delete") if err != nil { @@ -256,7 +256,7 @@ var getCmd = &cobra.Command{ names, err := w.ClusterPolicies.PolicyNameToPolicyIdMap(ctx, compute.ListClusterPoliciesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Cluster Policies drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Canonical unique identifier for the cluster policy") if err != nil { diff --git a/cmd/workspace/clusters/clusters.go b/cmd/workspace/clusters/clusters.go index 10155161c..3a40b2d47 100755 --- a/cmd/workspace/clusters/clusters.go +++ b/cmd/workspace/clusters/clusters.go @@ -174,7 +174,7 @@ var createCmd = &cobra.Command{ names, err := w.Clusters.ClusterInfoClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The Spark version of the cluster, e.g") if err != nil { @@ -257,7 +257,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Clusters.ClusterInfoClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The cluster to be terminated") if err != nil { @@ -448,7 +448,7 @@ var eventsCmd = &cobra.Command{ names, err := w.Clusters.ClusterInfoClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID of the cluster to retrieve events about") if err != nil { @@ -512,7 +512,7 @@ var getCmd = &cobra.Command{ names, err := w.Clusters.ClusterInfoClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The cluster about which to retrieve information") if err != nil { @@ -688,7 +688,7 @@ var permanentDeleteCmd = &cobra.Command{ names, err := w.Clusters.ClusterInfoClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The cluster to be deleted") if err != nil { @@ -748,7 +748,7 @@ var pinCmd = &cobra.Command{ names, err := w.Clusters.ClusterInfoClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -815,7 +815,7 @@ var resizeCmd = &cobra.Command{ names, err := w.Clusters.ClusterInfoClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The cluster to be resized") if err != nil { @@ -898,7 +898,7 @@ var restartCmd = &cobra.Command{ names, err := w.Clusters.ClusterInfoClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The cluster to be started") if err != nil { @@ -1013,7 +1013,7 @@ var startCmd = &cobra.Command{ names, err := w.Clusters.ClusterInfoClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The cluster to be started") if err != nil { @@ -1090,7 +1090,7 @@ var unpinCmd = &cobra.Command{ names, err := w.Clusters.ClusterInfoClusterNameToClusterIdMap(ctx, compute.ListClustersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Clusters drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { diff --git a/cmd/workspace/clusters/overrides.go b/cmd/workspace/clusters/overrides.go index f98ac5929..1e8818952 100644 --- a/cmd/workspace/clusters/overrides.go +++ b/cmd/workspace/clusters/overrides.go @@ -4,8 +4,8 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "ID"}} {{white "Name"}} {{white "State"}} - {{range .}}{{.ClusterId | green}} {{.ClusterName|white}} {{if eq .State "RUNNING"}}{{green "%s" .State}}{{else if eq .State "TERMINATED"}}{{red "%s" .State}}{{else}}{{blue "%s" .State}}{{end}} + {{header "ID"}} {{header "Name"}} {{header "State"}} + {{range .}}{{.ClusterId | green}} {{.ClusterName | cyan}} {{if eq .State "RUNNING"}}{{green "%s" .State}}{{else if eq .State "TERMINATED"}}{{red "%s" .State}}{{else}}{{blue "%s" .State}}{{end}} {{end}}`) listNodeTypesCmd.Annotations["template"] = cmdio.Heredoc(` diff --git a/cmd/workspace/dashboards/dashboards.go b/cmd/workspace/dashboards/dashboards.go index b7b1fa1c8..315d1e740 100755 --- a/cmd/workspace/dashboards/dashboards.go +++ b/cmd/workspace/dashboards/dashboards.go @@ -110,7 +110,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Dashboards.DashboardNameToIdMap(ctx, sql.ListDashboardsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Dashboards drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -169,7 +169,7 @@ var getCmd = &cobra.Command{ names, err := w.Dashboards.DashboardNameToIdMap(ctx, sql.ListDashboardsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Dashboards drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -279,7 +279,7 @@ var restoreCmd = &cobra.Command{ names, err := w.Dashboards.DashboardNameToIdMap(ctx, sql.ListDashboardsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Dashboards drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { diff --git a/cmd/workspace/dashboards/overrides.go b/cmd/workspace/dashboards/overrides.go index 87bc14e4f..ba7e42ec7 100644 --- a/cmd/workspace/dashboards/overrides.go +++ b/cmd/workspace/dashboards/overrides.go @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "ID"}} {{white "Name"}} + {{header "ID"}} {{header "Name"}} {{range .}}{{.Id|green}} {{.Name}} {{end}}`) } diff --git a/cmd/workspace/external-locations/overrides.go b/cmd/workspace/external-locations/overrides.go index 7afd7da0c..7efd193d9 100644 --- a/cmd/workspace/external-locations/overrides.go +++ b/cmd/workspace/external-locations/overrides.go @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "Name"}} {{white "Credential"}} {{white "URL"}} - {{range .}}{{.Name|green}} {{.CredentialName|blue}} {{.Url}} + {{header "Name"}} {{header "Credential"}} {{header "URL"}} + {{range .}}{{.Name|green}} {{.CredentialName|cyan}} {{.Url}} {{end}}`) } diff --git a/cmd/workspace/git-credentials/git-credentials.go b/cmd/workspace/git-credentials/git-credentials.go index ea7242da9..161629888 100755 --- a/cmd/workspace/git-credentials/git-credentials.go +++ b/cmd/workspace/git-credentials/git-credentials.go @@ -65,7 +65,7 @@ var createCmd = &cobra.Command{ names, err := w.GitCredentials.CredentialInfoGitProviderToCredentialIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Git Credentials drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Git provider") if err != nil { @@ -123,7 +123,7 @@ var deleteCmd = &cobra.Command{ names, err := w.GitCredentials.CredentialInfoGitProviderToCredentialIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Git Credentials drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID for the corresponding credential to access") if err != nil { @@ -184,7 +184,7 @@ var getCmd = &cobra.Command{ names, err := w.GitCredentials.CredentialInfoGitProviderToCredentialIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Git Credentials drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID for the corresponding credential to access") if err != nil { @@ -277,7 +277,7 @@ var updateCmd = &cobra.Command{ names, err := w.GitCredentials.CredentialInfoGitProviderToCredentialIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Git Credentials drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID for the corresponding credential to access") if err != nil { diff --git a/cmd/workspace/global-init-scripts/global-init-scripts.go b/cmd/workspace/global-init-scripts/global-init-scripts.go index 090a2b352..3a2c3b649 100755 --- a/cmd/workspace/global-init-scripts/global-init-scripts.go +++ b/cmd/workspace/global-init-scripts/global-init-scripts.go @@ -114,7 +114,7 @@ var deleteCmd = &cobra.Command{ names, err := w.GlobalInitScripts.GlobalInitScriptDetailsNameToScriptIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Global Init Scripts drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID of the global init script") if err != nil { @@ -172,7 +172,7 @@ var getCmd = &cobra.Command{ names, err := w.GlobalInitScripts.GlobalInitScriptDetailsNameToScriptIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Global Init Scripts drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID of the global init script") if err != nil { diff --git a/cmd/workspace/groups/groups.go b/cmd/workspace/groups/groups.go index 9f85cdf33..aa5a7e355 100755 --- a/cmd/workspace/groups/groups.go +++ b/cmd/workspace/groups/groups.go @@ -116,7 +116,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a group in the Databricks workspace") if err != nil { @@ -174,7 +174,7 @@ var getCmd = &cobra.Command{ names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a group in the Databricks workspace") if err != nil { @@ -289,7 +289,7 @@ var patchCmd = &cobra.Command{ names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a group in the Databricks workspace") if err != nil { @@ -355,7 +355,7 @@ var updateCmd = &cobra.Command{ names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks group ID") if err != nil { diff --git a/cmd/workspace/instance-pools/instance-pools.go b/cmd/workspace/instance-pools/instance-pools.go index d78ae9396..c80feb59e 100755 --- a/cmd/workspace/instance-pools/instance-pools.go +++ b/cmd/workspace/instance-pools/instance-pools.go @@ -133,7 +133,7 @@ var deleteCmd = &cobra.Command{ names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The instance pool to be terminated") if err != nil { @@ -253,7 +253,7 @@ var getCmd = &cobra.Command{ names, err := w.InstancePools.InstancePoolAndStatsInstancePoolNameToInstancePoolIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Instance Pools drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The canonical unique identifier for the instance pool") if err != nil { diff --git a/cmd/workspace/ip-access-lists/ip-access-lists.go b/cmd/workspace/ip-access-lists/ip-access-lists.go index e29339747..bbefc063a 100755 --- a/cmd/workspace/ip-access-lists/ip-access-lists.go +++ b/cmd/workspace/ip-access-lists/ip-access-lists.go @@ -138,7 +138,7 @@ var deleteCmd = &cobra.Command{ names, err := w.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list to modify") if err != nil { @@ -196,7 +196,7 @@ var getCmd = &cobra.Command{ names, err := w.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list to modify") if err != nil { diff --git a/cmd/workspace/jobs/jobs.go b/cmd/workspace/jobs/jobs.go index 601293eea..77eea5686 100755 --- a/cmd/workspace/jobs/jobs.go +++ b/cmd/workspace/jobs/jobs.go @@ -74,7 +74,7 @@ var cancelAllRunsCmd = &cobra.Command{ names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The canonical identifier of the job to cancel all runs of") if err != nil { @@ -141,7 +141,7 @@ var cancelRunCmd = &cobra.Command{ names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "This field is required") if err != nil { @@ -290,7 +290,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The canonical identifier of the job to delete") if err != nil { @@ -351,7 +351,7 @@ var deleteRunCmd = &cobra.Command{ names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The canonical identifier of the run for which to retrieve the metadata") if err != nil { @@ -414,7 +414,7 @@ var exportRunCmd = &cobra.Command{ names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The canonical identifier for the run") if err != nil { @@ -475,7 +475,7 @@ var getCmd = &cobra.Command{ names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The canonical identifier of the job to retrieve information about") if err != nil { @@ -543,7 +543,7 @@ var getRunCmd = &cobra.Command{ names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The canonical identifier of the run for which to retrieve the metadata") if err != nil { @@ -613,7 +613,7 @@ var getRunOutputCmd = &cobra.Command{ names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The canonical identifier for the run") if err != nil { @@ -802,7 +802,7 @@ var repairRunCmd = &cobra.Command{ names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The job run ID of the run to repair") if err != nil { @@ -951,7 +951,7 @@ var runNowCmd = &cobra.Command{ names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID of the job to be executed") if err != nil { @@ -1128,7 +1128,7 @@ var updateCmd = &cobra.Command{ names, err := w.Jobs.BaseJobSettingsNameToJobIdMap(ctx, jobs.ListJobsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Jobs drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The canonical identifier of the job to update") if err != nil { diff --git a/cmd/workspace/jobs/overrides.go b/cmd/workspace/jobs/overrides.go index 103176cba..93512c84a 100644 --- a/cmd/workspace/jobs/overrides.go +++ b/cmd/workspace/jobs/overrides.go @@ -8,7 +8,7 @@ func init() { {{end}}`) listRunsCmd.Annotations["template"] = cmdio.Heredoc(` - {{"Job ID"|white}} {{"Run ID"|white}} {{"Result State"|white}} URL - {{range .}}{{green "%d" .JobId}} {{blue "%d" .RunId}} {{if eq .State.ResultState "SUCCESS"}}{{"SUCCESS"|green}}{{else}}{{red "%s" .State.ResultState}}{{end}} {{.RunPageUrl}} + {{header "Job ID"}} {{header "Run ID"}} {{header "Result State"}} URL + {{range .}}{{green "%d" .JobId}} {{cyan "%d" .RunId}} {{if eq .State.ResultState "SUCCESS"}}{{"SUCCESS"|green}}{{else}}{{red "%s" .State.ResultState}}{{end}} {{.RunPageUrl}} {{end}}`) } diff --git a/cmd/workspace/metastores/metastores.go b/cmd/workspace/metastores/metastores.go index 589140a06..4df439d49 100755 --- a/cmd/workspace/metastores/metastores.go +++ b/cmd/workspace/metastores/metastores.go @@ -201,7 +201,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Metastores.MetastoreInfoNameToMetastoreIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Metastores drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID of the metastore") if err != nil { @@ -260,7 +260,7 @@ var getCmd = &cobra.Command{ names, err := w.Metastores.MetastoreInfoNameToMetastoreIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Metastores drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID of the metastore") if err != nil { @@ -488,7 +488,7 @@ var updateCmd = &cobra.Command{ names, err := w.Metastores.MetastoreInfoNameToMetastoreIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Metastores drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID of the metastore") if err != nil { @@ -552,7 +552,7 @@ var updateAssignmentCmd = &cobra.Command{ names, err := w.Metastores.MetastoreInfoNameToMetastoreIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Metastores drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "A workspace ID") if err != nil { diff --git a/cmd/workspace/metastores/overrides.go b/cmd/workspace/metastores/overrides.go index d53675d02..9d1c23ac2 100644 --- a/cmd/workspace/metastores/overrides.go +++ b/cmd/workspace/metastores/overrides.go @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "ID"}} {{white "Name"}} {{white "Region"}} - {{range .}}{{.MetastoreId|green}} {{.Name|white}} {{.Region}} + {{header "ID"}} {{header "Name"}} {{"Region"}} + {{range .}}{{.MetastoreId|green}} {{.Name|cyan}} {{.Region}} {{end}}`) } diff --git a/cmd/workspace/pipelines/pipelines.go b/cmd/workspace/pipelines/pipelines.go index 1d2871749..8ef29664f 100755 --- a/cmd/workspace/pipelines/pipelines.go +++ b/cmd/workspace/pipelines/pipelines.go @@ -136,7 +136,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -197,7 +197,7 @@ var getCmd = &cobra.Command{ names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -309,7 +309,7 @@ var listPipelineEventsCmd = &cobra.Command{ names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -423,7 +423,7 @@ var listUpdatesCmd = &cobra.Command{ names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The pipeline to return updates for") if err != nil { @@ -486,7 +486,7 @@ var resetCmd = &cobra.Command{ names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -566,7 +566,7 @@ var startUpdateCmd = &cobra.Command{ names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -629,7 +629,7 @@ var stopCmd = &cobra.Command{ names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -724,7 +724,7 @@ var updateCmd = &cobra.Command{ names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique identifier for this pipeline") if err != nil { diff --git a/cmd/workspace/providers/providers.go b/cmd/workspace/providers/providers.go index c9dd3cd0a..3fd237528 100755 --- a/cmd/workspace/providers/providers.go +++ b/cmd/workspace/providers/providers.go @@ -111,7 +111,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Providers.ProviderInfoNameToMetastoreIdMap(ctx, sharing.ListProvidersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Providers drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Name of the provider") if err != nil { @@ -171,7 +171,7 @@ var getCmd = &cobra.Command{ names, err := w.Providers.ProviderInfoNameToMetastoreIdMap(ctx, sharing.ListProvidersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Providers drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Name of the provider") if err != nil { @@ -283,7 +283,7 @@ var listSharesCmd = &cobra.Command{ names, err := w.Providers.ProviderInfoNameToMetastoreIdMap(ctx, sharing.ListProvidersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Providers drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Name of the provider in which to list shares") if err != nil { @@ -349,7 +349,7 @@ var updateCmd = &cobra.Command{ names, err := w.Providers.ProviderInfoNameToMetastoreIdMap(ctx, sharing.ListProvidersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Providers drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The name of the Provider") if err != nil { diff --git a/cmd/workspace/queries/overrides.go b/cmd/workspace/queries/overrides.go index cc22ffaee..86f47388e 100644 --- a/cmd/workspace/queries/overrides.go +++ b/cmd/workspace/queries/overrides.go @@ -5,7 +5,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { // TODO: figure out colored/non-colored headers and colspan shifts listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "ID"}} {{white "Name"}} {{white "Author"}} - {{range .}}{{.Id|green}} {{.Name|white}} {{.User.Email|white}} + {{header "ID"}} {{header "Name"}} {{header "Author"}} + {{range .}}{{.Id|green}} {{.Name|cyan}} {{.User.Email|cyan}} {{end}}`) } diff --git a/cmd/workspace/queries/queries.go b/cmd/workspace/queries/queries.go index fa83408aa..ea4d2bac0 100755 --- a/cmd/workspace/queries/queries.go +++ b/cmd/workspace/queries/queries.go @@ -121,7 +121,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Queries.QueryNameToIdMap(ctx, sql.ListQueriesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Queries drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -180,7 +180,7 @@ var getCmd = &cobra.Command{ names, err := w.Queries.QueryNameToIdMap(ctx, sql.ListQueriesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Queries drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -292,7 +292,7 @@ var restoreCmd = &cobra.Command{ names, err := w.Queries.QueryNameToIdMap(ctx, sql.ListQueriesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Queries drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { @@ -358,7 +358,7 @@ var updateCmd = &cobra.Command{ names, err := w.Queries.QueryNameToIdMap(ctx, sql.ListQueriesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Queries drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "") if err != nil { diff --git a/cmd/workspace/query-history/overrides.go b/cmd/workspace/query-history/overrides.go index 11f0d9c8d..7e7020697 100644 --- a/cmd/workspace/query-history/overrides.go +++ b/cmd/workspace/query-history/overrides.go @@ -5,6 +5,6 @@ import "github.com/databricks/cli/libs/cmdio" func init() { // TODO: figure out the right format listCmd.Annotations["template"] = cmdio.Heredoc(` - {{range .}}{{.UserName}} {{white "%s" .Status}} {{.QueryText}} + {{range .}}{{.UserName}} {{cyan "%s" .Status}} {{.QueryText}} {{end}}`) } diff --git a/cmd/workspace/recipients/recipients.go b/cmd/workspace/recipients/recipients.go index 2f907a6d8..0d615aa4d 100755 --- a/cmd/workspace/recipients/recipients.go +++ b/cmd/workspace/recipients/recipients.go @@ -116,7 +116,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Recipients.RecipientInfoNameToMetastoreIdMap(ctx, sharing.ListRecipientsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Recipients drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Name of the recipient") if err != nil { @@ -176,7 +176,7 @@ var getCmd = &cobra.Command{ names, err := w.Recipients.RecipientInfoNameToMetastoreIdMap(ctx, sharing.ListRecipientsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Recipients drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Name of the recipient") if err != nil { @@ -340,7 +340,7 @@ var sharePermissionsCmd = &cobra.Command{ names, err := w.Recipients.RecipientInfoNameToMetastoreIdMap(ctx, sharing.ListRecipientsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Recipients drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The name of the Recipient") if err != nil { @@ -406,7 +406,7 @@ var updateCmd = &cobra.Command{ names, err := w.Recipients.RecipientInfoNameToMetastoreIdMap(ctx, sharing.ListRecipientsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Recipients drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Name of Recipient") if err != nil { diff --git a/cmd/workspace/repos/repos.go b/cmd/workspace/repos/repos.go index d3e95fc78..09e497dfc 100755 --- a/cmd/workspace/repos/repos.go +++ b/cmd/workspace/repos/repos.go @@ -117,7 +117,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID for the corresponding repo to access") if err != nil { @@ -178,7 +178,7 @@ var getCmd = &cobra.Command{ names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID for the corresponding repo to access") if err != nil { @@ -295,7 +295,7 @@ var updateCmd = &cobra.Command{ names, err := w.Repos.RepoInfoPathToIdMap(ctx, workspace.ListReposRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Repos drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID for the corresponding repo to access") if err != nil { diff --git a/cmd/workspace/schemas/overrides.go b/cmd/workspace/schemas/overrides.go index fbf4bebcd..4ff8bf124 100644 --- a/cmd/workspace/schemas/overrides.go +++ b/cmd/workspace/schemas/overrides.go @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "Full Name"}} {{white "Owner"}} {{white "Comment"}} - {{range .}}{{.FullName|green}} {{.Owner|white}} {{.Comment}} + {{header "Full Name"}} {{header "Owner"}} {{header "Comment"}} + {{range .}}{{.FullName|green}} {{.Owner|cyan}} {{.Comment}} {{end}}`) } diff --git a/cmd/workspace/schemas/schemas.go b/cmd/workspace/schemas/schemas.go index c4bce9dd5..a1216dfa6 100755 --- a/cmd/workspace/schemas/schemas.go +++ b/cmd/workspace/schemas/schemas.go @@ -114,7 +114,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Schemas.SchemaInfoNameToFullNameMap(ctx, catalog.ListSchemasRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Schemas drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Full name of the schema") if err != nil { @@ -174,7 +174,7 @@ var getCmd = &cobra.Command{ names, err := w.Schemas.SchemaInfoNameToFullNameMap(ctx, catalog.ListSchemasRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Schemas drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Full name of the schema") if err != nil { @@ -293,7 +293,7 @@ var updateCmd = &cobra.Command{ names, err := w.Schemas.SchemaInfoNameToFullNameMap(ctx, catalog.ListSchemasRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Schemas drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Full name of the schema") if err != nil { diff --git a/cmd/workspace/secrets/overrides.go b/cmd/workspace/secrets/overrides.go index e3ab714f4..d46284bf6 100644 --- a/cmd/workspace/secrets/overrides.go +++ b/cmd/workspace/secrets/overrides.go @@ -10,7 +10,7 @@ import ( func init() { listScopesCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "Scope"}} {{white "Backend Type"}} + {{header "Scope"}} {{header "Backend Type"}} {{range .}}{{.Name|green}} {{.BackendType}} {{end}}`) diff --git a/cmd/workspace/service-principals/service-principals.go b/cmd/workspace/service-principals/service-principals.go index ea52d52a4..db03aad09 100755 --- a/cmd/workspace/service-principals/service-principals.go +++ b/cmd/workspace/service-principals/service-principals.go @@ -115,7 +115,7 @@ var deleteCmd = &cobra.Command{ names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a service principal in the Databricks workspace") if err != nil { @@ -174,7 +174,7 @@ var getCmd = &cobra.Command{ names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a service principal in the Databricks workspace") if err != nil { @@ -290,7 +290,7 @@ var patchCmd = &cobra.Command{ names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a service principal in the Databricks workspace") if err != nil { @@ -359,7 +359,7 @@ var updateCmd = &cobra.Command{ names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks service principal ID") if err != nil { diff --git a/cmd/workspace/storage-credentials/overrides.go b/cmd/workspace/storage-credentials/overrides.go index e9643d39b..8bce9ffa2 100644 --- a/cmd/workspace/storage-credentials/overrides.go +++ b/cmd/workspace/storage-credentials/overrides.go @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "ID"}} {{white "Name"}} {{white "Credentials"}} - {{range .}}{{.Id|green}} {{.Name|white}} {{if .AwsIamRole}}{{.AwsIamRole.RoleArn}}{{end}}{{if .AzureServicePrincipal}}{{.AzureServicePrincipal.ApplicationId}}{{end}}{{if .GcpServiceAccountKey}}{{.Email}}{{end}} + {{header "ID"}} {{header "Name"}} {{header "Credentials"}} + {{range .}}{{.Id|green}} {{.Name|cyan}} {{if .AwsIamRole}}{{.AwsIamRole.RoleArn}}{{end}}{{if .AzureServicePrincipal}}{{.AzureServicePrincipal.ApplicationId}}{{end}}{{if .GcpServiceAccountKey}}{{.Email}}{{end}} {{end}}`) } diff --git a/cmd/workspace/tables/overrides.go b/cmd/workspace/tables/overrides.go index 128821c23..ed9c86ed5 100644 --- a/cmd/workspace/tables/overrides.go +++ b/cmd/workspace/tables/overrides.go @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "Full Name"}} {{white "Table Type"}} + {{header "Full Name"}} {{header "Table Type"}} {{range .}}{{.FullName|green}} {{blue "%s" .TableType}} {{end}}`) } diff --git a/cmd/workspace/tables/tables.go b/cmd/workspace/tables/tables.go index c4f0dd80f..a8bee878e 100755 --- a/cmd/workspace/tables/tables.go +++ b/cmd/workspace/tables/tables.go @@ -66,7 +66,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Tables.TableInfoNameToTableIdMap(ctx, catalog.ListTablesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Tables drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Full name of the table") if err != nil { @@ -130,7 +130,7 @@ var getCmd = &cobra.Command{ names, err := w.Tables.TableInfoNameToTableIdMap(ctx, catalog.ListTablesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Tables drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Full name of the table") if err != nil { @@ -261,7 +261,7 @@ var listSummariesCmd = &cobra.Command{ names, err := w.Tables.TableInfoNameToTableIdMap(ctx, catalog.ListTablesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Tables drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Name of parent catalog for tables of interest") if err != nil { diff --git a/cmd/workspace/token-management/overrides.go b/cmd/workspace/token-management/overrides.go index ea3bbaf95..2070e2a2b 100644 --- a/cmd/workspace/token-management/overrides.go +++ b/cmd/workspace/token-management/overrides.go @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "ID"}} {{white "Created By"}} {{white "Comment"}} - {{range .}}{{.TokenId|green}} {{.CreatedByUsername|white}} {{.Comment|white}} + {{header "ID"}} {{header "Created By"}} {{header "Comment"}} + {{range .}}{{.TokenId|green}} {{.CreatedByUsername|cyan}} {{.Comment|cyan}} {{end}}`) } diff --git a/cmd/workspace/token-management/token-management.go b/cmd/workspace/token-management/token-management.go index 03c32b595..0b56f7b58 100755 --- a/cmd/workspace/token-management/token-management.go +++ b/cmd/workspace/token-management/token-management.go @@ -110,7 +110,7 @@ var deleteCmd = &cobra.Command{ names, err := w.TokenManagement.TokenInfoCommentToTokenIdMap(ctx, settings.ListTokenManagementRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Token Management drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID of the token to get") if err != nil { @@ -168,7 +168,7 @@ var getCmd = &cobra.Command{ names, err := w.TokenManagement.TokenInfoCommentToTokenIdMap(ctx, settings.ListTokenManagementRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Token Management drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID of the token to get") if err != nil { diff --git a/cmd/workspace/tokens/overrides.go b/cmd/workspace/tokens/overrides.go index 8d9ba41f2..b5673c0e9 100644 --- a/cmd/workspace/tokens/overrides.go +++ b/cmd/workspace/tokens/overrides.go @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "ID"}} {{white "Expiry time"}} {{white "Comment"}} - {{range .}}{{.TokenId|green}} {{white "%d" .ExpiryTime}} {{.Comment|white}} + {{header "ID"}} {{header "Expiry time"}} {{header "Comment"}} + {{range .}}{{.TokenId|green}} {{cyan "%d" .ExpiryTime}} {{.Comment|cyan}} {{end}}`) } diff --git a/cmd/workspace/tokens/tokens.go b/cmd/workspace/tokens/tokens.go index 359f1afd8..7ee5f0c80 100755 --- a/cmd/workspace/tokens/tokens.go +++ b/cmd/workspace/tokens/tokens.go @@ -111,7 +111,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Tokens.TokenInfoCommentToTokenIdMap(ctx) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Tokens drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The ID of the token to be revoked") if err != nil { diff --git a/cmd/workspace/users/users.go b/cmd/workspace/users/users.go index fec18927a..95301548a 100755 --- a/cmd/workspace/users/users.go +++ b/cmd/workspace/users/users.go @@ -124,7 +124,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a user in the Databricks workspace") if err != nil { @@ -182,7 +182,7 @@ var getCmd = &cobra.Command{ names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a user in the Databricks workspace") if err != nil { @@ -298,7 +298,7 @@ var patchCmd = &cobra.Command{ names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Unique ID for a user in the Databricks workspace") if err != nil { @@ -367,7 +367,7 @@ var updateCmd = &cobra.Command{ names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Databricks user ID") if err != nil { diff --git a/cmd/workspace/volumes/volumes.go b/cmd/workspace/volumes/volumes.go index 8364850d4..a584dcebe 100755 --- a/cmd/workspace/volumes/volumes.go +++ b/cmd/workspace/volumes/volumes.go @@ -139,7 +139,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Volumes.VolumeInfoNameToVolumeIdMap(ctx, catalog.ListVolumesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Volumes drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The three-level (fully qualified) name of the volume") if err != nil { @@ -261,7 +261,7 @@ var readCmd = &cobra.Command{ names, err := w.Volumes.VolumeInfoNameToVolumeIdMap(ctx, catalog.ListVolumesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Volumes drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The three-level (fully qualified) name of the volume") if err != nil { @@ -330,7 +330,7 @@ var updateCmd = &cobra.Command{ names, err := w.Volumes.VolumeInfoNameToVolumeIdMap(ctx, catalog.ListVolumesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Volumes drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The three-level (fully qualified) name of the volume") if err != nil { diff --git a/cmd/workspace/warehouses/overrides.go b/cmd/workspace/warehouses/overrides.go index 5f7723300..82319d6fc 100644 --- a/cmd/workspace/warehouses/overrides.go +++ b/cmd/workspace/warehouses/overrides.go @@ -4,7 +4,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "ID"}} {{white "Name"}} {{white "Size"}} {{white "State"}} - {{range .}}{{.Id|green}} {{.Name|white}} {{.ClusterSize|white}} {{if eq .State "RUNNING"}}{{"RUNNING"|green}}{{else if eq .State "STOPPED"}}{{"STOPPED"|red}}{{else}}{{blue "%s" .State}}{{end}} + {{header "ID"}} {{header "Name"}} {{header "Size"}} {{header "State"}} + {{range .}}{{.Id|green}} {{.Name|cyan}} {{.ClusterSize|cyan}} {{if eq .State "RUNNING"}}{{"RUNNING"|green}}{{else if eq .State "STOPPED"}}{{"STOPPED"|red}}{{else}}{{blue "%s" .State}}{{end}} {{end}}`) } diff --git a/cmd/workspace/warehouses/warehouses.go b/cmd/workspace/warehouses/warehouses.go index ad8ef1c7a..3387e36ee 100755 --- a/cmd/workspace/warehouses/warehouses.go +++ b/cmd/workspace/warehouses/warehouses.go @@ -153,7 +153,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Required") if err != nil { @@ -254,7 +254,7 @@ var editCmd = &cobra.Command{ names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Required") if err != nil { @@ -341,7 +341,7 @@ var getCmd = &cobra.Command{ names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Required") if err != nil { @@ -539,7 +539,7 @@ var startCmd = &cobra.Command{ names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Required") if err != nil { @@ -626,7 +626,7 @@ var stopCmd = &cobra.Command{ names, err := w.Warehouses.EndpointInfoNameToIdMap(ctx, sql.ListWarehousesRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Warehouses drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "Required") if err != nil { diff --git a/cmd/workspace/workspace/overrides.go b/cmd/workspace/workspace/overrides.go index 611868905..0a00ba259 100644 --- a/cmd/workspace/workspace/overrides.go +++ b/cmd/workspace/workspace/overrides.go @@ -5,7 +5,7 @@ import "github.com/databricks/cli/libs/cmdio" func init() { listReq.Path = "/" listCmd.Annotations["template"] = cmdio.Heredoc(` - {{white "ID"}} {{white "Type"}} {{white "Language"}} {{white "Path"}} - {{range .}}{{green "%d" .ObjectId}} {{blue "%s" .ObjectType}} {{cyan "%s" .Language}} {{.Path|white}} + {{header "ID"}} {{header "Type"}} {{header "Language"}} {{header "Path"}} + {{range .}}{{green "%d" .ObjectId}} {{blue "%s" .ObjectType}} {{cyan "%s" .Language}} {{.Path|cyan}} {{end}}`) } diff --git a/cmd/workspace/workspace/workspace.go b/cmd/workspace/workspace/workspace.go index 03598c5ff..c942d7aa5 100755 --- a/cmd/workspace/workspace/workspace.go +++ b/cmd/workspace/workspace/workspace.go @@ -67,7 +67,7 @@ var deleteCmd = &cobra.Command{ names, err := w.Workspace.ObjectInfoPathToObjectIdMap(ctx, workspace.ListWorkspaceRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Workspace drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The absolute path of the notebook or directory") if err != nil { @@ -135,7 +135,7 @@ var exportCmd = &cobra.Command{ names, err := w.Workspace.ObjectInfoPathToObjectIdMap(ctx, workspace.ListWorkspaceRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Workspace drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The absolute path of the object or directory") if err != nil { @@ -194,7 +194,7 @@ var getStatusCmd = &cobra.Command{ names, err := w.Workspace.ObjectInfoPathToObjectIdMap(ctx, workspace.ListWorkspaceRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Workspace drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The absolute path of the notebook or directory") if err != nil { @@ -260,7 +260,7 @@ var importCmd = &cobra.Command{ names, err := w.Workspace.ObjectInfoPathToObjectIdMap(ctx, workspace.ListWorkspaceRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Workspace drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The absolute path of the object or directory") if err != nil { @@ -375,7 +375,7 @@ var mkdirsCmd = &cobra.Command{ names, err := w.Workspace.ObjectInfoPathToObjectIdMap(ctx, workspace.ListWorkspaceRequest{}) close(promptSpinner) if err != nil { - return err + return fmt.Errorf("failed to load names for Workspace drop-down. Please manually specify required arguments. Original error: %w", err) } id, err := cmdio.Select(ctx, names, "The absolute path of the directory") if err != nil { diff --git a/internal/fs_ls_test.go b/internal/fs_ls_test.go new file mode 100644 index 000000000..060c706df --- /dev/null +++ b/internal/fs_ls_test.go @@ -0,0 +1,104 @@ +package internal + +import ( + "context" + "encoding/json" + "io/fs" + "path" + "regexp" + "strings" + "testing" + + _ "github.com/databricks/cli/cmd/fs" + "github.com/databricks/cli/libs/filer" + "github.com/databricks/databricks-sdk-go" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestFsLsForDbfs(t *testing.T) { + t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV")) + + ctx := context.Background() + w, err := databricks.NewWorkspaceClient() + require.NoError(t, err) + + tmpDir := temporaryDbfsDir(t, w) + + f, err := filer.NewDbfsClient(w, tmpDir) + require.NoError(t, err) + + err = f.Mkdir(ctx, "a") + require.NoError(t, err) + err = f.Write(ctx, "a/hello.txt", strings.NewReader("abc"), filer.CreateParentDirectories) + require.NoError(t, err) + err = f.Write(ctx, "bye.txt", strings.NewReader("def")) + require.NoError(t, err) + + stdout, stderr := RequireSuccessfulRun(t, "fs", "ls", "dbfs:"+tmpDir, "--output=json") + assert.Equal(t, "", stderr.String()) + var parsedStdout []map[string]any + err = json.Unmarshal(stdout.Bytes(), &parsedStdout) + require.NoError(t, err) + + // assert on ls output + assert.Equal(t, "a", parsedStdout[0]["name"]) + assert.Equal(t, true, parsedStdout[0]["is_directory"]) + assert.Equal(t, float64(0), parsedStdout[0]["size"]) + assert.Equal(t, "bye.txt", parsedStdout[1]["name"]) + assert.Equal(t, false, parsedStdout[1]["is_directory"]) + assert.Equal(t, float64(3), parsedStdout[1]["size"]) +} + +func TestFsLsForDbfsOnFile(t *testing.T) { + t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV")) + + ctx := context.Background() + w, err := databricks.NewWorkspaceClient() + require.NoError(t, err) + + tmpDir := temporaryDbfsDir(t, w) + + f, err := filer.NewDbfsClient(w, tmpDir) + require.NoError(t, err) + + err = f.Mkdir(ctx, "a") + require.NoError(t, err) + err = f.Write(ctx, "a/hello.txt", strings.NewReader("abc"), filer.CreateParentDirectories) + require.NoError(t, err) + + _, _, err = RequireErrorRun(t, "fs", "ls", "dbfs:"+path.Join(tmpDir, "a", "hello.txt"), "--output=json") + assert.Regexp(t, regexp.MustCompile("not a directory: .*/a/hello.txt"), err.Error()) +} + +func TestFsLsForDbfsOnEmptyDir(t *testing.T) { + t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV")) + + w, err := databricks.NewWorkspaceClient() + require.NoError(t, err) + + tmpDir := temporaryDbfsDir(t, w) + + stdout, stderr := RequireSuccessfulRun(t, "fs", "ls", "dbfs:"+tmpDir, "--output=json") + assert.Equal(t, "", stderr.String()) + var parsedStdout []map[string]any + err = json.Unmarshal(stdout.Bytes(), &parsedStdout) + require.NoError(t, err) + + // assert on ls output + assert.Equal(t, 0, len(parsedStdout)) +} + +func TestFsLsForDbfsForNonexistingDir(t *testing.T) { + t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV")) + + _, _, err := RequireErrorRun(t, "fs", "ls", "dbfs:/john-cena", "--output=json") + assert.ErrorIs(t, err, fs.ErrNotExist) +} + +func TestFsLsWithoutScheme(t *testing.T) { + t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV")) + + _, _, err := RequireErrorRun(t, "fs", "ls", "/ray-mysterio", "--output=json") + assert.ErrorContains(t, err, "expected dbfs path (with the dbfs:/ prefix): /ray-mysterio") +} diff --git a/libs/cmdio/render.go b/libs/cmdio/render.go index 2e42c32c2..c8f2b0dfc 100644 --- a/libs/cmdio/render.go +++ b/libs/cmdio/render.go @@ -59,8 +59,7 @@ func renderTemplate(w io.Writer, tmpl string, v any) error { // we render colored output if stdout is TTY, otherwise we render text. // in the future we'll check if we can explicitly check for stderr being // a TTY - "black": color.BlackString, - "white": color.WhiteString, + "header": color.BlueString, "red": color.RedString, "green": color.GreenString, "blue": color.BlueString, @@ -111,8 +110,9 @@ func fancyJSON(v any) ([]byte, error) { f.FalseColor = color.New(color.FgRed) f.NumberColor = color.New(color.FgCyan) f.NullColor = color.New(color.FgMagenta) - f.FieldColor = color.New(color.FgWhite, color.Bold) - f.FieldQuoteColor = color.New(color.FgWhite) + f.ObjectColor = color.New(color.Reset) + f.CommaColor = color.New(color.Reset) + f.ColonColor = color.New(color.Reset) return jsoncolor.MarshalIndentWithFormatter(v, "", " ", f) }