mirror of https://github.com/databricks/cli.git
Compare commits
9 Commits
91ad4df7bf
...
4d858dd247
Author | SHA1 | Date |
---|---|---|
|
4d858dd247 | |
|
9d193fb921 | |
|
b452f53ccf | |
|
3d96565d04 | |
|
162aa212bc | |
|
b6a376bf8a | |
|
b81008e2f6 | |
|
26afab2ccb | |
|
edff68c763 |
|
@ -130,21 +130,26 @@ func new{{.PascalName}}() *cobra.Command {
|
||||||
cmd.Flags().BoolVar(&{{.CamelName}}SkipWait, "no-wait", {{.CamelName}}SkipWait, `do not wait to reach {{range $i, $e := .Wait.Success}}{{if $i}} or {{end}}{{.Content}}{{end}} state`)
|
cmd.Flags().BoolVar(&{{.CamelName}}SkipWait, "no-wait", {{.CamelName}}SkipWait, `do not wait to reach {{range $i, $e := .Wait.Success}}{{if $i}} or {{end}}{{.Content}}{{end}} state`)
|
||||||
cmd.Flags().DurationVar(&{{.CamelName}}Timeout, "timeout", {{.Wait.Timeout}}*time.Minute, `maximum amount of time to reach {{range $i, $e := .Wait.Success}}{{if $i}} or {{end}}{{.Content}}{{end}} state`)
|
cmd.Flags().DurationVar(&{{.CamelName}}Timeout, "timeout", {{.Wait.Timeout}}*time.Minute, `maximum amount of time to reach {{range $i, $e := .Wait.Success}}{{if $i}} or {{end}}{{.Content}}{{end}} state`)
|
||||||
{{end -}}
|
{{end -}}
|
||||||
{{if .Request}}// TODO: short flags
|
{{- $request := .Request -}}
|
||||||
|
{{- if .RequestBodyField -}}
|
||||||
|
{{- $request = .RequestBodyField.Entity -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{if $request }}// TODO: short flags
|
||||||
{{- if .CanUseJson}}
|
{{- if .CanUseJson}}
|
||||||
cmd.Flags().Var(&{{.CamelName}}Json, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&{{.CamelName}}Json, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
{{- end}}
|
{{- end}}
|
||||||
{{$method := .}}
|
{{$method := .}}
|
||||||
{{ if not .IsJsonOnly }}
|
{{ if not .IsJsonOnly }}
|
||||||
{{range .Request.Fields -}}
|
{{range $request.Fields -}}
|
||||||
{{- if not .Required -}}
|
{{- if not .Required -}}
|
||||||
{{if .Entity.IsObject }}// TODO: complex arg: {{.Name}}
|
{{if .Entity.IsObject }}// TODO: complex arg: {{.Name}}
|
||||||
{{else if .Entity.IsAny }}// TODO: any: {{.Name}}
|
{{else if .Entity.IsAny }}// TODO: any: {{.Name}}
|
||||||
{{else if .Entity.ArrayValue }}// TODO: array: {{.Name}}
|
{{else if .Entity.ArrayValue }}// TODO: array: {{.Name}}
|
||||||
{{else if .Entity.MapValue }}// TODO: map via StringToStringVar: {{.Name}}
|
{{else if .Entity.MapValue }}// TODO: map via StringToStringVar: {{.Name}}
|
||||||
{{else if .Entity.IsEmpty }}// TODO: output-only field
|
{{else if .Entity.IsEmpty }}// TODO: output-only field
|
||||||
{{else if .Entity.Enum }}cmd.Flags().Var(&{{$method.CamelName}}Req.{{.PascalName}}, "{{.KebabName}}", `{{.Summary | without "`" | trimSuffix "."}}. Supported values: {{template "printArray" .Entity.Enum}}`)
|
{{else if .Entity.IsComputed -}}
|
||||||
{{else}}cmd.Flags().{{template "arg-type" .Entity}}(&{{$method.CamelName}}Req.{{.PascalName}}, "{{.KebabName}}", {{$method.CamelName}}Req.{{.PascalName}}, `{{.Summary | without "`"}}`)
|
{{else if .Entity.Enum }}cmd.Flags().Var(&{{- template "request-body-obj" (dict "Method" $method "Field" .)}}, "{{.KebabName}}", `{{.Summary | without "`" | trimSuffix "."}}. Supported values: {{template "printArray" .Entity.Enum}}`)
|
||||||
|
{{else}}cmd.Flags().{{template "arg-type" .Entity}}(&{{- template "request-body-obj" (dict "Method" $method "Field" .)}}, "{{.KebabName}}", {{- template "request-body-obj" (dict "Method" $method "Field" .)}}, `{{.Summary | without "`"}}`)
|
||||||
{{end}}
|
{{end}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
@ -164,14 +169,14 @@ func new{{.PascalName}}() *cobra.Command {
|
||||||
{{- $noPrompt := or .IsCrudCreate (in $excludeFromPrompts $fullCommandName) }}
|
{{- $noPrompt := or .IsCrudCreate (in $excludeFromPrompts $fullCommandName) }}
|
||||||
|
|
||||||
{{- $hasPosArgs := .HasRequiredPositionalArguments -}}
|
{{- $hasPosArgs := .HasRequiredPositionalArguments -}}
|
||||||
{{- $hasSinglePosArg := and $hasPosArgs (eq 1 (len .Request.RequiredFields)) -}}
|
{{- $hasSinglePosArg := and $hasPosArgs (eq 1 (len $request.RequiredFields)) -}}
|
||||||
{{- $serviceHasNamedIdMap := and (and .Service.List .Service.List.NamedIdMap) (not (eq .PascalName "List")) -}}
|
{{- $serviceHasNamedIdMap := and (and .Service.List .Service.List.NamedIdMap) (not (eq .PascalName "List")) -}}
|
||||||
{{- $hasIdPrompt := and (not $noPrompt) (and $hasSinglePosArg $serviceHasNamedIdMap) -}}
|
{{- $hasIdPrompt := and (not $noPrompt) (and $hasSinglePosArg $serviceHasNamedIdMap) -}}
|
||||||
{{- $wait := and .Wait (and (not .IsCrudRead) (not (eq .SnakeName "get_run"))) -}}
|
{{- $wait := and .Wait (and (not .IsCrudRead) (not (eq .SnakeName "get_run"))) -}}
|
||||||
{{- $hasRequiredArgs := and (not $hasIdPrompt) $hasPosArgs -}}
|
{{- $hasRequiredArgs := and (not $hasIdPrompt) $hasPosArgs -}}
|
||||||
{{- $hasSingleRequiredRequestBodyFieldWithPrompt := and (and $hasIdPrompt .Request) (eq 1 (len .Request.RequiredRequestBodyFields)) -}}
|
{{- $hasSingleRequiredRequestBodyFieldWithPrompt := and (and $hasIdPrompt $request) (eq 1 (len $request.RequiredRequestBodyFields)) -}}
|
||||||
{{- $onlyPathArgsRequiredAsPositionalArguments := and .Request (eq (len .RequiredPositionalArguments) (len .Request.RequiredPathFields)) -}}
|
{{- $onlyPathArgsRequiredAsPositionalArguments := and $request (eq (len .RequiredPositionalArguments) (len $request.RequiredPathFields)) -}}
|
||||||
{{- $hasDifferentArgsWithJsonFlag := and (not $onlyPathArgsRequiredAsPositionalArguments) (and .CanUseJson .Request.HasRequiredRequestBodyFields) -}}
|
{{- $hasDifferentArgsWithJsonFlag := and (not $onlyPathArgsRequiredAsPositionalArguments) (and .CanUseJson (or $request.HasRequiredRequestBodyFields )) -}}
|
||||||
{{- $hasCustomArgHandler := or $hasRequiredArgs $hasDifferentArgsWithJsonFlag -}}
|
{{- $hasCustomArgHandler := or $hasRequiredArgs $hasDifferentArgsWithJsonFlag -}}
|
||||||
|
|
||||||
{{- $atleastOneArgumentWithDescription := false -}}
|
{{- $atleastOneArgumentWithDescription := false -}}
|
||||||
|
@ -209,12 +214,12 @@ func new{{.PascalName}}() *cobra.Command {
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
{{- if $hasDifferentArgsWithJsonFlag }}
|
{{- if $hasDifferentArgsWithJsonFlag }}
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err := root.ExactArgs({{len .Request.RequiredPathFields}})(cmd, args)
|
err := root.ExactArgs({{len $request.RequiredPathFields}})(cmd, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
{{- if eq 0 (len .Request.RequiredPathFields) }}
|
{{- if eq 0 (len $request.RequiredPathFields) }}
|
||||||
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide{{- range $index, $field := .Request.RequiredFields}}{{if $index}},{{end}} '{{$field.Name}}'{{end}} in your JSON input")
|
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide{{- range $index, $field := $request.RequiredFields}}{{if $index}},{{end}} '{{$field.Name}}'{{end}} in your JSON input")
|
||||||
{{- else }}
|
{{- else }}
|
||||||
return fmt.Errorf("when --json flag is specified, provide only{{- range $index, $field := .Request.RequiredPathFields}}{{if $index}},{{end}} {{$field.ConstantName}}{{end}} as positional arguments. Provide{{- range $index, $field := .Request.RequiredRequestBodyFields}}{{if $index}},{{end}} '{{$field.Name}}'{{end}} in your JSON input")
|
return fmt.Errorf("when --json flag is specified, provide only{{- range $index, $field := $request.RequiredPathFields}}{{if $index}},{{end}} {{$field.ConstantName}}{{end}} as positional arguments. Provide{{- range $index, $field := $request.RequiredRequestBodyFields}}{{if $index}},{{end}} '{{$field.Name}}'{{end}} in your JSON input")
|
||||||
{{- end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -254,20 +259,20 @@ func new{{.PascalName}}() *cobra.Command {
|
||||||
{{- if $hasIdPrompt}}
|
{{- if $hasIdPrompt}}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No{{range .Request.RequiredFields}} {{.ConstantName}}{{end}} argument specified. Loading names for {{.Service.TitleName}} drop-down."
|
promptSpinner <- "No{{range $request.RequiredFields}} {{.ConstantName}}{{end}} argument specified. Loading names for {{.Service.TitleName}} drop-down."
|
||||||
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}})
|
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)
|
close(promptSpinner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to load names for {{.Service.TitleName}} drop-down. Please manually specify required arguments. Original error: %w", 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}}")
|
id, err := cmdio.Select(ctx, names, "{{range $request.RequiredFields}}{{.Summary | trimSuffix "."}}{{end}}")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
args = append(args, id)
|
args = append(args, id)
|
||||||
}
|
}
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
return fmt.Errorf("expected to have {{range .Request.RequiredFields}}{{.Summary | trimSuffix "." | lower}}{{end}}")
|
return fmt.Errorf("expected to have {{range $request.RequiredFields}}{{.Summary | trimSuffix "." | lower}}{{end}}")
|
||||||
}
|
}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
@ -391,13 +396,19 @@ func new{{.PascalName}}() *cobra.Command {
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{if not $field.Entity.IsString -}}
|
{{if not $field.Entity.IsString -}}
|
||||||
_, err = fmt.Sscan(args[{{$arg}}], &{{$method.CamelName}}Req.{{$field.PascalName}})
|
_, err = fmt.Sscan(args[{{$arg}}], &{{- template "request-body-obj" (dict "Method" $method "Field" $field)}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid {{$field.ConstantName}}: %s", args[{{$arg}}])
|
return fmt.Errorf("invalid {{$field.ConstantName}}: %s", args[{{$arg}}])
|
||||||
}{{else -}}
|
}{{else -}}
|
||||||
{{$method.CamelName}}Req.{{ if $method.RequestBodyField }}{{$method.RequestBodyField.PascalName}}.{{end}}{{$field.PascalName}} = args[{{$arg}}]
|
{{- template "request-body-obj" (dict "Method" $method "Field" $field)}} = args[{{$arg}}]
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- if $optionalIfJsonIsUsed }}
|
{{- if $optionalIfJsonIsUsed }}
|
||||||
}
|
}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "request-body-obj" -}}
|
||||||
|
{{- $method := .Method -}}
|
||||||
|
{{- $field := .Field -}}
|
||||||
|
{{$method.CamelName}}Req{{ if (and $method.RequestBodyField (not $field.IsPath)) }}.{{$method.RequestBodyField.PascalName}}{{end}}.{{$field.PascalName}}
|
||||||
|
{{- end -}}
|
||||||
|
|
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -1,5 +1,26 @@
|
||||||
# Version changelog
|
# Version changelog
|
||||||
|
|
||||||
|
## [Release] Release v0.233.0
|
||||||
|
|
||||||
|
CLI:
|
||||||
|
* Clean host URL in the `auth login` command ([#1879](https://github.com/databricks/cli/pull/1879)).
|
||||||
|
|
||||||
|
Bundles:
|
||||||
|
* Fix bundle run when run interactively ([#1880](https://github.com/databricks/cli/pull/1880)).
|
||||||
|
* Fix relative path resolution for dashboards on Windows ([#1881](https://github.com/databricks/cli/pull/1881)).
|
||||||
|
|
||||||
|
Internal:
|
||||||
|
* Address goreleaser deprecation warning ([#1872](https://github.com/databricks/cli/pull/1872)).
|
||||||
|
* Update actions/github-script to v7 ([#1873](https://github.com/databricks/cli/pull/1873)).
|
||||||
|
* Use Go 1.23 ([#1871](https://github.com/databricks/cli/pull/1871)).
|
||||||
|
* [Internal] Always write message for manual integration test trigger ([#1874](https://github.com/databricks/cli/pull/1874)).
|
||||||
|
* Add `cmd-exec-id` to user agent ([#1808](https://github.com/databricks/cli/pull/1808)).
|
||||||
|
* Added E2E test to run Python wheels on interactive cluster created in bundle ([#1864](https://github.com/databricks/cli/pull/1864)).
|
||||||
|
|
||||||
|
|
||||||
|
Dependency updates:
|
||||||
|
* Bump github.com/hashicorp/terraform-json from 0.22.1 to 0.23.0 ([#1877](https://github.com/databricks/cli/pull/1877)).
|
||||||
|
|
||||||
## [Release] Release v0.232.1
|
## [Release] Release v0.232.1
|
||||||
|
|
||||||
This patch release fixes the following error observed when deploying to /Shared root folder
|
This patch release fixes the following error observed when deploying to /Shared root folder
|
||||||
|
|
|
@ -163,7 +163,7 @@ func (t *translateContext) translateNoOp(literal, localFullPath, localRelPath, r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *translateContext) retainLocalAbsoluteFilePath(literal, localFullPath, localRelPath, remotePath string) (string, error) {
|
func (t *translateContext) retainLocalAbsoluteFilePath(literal, localFullPath, localRelPath, remotePath string) (string, error) {
|
||||||
info, err := t.b.SyncRoot.Stat(localRelPath)
|
info, err := t.b.SyncRoot.Stat(filepath.ToSlash(localRelPath))
|
||||||
if errors.Is(err, fs.ErrNotExist) {
|
if errors.Is(err, fs.ErrNotExist) {
|
||||||
return "", fmt.Errorf("file %s not found", literal)
|
return "", fmt.Errorf("file %s not found", literal)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package mutator_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/bundle/config"
|
||||||
|
"github.com/databricks/cli/bundle/config/mutator"
|
||||||
|
"github.com/databricks/cli/bundle/config/resources"
|
||||||
|
"github.com/databricks/cli/bundle/internal/bundletest"
|
||||||
|
"github.com/databricks/cli/libs/dyn"
|
||||||
|
"github.com/databricks/cli/libs/vfs"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/dashboards"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestTranslatePathsDashboards_FilePathRelativeSubDirectory(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
touchEmptyFile(t, filepath.Join(dir, "src", "my_dashboard.lvdash.json"))
|
||||||
|
|
||||||
|
b := &bundle.Bundle{
|
||||||
|
SyncRootPath: dir,
|
||||||
|
SyncRoot: vfs.MustNew(dir),
|
||||||
|
Config: config.Root{
|
||||||
|
Resources: config.Resources{
|
||||||
|
Dashboards: map[string]*resources.Dashboard{
|
||||||
|
"dashboard": {
|
||||||
|
Dashboard: &dashboards.Dashboard{
|
||||||
|
DisplayName: "My Dashboard",
|
||||||
|
},
|
||||||
|
FilePath: "../src/my_dashboard.lvdash.json",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
bundletest.SetLocation(b, "resources.dashboards", []dyn.Location{{
|
||||||
|
File: filepath.Join(dir, "resources/dashboard.yml"),
|
||||||
|
}})
|
||||||
|
|
||||||
|
diags := bundle.Apply(context.Background(), b, mutator.TranslatePaths())
|
||||||
|
require.NoError(t, diags.Error())
|
||||||
|
|
||||||
|
// Assert that the file path for the dashboard has been converted to its local absolute path.
|
||||||
|
assert.Equal(
|
||||||
|
t,
|
||||||
|
filepath.Join(dir, "src", "my_dashboard.lvdash.json"),
|
||||||
|
b.Config.Resources.Dashboards["dashboard"].FilePath,
|
||||||
|
)
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/bundle/config/mutator"
|
||||||
"github.com/databricks/cli/bundle/phases"
|
"github.com/databricks/cli/bundle/phases"
|
||||||
"github.com/databricks/cli/cmd/bundle/utils"
|
"github.com/databricks/cli/cmd/bundle/utils"
|
||||||
"github.com/databricks/cli/cmd/root"
|
"github.com/databricks/cli/cmd/root"
|
||||||
|
@ -62,7 +63,12 @@ func newDestroyCommand() *cobra.Command {
|
||||||
|
|
||||||
diags = bundle.Apply(ctx, b, bundle.Seq(
|
diags = bundle.Apply(ctx, b, bundle.Seq(
|
||||||
phases.Initialize(),
|
phases.Initialize(),
|
||||||
phases.Build(),
|
// We need to resolve artifact variable (how we do it in build phase)
|
||||||
|
// because some of the to-be-destroyed resource might use this variable.
|
||||||
|
// Not resolving might lead to terraform "Reference to undeclared resource" error
|
||||||
|
mutator.ResolveVariableReferences(
|
||||||
|
"artifacts",
|
||||||
|
),
|
||||||
phases.Destroy(),
|
phases.Destroy(),
|
||||||
))
|
))
|
||||||
if err := diags.Error(); err != nil {
|
if err := diags.Error(); err != nil {
|
||||||
|
|
|
@ -35,17 +35,23 @@ func promptRunArgument(ctx context.Context, b *bundle.Bundle) (string, error) {
|
||||||
return key, nil
|
return key, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolveRunArgument(ctx context.Context, b *bundle.Bundle, args []string) (string, error) {
|
// resolveRunArgument resolves the resource key to run.
|
||||||
|
// It returns the remaining arguments to pass to the runner, if applicable.
|
||||||
|
func resolveRunArgument(ctx context.Context, b *bundle.Bundle, args []string) (string, []string, error) {
|
||||||
// If no arguments are specified, prompt the user to select something to run.
|
// If no arguments are specified, prompt the user to select something to run.
|
||||||
if len(args) == 0 && cmdio.IsPromptSupported(ctx) {
|
if len(args) == 0 && cmdio.IsPromptSupported(ctx) {
|
||||||
return promptRunArgument(ctx, b)
|
key, err := promptRunArgument(ctx, b)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
return key, args, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
return "", fmt.Errorf("expected a KEY of the resource to run")
|
return "", nil, fmt.Errorf("expected a KEY of the resource to run")
|
||||||
}
|
}
|
||||||
|
|
||||||
return args[0], nil
|
return args[0], args[1:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func keyToRunner(b *bundle.Bundle, arg string) (run.Runner, error) {
|
func keyToRunner(b *bundle.Bundle, arg string) (run.Runner, error) {
|
||||||
|
@ -109,7 +115,7 @@ task or a Python wheel task, the second example applies.
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
arg, err := resolveRunArgument(ctx, b, args)
|
key, args, err := resolveRunArgument(ctx, b, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -124,13 +130,13 @@ task or a Python wheel task, the second example applies.
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
runner, err := keyToRunner(b, arg)
|
runner, err := keyToRunner(b, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse additional positional arguments.
|
// Parse additional positional arguments.
|
||||||
err = runner.ParseArgs(args[1:], &runOptions)
|
err = runner.ParseArgs(args, &runOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,13 @@ func newCreate() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: complex arg: app
|
// TODO: complex arg: active_deployment
|
||||||
|
// TODO: complex arg: app_status
|
||||||
|
// TODO: complex arg: compute_status
|
||||||
|
cmd.Flags().StringVar(&createReq.App.DefaultSourceCodePath, "default-source-code-path", createReq.App.DefaultSourceCodePath, `The default workspace file system path of the source code from which app deployment are created.`)
|
||||||
|
cmd.Flags().StringVar(&createReq.App.Description, "description", createReq.App.Description, `The description of the app.`)
|
||||||
|
// TODO: complex arg: pending_deployment
|
||||||
|
// TODO: array: resources
|
||||||
|
|
||||||
cmd.Use = "create NAME"
|
cmd.Use = "create NAME"
|
||||||
cmd.Short = `Create an app.`
|
cmd.Short = `Create an app.`
|
||||||
|
@ -93,6 +99,13 @@ func newCreate() *cobra.Command {
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err := root.ExactArgs(0)(cmd, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'name' in your JSON input")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
check := root.ExactArgs(1)
|
check := root.ExactArgs(1)
|
||||||
return check(cmd, args)
|
return check(cmd, args)
|
||||||
}
|
}
|
||||||
|
@ -238,18 +251,25 @@ func newDeploy() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&deployJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&deployJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: complex arg: app_deployment
|
// TODO: complex arg: deployment_artifacts
|
||||||
|
cmd.Flags().StringVar(&deployReq.AppDeployment.DeploymentId, "deployment-id", deployReq.AppDeployment.DeploymentId, `The unique id of the deployment.`)
|
||||||
|
cmd.Flags().Var(&deployReq.AppDeployment.Mode, "mode", `The mode of which the deployment will manage the source code. Supported values: [AUTO_SYNC, SNAPSHOT]`)
|
||||||
|
cmd.Flags().StringVar(&deployReq.AppDeployment.SourceCodePath, "source-code-path", deployReq.AppDeployment.SourceCodePath, `The workspace file system path of the source code used to create the app deployment.`)
|
||||||
|
// TODO: complex arg: status
|
||||||
|
|
||||||
cmd.Use = "deploy"
|
cmd.Use = "deploy APP_NAME"
|
||||||
cmd.Short = `Create an app deployment.`
|
cmd.Short = `Create an app deployment.`
|
||||||
cmd.Long = `Create an app deployment.
|
cmd.Long = `Create an app deployment.
|
||||||
|
|
||||||
Creates an app deployment for the app with the supplied name.`
|
Creates an app deployment for the app with the supplied name.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
APP_NAME: The name of the app.`
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
check := root.ExactArgs(0)
|
check := root.ExactArgs(1)
|
||||||
return check(cmd, args)
|
return check(cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,6 +290,7 @@ func newDeploy() *cobra.Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
deployReq.AppName = args[0]
|
||||||
|
|
||||||
wait, err := w.Apps.Deploy(ctx, deployReq)
|
wait, err := w.Apps.Deploy(ctx, deployReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -914,22 +935,36 @@ func newUpdate() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: complex arg: app
|
// TODO: complex arg: active_deployment
|
||||||
|
// TODO: complex arg: app_status
|
||||||
|
// TODO: complex arg: compute_status
|
||||||
|
cmd.Flags().StringVar(&updateReq.App.DefaultSourceCodePath, "default-source-code-path", updateReq.App.DefaultSourceCodePath, `The default workspace file system path of the source code from which app deployment are created.`)
|
||||||
|
cmd.Flags().StringVar(&updateReq.App.Description, "description", updateReq.App.Description, `The description of the app.`)
|
||||||
|
// TODO: complex arg: pending_deployment
|
||||||
|
// TODO: array: resources
|
||||||
|
|
||||||
cmd.Use = "update NAME"
|
cmd.Use = "update NAME NAME"
|
||||||
cmd.Short = `Update an app.`
|
cmd.Short = `Update an app.`
|
||||||
cmd.Long = `Update an app.
|
cmd.Long = `Update an app.
|
||||||
|
|
||||||
Updates the app with the supplied name.
|
Updates the app with the supplied name.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
NAME: The name of the app.
|
||||||
NAME: The name of the app. The name must contain only lowercase alphanumeric
|
NAME: The name of the app. The name must contain only lowercase alphanumeric
|
||||||
characters and hyphens. It must be unique within the workspace.`
|
characters and hyphens. It must be unique within the workspace.`
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
check := root.ExactArgs(1)
|
if cmd.Flags().Changed("json") {
|
||||||
|
err := root.ExactArgs(0)(cmd, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'name' in your JSON input")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
check := root.ExactArgs(2)
|
||||||
return check(cmd, args)
|
return check(cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,8 +985,9 @@ func newUpdate() *cobra.Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateReq.Name = args[0]
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
updateReq.App.Name = args[0]
|
updateReq.App.Name = args[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := w.Apps.Update(ctx, updateReq)
|
response, err := w.Apps.Update(ctx, updateReq)
|
||||||
|
|
|
@ -76,7 +76,10 @@ func newCreate() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: complex arg: dashboard
|
cmd.Flags().StringVar(&createReq.Dashboard.DisplayName, "display-name", createReq.Dashboard.DisplayName, `The display name of the dashboard.`)
|
||||||
|
cmd.Flags().Var(&createReq.Dashboard.LifecycleState, "lifecycle-state", `The state of the dashboard resource. Supported values: [ACTIVE, TRASHED]`)
|
||||||
|
cmd.Flags().StringVar(&createReq.Dashboard.SerializedDashboard, "serialized-dashboard", createReq.Dashboard.SerializedDashboard, `The contents of the dashboard in serialized string form.`)
|
||||||
|
cmd.Flags().StringVar(&createReq.Dashboard.WarehouseId, "warehouse-id", createReq.Dashboard.WarehouseId, `The warehouse ID used to run the dashboard.`)
|
||||||
|
|
||||||
cmd.Use = "create"
|
cmd.Use = "create"
|
||||||
cmd.Short = `Create dashboard.`
|
cmd.Short = `Create dashboard.`
|
||||||
|
@ -147,17 +150,33 @@ func newCreateSchedule() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&createScheduleJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&createScheduleJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: complex arg: schedule
|
cmd.Flags().StringVar(&createScheduleReq.Schedule.DisplayName, "display-name", createScheduleReq.Schedule.DisplayName, `The display name for schedule.`)
|
||||||
|
cmd.Flags().Var(&createScheduleReq.Schedule.PauseStatus, "pause-status", `The status indicates whether this schedule is paused or not. Supported values: [PAUSED, UNPAUSED]`)
|
||||||
|
|
||||||
cmd.Use = "create-schedule"
|
cmd.Use = "create-schedule DASHBOARD_ID"
|
||||||
cmd.Short = `Create dashboard schedule.`
|
cmd.Short = `Create dashboard schedule.`
|
||||||
cmd.Long = `Create dashboard schedule.`
|
cmd.Long = `Create dashboard schedule.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
DASHBOARD_ID: UUID identifying the dashboard to which the schedule belongs.`
|
||||||
|
|
||||||
// This command is being previewed; hide from help output.
|
// This command is being previewed; hide from help output.
|
||||||
cmd.Hidden = true
|
cmd.Hidden = true
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err := root.ExactArgs(0)(cmd, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'cron_schedule' in your JSON input")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
check := root.ExactArgs(1)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
cmd.PreRunE = root.MustWorkspaceClient
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
@ -175,6 +194,7 @@ func newCreateSchedule() *cobra.Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
createScheduleReq.DashboardId = args[0]
|
||||||
|
|
||||||
response, err := w.Lakeview.CreateSchedule(ctx, createScheduleReq)
|
response, err := w.Lakeview.CreateSchedule(ctx, createScheduleReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -214,17 +234,31 @@ func newCreateSubscription() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&createSubscriptionJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&createSubscriptionJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: complex arg: subscription
|
cmd.Use = "create-subscription DASHBOARD_ID SCHEDULE_ID"
|
||||||
|
|
||||||
cmd.Use = "create-subscription"
|
|
||||||
cmd.Short = `Create schedule subscription.`
|
cmd.Short = `Create schedule subscription.`
|
||||||
cmd.Long = `Create schedule subscription.`
|
cmd.Long = `Create schedule subscription.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
DASHBOARD_ID: UUID identifying the dashboard to which the subscription belongs.
|
||||||
|
SCHEDULE_ID: UUID identifying the schedule to which the subscription belongs.`
|
||||||
|
|
||||||
// This command is being previewed; hide from help output.
|
// This command is being previewed; hide from help output.
|
||||||
cmd.Hidden = true
|
cmd.Hidden = true
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err := root.ExactArgs(0)(cmd, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'subscriber' in your JSON input")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
check := root.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
cmd.PreRunE = root.MustWorkspaceClient
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
@ -242,6 +276,8 @@ func newCreateSubscription() *cobra.Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
createSubscriptionReq.DashboardId = args[0]
|
||||||
|
createSubscriptionReq.ScheduleId = args[1]
|
||||||
|
|
||||||
response, err := w.Lakeview.CreateSubscription(ctx, createSubscriptionReq)
|
response, err := w.Lakeview.CreateSubscription(ctx, createSubscriptionReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -278,8 +314,6 @@ func newDeleteSchedule() *cobra.Command {
|
||||||
|
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
|
|
||||||
cmd.Flags().StringVar(&deleteScheduleReq.Etag, "etag", deleteScheduleReq.Etag, `The etag for the schedule.`)
|
|
||||||
|
|
||||||
cmd.Use = "delete-schedule DASHBOARD_ID SCHEDULE_ID"
|
cmd.Use = "delete-schedule DASHBOARD_ID SCHEDULE_ID"
|
||||||
cmd.Short = `Delete dashboard schedule.`
|
cmd.Short = `Delete dashboard schedule.`
|
||||||
cmd.Long = `Delete dashboard schedule.
|
cmd.Long = `Delete dashboard schedule.
|
||||||
|
@ -341,8 +375,6 @@ func newDeleteSubscription() *cobra.Command {
|
||||||
|
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
|
|
||||||
cmd.Flags().StringVar(&deleteSubscriptionReq.Etag, "etag", deleteSubscriptionReq.Etag, `The etag for the subscription.`)
|
|
||||||
|
|
||||||
cmd.Use = "delete-subscription DASHBOARD_ID SCHEDULE_ID SUBSCRIPTION_ID"
|
cmd.Use = "delete-subscription DASHBOARD_ID SCHEDULE_ID SUBSCRIPTION_ID"
|
||||||
cmd.Short = `Delete schedule subscription.`
|
cmd.Short = `Delete schedule subscription.`
|
||||||
cmd.Long = `Delete schedule subscription.
|
cmd.Long = `Delete schedule subscription.
|
||||||
|
@ -647,7 +679,6 @@ func newList() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
|
|
||||||
cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `The number of dashboards to return per page.`)
|
cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `The number of dashboards to return per page.`)
|
||||||
cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `A page token, received from a previous ListDashboards call.`)
|
|
||||||
cmd.Flags().BoolVar(&listReq.ShowTrashed, "show-trashed", listReq.ShowTrashed, `The flag to include dashboards located in the trash.`)
|
cmd.Flags().BoolVar(&listReq.ShowTrashed, "show-trashed", listReq.ShowTrashed, `The flag to include dashboards located in the trash.`)
|
||||||
cmd.Flags().Var(&listReq.View, "view", `DASHBOARD_VIEW_BASIConly includes summary metadata from the dashboard. Supported values: [DASHBOARD_VIEW_BASIC]`)
|
cmd.Flags().Var(&listReq.View, "view", `DASHBOARD_VIEW_BASIConly includes summary metadata from the dashboard. Supported values: [DASHBOARD_VIEW_BASIC]`)
|
||||||
|
|
||||||
|
@ -700,7 +731,6 @@ func newListSchedules() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
|
|
||||||
cmd.Flags().IntVar(&listSchedulesReq.PageSize, "page-size", listSchedulesReq.PageSize, `The number of schedules to return per page.`)
|
cmd.Flags().IntVar(&listSchedulesReq.PageSize, "page-size", listSchedulesReq.PageSize, `The number of schedules to return per page.`)
|
||||||
cmd.Flags().StringVar(&listSchedulesReq.PageToken, "page-token", listSchedulesReq.PageToken, `A page token, received from a previous ListSchedules call.`)
|
|
||||||
|
|
||||||
cmd.Use = "list-schedules DASHBOARD_ID"
|
cmd.Use = "list-schedules DASHBOARD_ID"
|
||||||
cmd.Short = `List dashboard schedules.`
|
cmd.Short = `List dashboard schedules.`
|
||||||
|
@ -759,7 +789,6 @@ func newListSubscriptions() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
|
|
||||||
cmd.Flags().IntVar(&listSubscriptionsReq.PageSize, "page-size", listSubscriptionsReq.PageSize, `The number of subscriptions to return per page.`)
|
cmd.Flags().IntVar(&listSubscriptionsReq.PageSize, "page-size", listSubscriptionsReq.PageSize, `The number of subscriptions to return per page.`)
|
||||||
cmd.Flags().StringVar(&listSubscriptionsReq.PageToken, "page-token", listSubscriptionsReq.PageToken, `A page token, received from a previous ListSubscriptions call.`)
|
|
||||||
|
|
||||||
cmd.Use = "list-subscriptions DASHBOARD_ID SCHEDULE_ID"
|
cmd.Use = "list-subscriptions DASHBOARD_ID SCHEDULE_ID"
|
||||||
cmd.Short = `List schedule subscriptions.`
|
cmd.Short = `List schedule subscriptions.`
|
||||||
|
@ -1097,18 +1126,24 @@ func newUpdate() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: complex arg: dashboard
|
cmd.Flags().StringVar(&updateReq.Dashboard.DisplayName, "display-name", updateReq.Dashboard.DisplayName, `The display name of the dashboard.`)
|
||||||
|
cmd.Flags().Var(&updateReq.Dashboard.LifecycleState, "lifecycle-state", `The state of the dashboard resource. Supported values: [ACTIVE, TRASHED]`)
|
||||||
|
cmd.Flags().StringVar(&updateReq.Dashboard.SerializedDashboard, "serialized-dashboard", updateReq.Dashboard.SerializedDashboard, `The contents of the dashboard in serialized string form.`)
|
||||||
|
cmd.Flags().StringVar(&updateReq.Dashboard.WarehouseId, "warehouse-id", updateReq.Dashboard.WarehouseId, `The warehouse ID used to run the dashboard.`)
|
||||||
|
|
||||||
cmd.Use = "update"
|
cmd.Use = "update DASHBOARD_ID"
|
||||||
cmd.Short = `Update dashboard.`
|
cmd.Short = `Update dashboard.`
|
||||||
cmd.Long = `Update dashboard.
|
cmd.Long = `Update dashboard.
|
||||||
|
|
||||||
Update a draft dashboard.`
|
Update a draft dashboard.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
DASHBOARD_ID: UUID identifying the dashboard.`
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
check := root.ExactArgs(0)
|
check := root.ExactArgs(1)
|
||||||
return check(cmd, args)
|
return check(cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1129,6 +1164,7 @@ func newUpdate() *cobra.Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateReq.DashboardId = args[0]
|
||||||
|
|
||||||
response, err := w.Lakeview.Update(ctx, updateReq)
|
response, err := w.Lakeview.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1168,17 +1204,34 @@ func newUpdateSchedule() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&updateScheduleJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&updateScheduleJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: complex arg: schedule
|
cmd.Flags().StringVar(&updateScheduleReq.Schedule.DisplayName, "display-name", updateScheduleReq.Schedule.DisplayName, `The display name for schedule.`)
|
||||||
|
cmd.Flags().Var(&updateScheduleReq.Schedule.PauseStatus, "pause-status", `The status indicates whether this schedule is paused or not. Supported values: [PAUSED, UNPAUSED]`)
|
||||||
|
|
||||||
cmd.Use = "update-schedule"
|
cmd.Use = "update-schedule DASHBOARD_ID SCHEDULE_ID"
|
||||||
cmd.Short = `Update dashboard schedule.`
|
cmd.Short = `Update dashboard schedule.`
|
||||||
cmd.Long = `Update dashboard schedule.`
|
cmd.Long = `Update dashboard schedule.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
DASHBOARD_ID: UUID identifying the dashboard to which the schedule belongs.
|
||||||
|
SCHEDULE_ID: UUID identifying the schedule.`
|
||||||
|
|
||||||
// This command is being previewed; hide from help output.
|
// This command is being previewed; hide from help output.
|
||||||
cmd.Hidden = true
|
cmd.Hidden = true
|
||||||
|
|
||||||
cmd.Annotations = make(map[string]string)
|
cmd.Annotations = make(map[string]string)
|
||||||
|
|
||||||
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
|
if cmd.Flags().Changed("json") {
|
||||||
|
err := root.ExactArgs(0)(cmd, args)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'cron_schedule' in your JSON input")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
check := root.ExactArgs(2)
|
||||||
|
return check(cmd, args)
|
||||||
|
}
|
||||||
|
|
||||||
cmd.PreRunE = root.MustWorkspaceClient
|
cmd.PreRunE = root.MustWorkspaceClient
|
||||||
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
@ -1196,6 +1249,8 @@ func newUpdateSchedule() *cobra.Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateScheduleReq.DashboardId = args[0]
|
||||||
|
updateScheduleReq.ScheduleId = args[1]
|
||||||
|
|
||||||
response, err := w.Lakeview.UpdateSchedule(ctx, updateScheduleReq)
|
response, err := w.Lakeview.UpdateSchedule(ctx, updateScheduleReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -66,7 +66,10 @@ func newCreate() *cobra.Command {
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
||||||
|
|
||||||
// TODO: complex arg: table
|
cmd.Flags().StringVar(&createReq.Table.Name, "name", createReq.Table.Name, `Full three-part (catalog, schema, table) name of the table.`)
|
||||||
|
// TODO: complex arg: spec
|
||||||
|
// TODO: complex arg: status
|
||||||
|
cmd.Flags().Var(&createReq.Table.UnityCatalogProvisioningState, "unity-catalog-provisioning-state", `The provisioning state of the online table entity in Unity Catalog. Supported values: [ACTIVE, DELETING, FAILED, PROVISIONING, UPDATING]`)
|
||||||
|
|
||||||
cmd.Use = "create"
|
cmd.Use = "create"
|
||||||
cmd.Short = `Create an Online Table.`
|
cmd.Short = `Create an Online Table.`
|
||||||
|
|
|
@ -391,7 +391,6 @@ func newUpdate() *cobra.Command {
|
||||||
|
|
||||||
cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `User-provided free-form text description.`)
|
cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `User-provided free-form text description.`)
|
||||||
cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the share.`)
|
cmd.Flags().StringVar(&updateReq.NewName, "new-name", updateReq.NewName, `New name for the share.`)
|
||||||
cmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of share.`)
|
|
||||||
cmd.Flags().StringVar(&updateReq.StorageRoot, "storage-root", updateReq.StorageRoot, `Storage root URL for the share.`)
|
cmd.Flags().StringVar(&updateReq.StorageRoot, "storage-root", updateReq.StorageRoot, `Storage root URL for the share.`)
|
||||||
// TODO: array: updates
|
// TODO: array: updates
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -143,6 +144,26 @@ func (a *PersistentAuth) Challenge(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function cleans up the host URL by only retaining the scheme and the host.
|
||||||
|
// This function thus removes any path, query arguments, or fragments from the URL.
|
||||||
|
func (a *PersistentAuth) cleanHost() {
|
||||||
|
parsedHost, err := url.Parse(a.Host)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// when either host or scheme is empty, we don't want to clean it. This is because
|
||||||
|
// the Go url library parses a raw "abc" string as the path of a URL and cleaning
|
||||||
|
// it will return thus return an empty string.
|
||||||
|
if parsedHost.Host == "" || parsedHost.Scheme == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
host := url.URL{
|
||||||
|
Scheme: parsedHost.Scheme,
|
||||||
|
Host: parsedHost.Host,
|
||||||
|
}
|
||||||
|
a.Host = host.String()
|
||||||
|
}
|
||||||
|
|
||||||
func (a *PersistentAuth) init(ctx context.Context) error {
|
func (a *PersistentAuth) init(ctx context.Context) error {
|
||||||
if a.Host == "" && a.AccountID == "" {
|
if a.Host == "" && a.AccountID == "" {
|
||||||
return ErrFetchCredentials
|
return ErrFetchCredentials
|
||||||
|
@ -156,6 +177,9 @@ func (a *PersistentAuth) init(ctx context.Context) error {
|
||||||
if a.browser == nil {
|
if a.browser == nil {
|
||||||
a.browser = browser.OpenURL
|
a.browser = browser.OpenURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.cleanHost()
|
||||||
|
|
||||||
// try acquire listener, which we also use as a machine-local
|
// try acquire listener, which we also use as a machine-local
|
||||||
// exclusive lock to prevent token cache corruption in the scope
|
// exclusive lock to prevent token cache corruption in the scope
|
||||||
// of developer machine, where this command runs.
|
// of developer machine, where this command runs.
|
||||||
|
|
|
@ -228,3 +228,37 @@ func TestChallengeFailed(t *testing.T) {
|
||||||
assert.EqualError(t, err, "authorize: access_denied: Policy evaluation failed for this request")
|
assert.EqualError(t, err, "authorize: access_denied: Policy evaluation failed for this request")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPersistentAuthCleanHost(t *testing.T) {
|
||||||
|
for _, tcases := range []struct {
|
||||||
|
in string
|
||||||
|
out string
|
||||||
|
}{
|
||||||
|
{"https://example.com", "https://example.com"},
|
||||||
|
{"https://example.com/", "https://example.com"},
|
||||||
|
{"https://example.com/path", "https://example.com"},
|
||||||
|
{"https://example.com/path/subpath", "https://example.com"},
|
||||||
|
{"https://example.com/path?query=1", "https://example.com"},
|
||||||
|
{"https://example.com/path?query=1&other=2", "https://example.com"},
|
||||||
|
{"https://example.com/path#fragment", "https://example.com"},
|
||||||
|
{"https://example.com/path?query=1#fragment", "https://example.com"},
|
||||||
|
{"https://example.com/path?query=1&other=2#fragment", "https://example.com"},
|
||||||
|
{"https://example.com/path/subpath?query=1", "https://example.com"},
|
||||||
|
{"https://example.com/path/subpath?query=1&other=2", "https://example.com"},
|
||||||
|
{"https://example.com/path/subpath#fragment", "https://example.com"},
|
||||||
|
{"https://example.com/path/subpath?query=1#fragment", "https://example.com"},
|
||||||
|
{"https://example.com/path/subpath?query=1&other=2#fragment", "https://example.com"},
|
||||||
|
{"https://example.com/path?query=1%20value&other=2%20value", "https://example.com"},
|
||||||
|
{"http://example.com/path/subpath?query=1%20value&other=2%20value", "http://example.com"},
|
||||||
|
|
||||||
|
// URLs without scheme should be left as is
|
||||||
|
{"abc", "abc"},
|
||||||
|
{"abc.com/def", "abc.com/def"},
|
||||||
|
} {
|
||||||
|
p := &PersistentAuth{
|
||||||
|
Host: tcases.in,
|
||||||
|
}
|
||||||
|
p.cleanHost()
|
||||||
|
assert.Equal(t, tcases.out, p.Host)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue