databricks-cli/cmd/workspace/jobs/overrides.go

26 lines
877 B
Go

package jobs
import (
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/databricks-sdk-go/service/jobs"
"github.com/spf13/cobra"
)
func listOverride(listCmd *cobra.Command, listReq *jobs.ListJobsRequest) {
listCmd.Annotations["template"] = cmdio.Heredoc(`
{{range .}}{{green "%d" .JobId}} {{.Settings.Name}}
{{end}}`)
}
func listRunsOverride(listRunsCmd *cobra.Command, listRunsReq *jobs.ListRunsRequest) {
listRunsCmd.Annotations["template"] = cmdio.Heredoc(`
{{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}}`)
}
func init() {
listOverrides = append(listOverrides, listOverride)
listRunsOverrides = append(listRunsOverrides, listRunsOverride)
}