Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions .codegen/service.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func init() {
{{else if .Entity.IsAny }}// TODO: any: {{.Name}}
{{else if .Entity.ArrayValue }}// TODO: array: {{.Name}}
{{else if .Entity.MapValue }}// TODO: map via StringToStringVar: {{.Name}}
{{else if .Entity.IsEmpty }}// TODO: output-only field
{{else if .Entity.Enum }}{{$method.CamelName}}Cmd.Flags().Var(&{{$method.CamelName}}Req.{{.PascalName}}, "{{.KebabName}}", `{{.Summary | without "`"}}`)
{{else}}{{$method.CamelName}}Cmd.Flags().{{template "arg-type" .Entity}}(&{{$method.CamelName}}Req.{{.PascalName}}, "{{.KebabName}}", {{$method.CamelName}}Req.{{.PascalName}}, `{{.Summary | without "`"}}`)
{{end}}
Expand Down Expand Up @@ -129,35 +130,38 @@ var {{.CamelName}}Cmd = &cobra.Command{
}
{{end}}
{{if $wait -}}
wait, err := {{if .Service.IsAccounts}}a{{else}}w{{end}}.{{.Service.PascalName}}.{{.PascalName}}(ctx{{if .Request}}, {{.CamelName}}Req{{end}})
if err != nil {
return err
}
if {{.CamelName}}SkipWait {
{{template "method-call" .}}
{{if .Response -}}
return cmdio.Render(ctx, wait.Response)
{{- else -}}
return nil
Comment thread
nfx marked this conversation as resolved.
{{- end}}
}
spinner := cmdio.Spinner(ctx)
info, err := {{if .Service.IsAccounts}}a{{else}}w{{end}}.{{.Service.PascalName}}.{{.PascalName}}AndWait(ctx{{if .Request}}, {{.CamelName}}Req{{end}},
retries.Timeout[{{.Service.Package.Name}}.{{.Wait.Poll.Response.PascalName}}]({{.CamelName}}Timeout),
func(i *retries.Info[{{.Service.Package.Name}}.{{.Wait.Poll.Response.PascalName}}]) {
if i.Info == nil {
return
}
{{if .Wait.MessagePath -}}
{{if .Wait.ComplexMessagePath -}}
if i.Info.{{.Wait.MessagePathHead.PascalName}} == nil {
return
}
status := i.Info{{range .Wait.StatusPath}}.{{.PascalName}}{{end}}
statusMessage := fmt.Sprintf("current status: %s", status)
if i.Info.{{.Wait.MessagePathHead.PascalName}} != nil {
statusMessage = i.Info{{range .Wait.MessagePath}}.{{.PascalName}}{{end}}
}
{{- else -}}
statusMessage := i.Info{{range .Wait.MessagePath}}.{{.PascalName}}{{end}}
{{- end}}
{{- else -}}
status := i.Info{{range .Wait.StatusPath}}.{{.PascalName}}{{end}}
statusMessage := fmt.Sprintf("current status: %s", status)
{{- end}}
spinner <- statusMessage
})
info, err := wait.OnProgress(func(i *{{.Service.Package.Name}}.{{.Wait.Poll.Response.PascalName}}) {
{{if .Wait.MessagePath -}}
{{if .Wait.ComplexMessagePath -}}
if i.{{.Wait.MessagePathHead.PascalName}} == nil {
return
}
status := i{{range .Wait.StatusPath}}.{{.PascalName}}{{end}}
statusMessage := fmt.Sprintf("current status: %s", status)
if i.{{.Wait.MessagePathHead.PascalName}} != nil {
statusMessage = i{{range .Wait.MessagePath}}.{{.PascalName}}{{end}}
}
{{- else -}}
statusMessage := i{{range .Wait.MessagePath}}.{{.PascalName}}{{end}}
{{- end}}
{{- else -}}
status := i{{range .Wait.StatusPath}}.{{.PascalName}}{{end}}
statusMessage := fmt.Sprintf("current status: %s", status)
{{- end}}
spinner <- statusMessage
}).GetWithTimeout({{.CamelName}}Timeout)
close(spinner)
if err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cmd/account/access-control/access-control.go linguist-generated=true
cmd/account/billable-usage/billable-usage.go linguist-generated=true
cmd/account/budgets/budgets.go linguist-generated=true
cmd/account/cmd.go linguist-generated=true
Expand All @@ -15,6 +16,7 @@ cmd/account/private-access/private-access.go linguist-generated=true
cmd/account/published-app-integration/published-app-integration.go linguist-generated=true
cmd/account/service-principal-secrets/service-principal-secrets.go linguist-generated=true
cmd/account/service-principals/service-principals.go linguist-generated=true
cmd/account/settings/settings.go linguist-generated=true
cmd/account/storage-credentials/storage-credentials.go linguist-generated=true
cmd/account/storage/storage.go linguist-generated=true
cmd/account/users/users.go linguist-generated=true
Expand All @@ -26,6 +28,7 @@ cmd/workspace/catalogs/catalogs.go linguist-generated=true
cmd/workspace/cluster-policies/cluster-policies.go linguist-generated=true
cmd/workspace/clusters/clusters.go linguist-generated=true
cmd/workspace/cmd.go linguist-generated=true
cmd/workspace/connections/connections.go linguist-generated=true
cmd/workspace/current-user/current-user.go linguist-generated=true
cmd/workspace/dashboards/dashboards.go linguist-generated=true
cmd/workspace/data-sources/data-sources.go linguist-generated=true
Expand Down Expand Up @@ -58,6 +61,7 @@ cmd/workspace/service-principals/service-principals.go linguist-generated=true
cmd/workspace/serving-endpoints/serving-endpoints.go linguist-generated=true
cmd/workspace/shares/shares.go linguist-generated=true
cmd/workspace/storage-credentials/storage-credentials.go linguist-generated=true
cmd/workspace/system-schemas/system-schemas.go linguist-generated=true
cmd/workspace/table-constraints/table-constraints.go linguist-generated=true
cmd/workspace/tables/tables.go linguist-generated=true
cmd/workspace/token-management/token-management.go linguist-generated=true
Expand Down
43 changes: 17 additions & 26 deletions bundle/run/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/databricks/cli/bundle/run/progress"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/log"
"github.com/databricks/databricks-sdk-go/retries"
"github.com/databricks/databricks-sdk-go/service/jobs"
"github.com/fatih/color"
flag "github.com/spf13/pflag"
Expand Down Expand Up @@ -145,51 +144,36 @@ func (r *jobRunner) logFailedTasks(ctx context.Context, runId int64) {
}
}

func pullRunIdCallback(runId *int64) func(info *retries.Info[jobs.Run]) {
return func(info *retries.Info[jobs.Run]) {
i := info.Info
if i == nil {
return
}

func pullRunIdCallback(runId *int64) func(info *jobs.Run) {
return func(i *jobs.Run) {
if *runId == 0 {
*runId = i.RunId
}
}
}

func logDebugCallback(ctx context.Context, runId *int64) func(info *retries.Info[jobs.Run]) {
func logDebugCallback(ctx context.Context, runId *int64) func(info *jobs.Run) {
var prevState *jobs.RunState
return func(info *retries.Info[jobs.Run]) {
i := info.Info
if i == nil {
return
}

return func(i *jobs.Run) {
state := i.State
if state == nil {
return
}

// Log the job run URL as soon as it is available.
if prevState == nil {
log.Infof(ctx, "Run available at %s", info.Info.RunPageUrl)
log.Infof(ctx, "Run available at %s", i.RunPageUrl)
}
if prevState == nil || prevState.LifeCycleState != state.LifeCycleState {
log.Infof(ctx, "Run status: %s", info.Info.State.LifeCycleState)
log.Infof(ctx, "Run status: %s", i.State.LifeCycleState)
prevState = state
}
}
}

func logProgressCallback(ctx context.Context, progressLogger *cmdio.Logger) func(info *retries.Info[jobs.Run]) {
func logProgressCallback(ctx context.Context, progressLogger *cmdio.Logger) func(info *jobs.Run) {
var prevState *jobs.RunState
return func(info *retries.Info[jobs.Run]) {
i := info.Info
if i == nil {
return
}

return func(i *jobs.Run) {
state := i.State
if state == nil {
return
Expand Down Expand Up @@ -255,8 +239,15 @@ func (r *jobRunner) Run(ctx context.Context, opts *Options) (output.RunOutput, e
}
logProgress := logProgressCallback(ctx, progressLogger)

run, err := w.Jobs.RunNowAndWait(ctx, *req,
retries.Timeout[jobs.Run](jobRunTimeout), pullRunId, logDebug, logProgress)
waiter, err := w.Jobs.RunNow(ctx, *req)
if err != nil {
return nil, fmt.Errorf("cannot start job")
}
run, err := waiter.OnProgress(func(r *jobs.Run) {
pullRunId(r)
logDebug(r)
logProgress(r)
}).GetWithTimeout(jobRunTimeout)
if err != nil && runId != nil {
r.logFailedTasks(ctx, *runId)
}
Expand Down
172 changes: 172 additions & 0 deletions cmd/account/access-control/access-control.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions cmd/account/cmd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading