-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathoverrides.go
More file actions
35 lines (30 loc) · 969 Bytes
/
overrides.go
File metadata and controls
35 lines (30 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)
}