Skip to content
32 changes: 32 additions & 0 deletions cmd/workspace/alerts/overrides.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package alerts

import (
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/tableview"
"github.com/databricks/databricks-sdk-go/service/sql"
"github.com/spf13/cobra"
)

func listOverride(listCmd *cobra.Command, listReq *sql.ListAlertsRequest) {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{green "%s" .Id}} {{.DisplayName}} {{.State}}
{{end}}`)

columns := []tableview.ColumnDef{
{Header: "ID", Extract: func(v any) string {
return v.(sql.ListAlertsResponseAlert).Id
}},
{Header: "Name", Extract: func(v any) string {
return v.(sql.ListAlertsResponseAlert).DisplayName
}},
{Header: "State", Extract: func(v any) string {
return string(v.(sql.ListAlertsResponseAlert).State)
}},
}

tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
}

func init() {
listOverrides = append(listOverrides, listOverride)
}
24 changes: 24 additions & 0 deletions cmd/workspace/apps/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

appsCli "github.com/databricks/cli/cmd/apps"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/tableview"
"github.com/databricks/databricks-sdk-go/service/apps"
"github.com/spf13/cobra"
)
Expand All @@ -15,6 +16,29 @@ func listOverride(listCmd *cobra.Command, listReq *apps.ListAppsRequest) {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{.Name | green}} {{.Url}} {{if .ComputeStatus}}{{if eq .ComputeStatus.State "ACTIVE"}}{{green "%s" .ComputeStatus.State }}{{else}}{{blue "%s" .ComputeStatus.State}}{{end}}{{end}} {{if .ActiveDeployment}}{{if eq .ActiveDeployment.Status.State "SUCCEEDED"}}{{green "%s" .ActiveDeployment.Status.State }}{{else}}{{blue "%s" .ActiveDeployment.Status.State}}{{end}}{{end}}
{{end}}`)

columns := []tableview.ColumnDef{
{Header: "Name", Extract: func(v any) string {
return v.(apps.App).Name
}},
{Header: "URL", Extract: func(v any) string {
return v.(apps.App).Url
}},
{Header: "Compute Status", Extract: func(v any) string {
if v.(apps.App).ComputeStatus != nil {
return string(v.(apps.App).ComputeStatus.State)
}
return ""
}},
{Header: "Deploy Status", Extract: func(v any) string {
if v.(apps.App).ActiveDeployment != nil && v.(apps.App).ActiveDeployment.Status != nil {
return string(v.(apps.App).ActiveDeployment.Status.State)
}
return ""
}},
}

tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
}

func listDeploymentsOverride(listDeploymentsCmd *cobra.Command, listDeploymentsReq *apps.ListAppDeploymentsRequest) {
Expand Down
15 changes: 15 additions & 0 deletions cmd/workspace/catalogs/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package catalogs

import (
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/tableview"
"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/spf13/cobra"
)
Expand All @@ -12,6 +13,20 @@ func listOverride(listCmd *cobra.Command, listReq *catalog.ListCatalogsRequest)
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{.Name|green}} {{blue "%s" .CatalogType}} {{.Comment}}
{{end}}`)

columns := []tableview.ColumnDef{
{Header: "Name", Extract: func(v any) string {
return v.(catalog.CatalogInfo).Name
}},
{Header: "Type", Extract: func(v any) string {
return string(v.(catalog.CatalogInfo).CatalogType)
}},
{Header: "Comment", MaxWidth: 40, Extract: func(v any) string {
return v.(catalog.CatalogInfo).Comment
}},
}

tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
}

func init() {
Expand Down
15 changes: 15 additions & 0 deletions cmd/workspace/clusters/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"strings"

"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/tableview"
"github.com/databricks/databricks-sdk-go/service/compute"
"github.com/spf13/cobra"
)
Expand All @@ -17,6 +18,20 @@ func listOverride(listCmd *cobra.Command, listReq *compute.ListClustersRequest)
{{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}}`)

columns := []tableview.ColumnDef{
{Header: "Cluster ID", Extract: func(v any) string {
return v.(compute.ClusterDetails).ClusterId
}},
{Header: "Name", Extract: func(v any) string {
return v.(compute.ClusterDetails).ClusterName
}},
{Header: "State", Extract: func(v any) string {
return string(v.(compute.ClusterDetails).State)
}},
}

tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})

listReq.FilterBy = &compute.ListClustersFilterBy{}
listCmd.Flags().BoolVar(&listReq.FilterBy.IsPinned, "is-pinned", false, "Filter clusters by pinned status")
listCmd.Flags().StringVar(&listReq.FilterBy.PolicyId, "policy-id", "", "Filter clusters by policy id")
Expand Down
15 changes: 15 additions & 0 deletions cmd/workspace/external-locations/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package external_locations

import (
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/tableview"
"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/spf13/cobra"
)
Expand All @@ -12,6 +13,20 @@ func listOverride(listCmd *cobra.Command, listReq *catalog.ListExternalLocations
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{.Name|green}} {{.CredentialName|cyan}} {{.Url}}
{{end}}`)

columns := []tableview.ColumnDef{
{Header: "Name", Extract: func(v any) string {
return v.(catalog.ExternalLocationInfo).Name
}},
{Header: "Credential", Extract: func(v any) string {
return v.(catalog.ExternalLocationInfo).CredentialName
}},
{Header: "URL", Extract: func(v any) string {
return v.(catalog.ExternalLocationInfo).Url
}},
}

tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
}

func init() {
Expand Down
19 changes: 19 additions & 0 deletions cmd/workspace/instance-pools/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@ package instance_pools

import (
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/tableview"
"github.com/databricks/databricks-sdk-go/service/compute"
"github.com/spf13/cobra"
)

func listOverride(listCmd *cobra.Command) {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{.InstancePoolId|green}} {{.InstancePoolName}} {{.NodeTypeId}} {{.State}}
{{end}}`)

columns := []tableview.ColumnDef{
{Header: "Pool ID", Extract: func(v any) string {
return v.(compute.InstancePoolAndStats).InstancePoolId
}},
{Header: "Name", Extract: func(v any) string {
return v.(compute.InstancePoolAndStats).InstancePoolName
}},
{Header: "Node Type", Extract: func(v any) string {
return v.(compute.InstancePoolAndStats).NodeTypeId
}},
{Header: "State", Extract: func(v any) string {
return string(v.(compute.InstancePoolAndStats).State)
}},
}

tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
}

func init() {
Expand Down
30 changes: 30 additions & 0 deletions cmd/workspace/jobs/overrides.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package jobs

import (
"context"
"strconv"

"github.com/databricks/cli/libs/cmdctx"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/tableview"
"github.com/databricks/databricks-sdk-go/service/jobs"
"github.com/spf13/cobra"
)
Expand All @@ -10,6 +15,31 @@ func listOverride(listCmd *cobra.Command, listReq *jobs.ListJobsRequest) {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{green "%d" .JobId}} {{.Settings.Name}}
{{end}}`)

columns := []tableview.ColumnDef{
{Header: "Job ID", Extract: func(v any) string {
return strconv.FormatInt(v.(jobs.BaseJob).JobId, 10)
}},
{Header: "Name", Extract: func(v any) string {
if v.(jobs.BaseJob).Settings != nil {
return v.(jobs.BaseJob).Settings.Name
}
return ""
}},
}

tableview.RegisterConfig(listCmd, tableview.TableConfig{
Columns: columns,
Search: &tableview.SearchConfig{
Placeholder: "Search by exact name...",
NewIterator: func(ctx context.Context, query string) tableview.RowIterator {
req := *listReq
req.Name = query
w := cmdctx.WorkspaceClient(ctx)
return tableview.WrapIterator(w.Jobs.List(ctx, req), columns)
},
},
})
}

func listRunsOverride(listRunsCmd *cobra.Command, listRunsReq *jobs.ListRunsRequest) {
Expand Down
40 changes: 40 additions & 0 deletions cmd/workspace/pipelines/overrides.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,55 @@
package pipelines

import (
"context"
"fmt"
"regexp"
"slices"
"strings"

pipelinesCli "github.com/databricks/cli/cmd/pipelines"
"github.com/databricks/cli/libs/cmdctx"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/tableview"
"github.com/databricks/databricks-sdk-go/service/pipelines"
"github.com/spf13/cobra"
)

func listPipelinesOverride(listCmd *cobra.Command, listReq *pipelines.ListPipelinesRequest) {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{green "%s" .PipelineId}} {{.Name}} {{blue "%s" .State}}
{{end}}`)

columns := []tableview.ColumnDef{
{Header: "Pipeline ID", Extract: func(v any) string {
return v.(pipelines.PipelineStateInfo).PipelineId
}},
{Header: "Name", Extract: func(v any) string {
return v.(pipelines.PipelineStateInfo).Name
}},
{Header: "State", Extract: func(v any) string {
return string(v.(pipelines.PipelineStateInfo).State)
}},
}

tableview.RegisterConfig(listCmd, tableview.TableConfig{
Columns: columns,
Search: &tableview.SearchConfig{
Placeholder: "Filter by name...",
NewIterator: func(ctx context.Context, query string) tableview.RowIterator {
req := *listReq
escaped := strings.ReplaceAll(query, "'", "''")
req.Filter = fmt.Sprintf("name LIKE '%%%s%%'", escaped)
w := cmdctx.WorkspaceClient(ctx)
return tableview.WrapIterator(w.Pipelines.ListPipelines(ctx, req), columns)
},
},
})
}

func init() {
listPipelinesOverrides = append(listPipelinesOverrides, listPipelinesOverride)

cmdOverrides = append(cmdOverrides, func(cli *cobra.Command) {
// all auto-generated commands apart from nonManagementCommands go into 'management' group
nonManagementCommands := []string{
Expand Down
18 changes: 18 additions & 0 deletions cmd/workspace/repos/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/flags"
"github.com/databricks/cli/libs/tableview"
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/service/workspace"
"github.com/spf13/cobra"
Expand All @@ -20,6 +21,23 @@ func listOverride(listCmd *cobra.Command, listReq *workspace.ListReposRequest) {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{green "%d" .Id}} {{.Path}} {{.Branch|blue}} {{.Url|cyan}}
{{end}}`)

columns := []tableview.ColumnDef{
{Header: "ID", Extract: func(v any) string {
return strconv.FormatInt(v.(workspace.RepoInfo).Id, 10)
}},
{Header: "Path", Extract: func(v any) string {
return v.(workspace.RepoInfo).Path
}},
{Header: "Branch", Extract: func(v any) string {
return v.(workspace.RepoInfo).Branch
}},
{Header: "URL", Extract: func(v any) string {
return v.(workspace.RepoInfo).Url
}},
}

tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
}

func createOverride(createCmd *cobra.Command, createReq *workspace.CreateRepoRequest) {
Expand Down
15 changes: 15 additions & 0 deletions cmd/workspace/schemas/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package schemas

import (
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/tableview"
"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/spf13/cobra"
)
Expand All @@ -12,6 +13,20 @@ func listOverride(listCmd *cobra.Command, listReq *catalog.ListSchemasRequest) {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{.FullName|green}} {{.Owner|cyan}} {{.Comment}}
{{end}}`)

columns := []tableview.ColumnDef{
{Header: "Full Name", Extract: func(v any) string {
return v.(catalog.SchemaInfo).FullName
}},
{Header: "Owner", Extract: func(v any) string {
return v.(catalog.SchemaInfo).Owner
}},
{Header: "Comment", MaxWidth: 40, Extract: func(v any) string {
return v.(catalog.SchemaInfo).Comment
}},
}

tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
}

func init() {
Expand Down
35 changes: 35 additions & 0 deletions cmd/workspace/serving-endpoints/overrides.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package serving_endpoints

import (
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/tableview"
"github.com/databricks/databricks-sdk-go/service/serving"
"github.com/spf13/cobra"
)

func listOverride(listCmd *cobra.Command) {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{green "%s" .Name}} {{if .State}}{{.State.Ready}}{{end}} {{.Creator}}
{{end}}`)

columns := []tableview.ColumnDef{
{Header: "Name", Extract: func(v any) string {
return v.(serving.ServingEndpoint).Name
}},
{Header: "State", Extract: func(v any) string {
if v.(serving.ServingEndpoint).State != nil {
return string(v.(serving.ServingEndpoint).State.Ready)
}
return ""
}},
{Header: "Creator", Extract: func(v any) string {
return v.(serving.ServingEndpoint).Creator
}},
}

tableview.RegisterConfig(listCmd, tableview.TableConfig{Columns: columns})
}

func init() {
listOverrides = append(listOverrides, listOverride)
}
Loading
Loading