mirror of https://github.com/databricks/cli.git
Compare commits
28 Commits
1ba769c68f
...
48b9571f3f
Author | SHA1 | Date |
---|---|---|
|
48b9571f3f | |
|
a559bd05be | |
|
eddaddaf8b | |
|
acac0289c5 | |
|
ab622e65bb | |
|
55a055d0f5 | |
|
60c153c0e7 | |
|
3bab21e72e | |
|
68d69d6e0b | |
|
f8bb3a8d72 | |
|
571076d5e1 | |
|
ca45e53f42 | |
|
ffdbec87cc | |
|
eefda8c198 | |
|
c9770503f8 | |
|
3b1fb6d2df | |
|
0c9c90208f | |
|
c5043c3d9d | |
|
dedec58e41 | |
|
e4d039a1aa | |
|
cc112961ce | |
|
0753dfe2f4 | |
|
ab20624206 | |
|
f0e2981596 | |
|
08a0d083c3 | |
|
845d23ac21 | |
|
b9085de533 | |
|
3270afaff4 |
|
@ -11,6 +11,7 @@
|
||||||
"toolchain": {
|
"toolchain": {
|
||||||
"required": ["go"],
|
"required": ["go"],
|
||||||
"post_generate": [
|
"post_generate": [
|
||||||
|
"go test -timeout 240s -run TestConsistentDatabricksSdkVersion github.com/databricks/cli/internal/build",
|
||||||
"go run ./bundle/internal/schema/*.go ./bundle/schema/jsonschema.json",
|
"go run ./bundle/internal/schema/*.go ./bundle/schema/jsonschema.json",
|
||||||
"echo 'bundle/internal/tf/schema/\\*.go linguist-generated=true' >> ./.gitattributes",
|
"echo 'bundle/internal/tf/schema/\\*.go linguist-generated=true' >> ./.gitattributes",
|
||||||
"echo 'go.sum linguist-generated=true' >> ./.gitattributes",
|
"echo 'go.sum linguist-generated=true' >> ./.gitattributes",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0c86ea6dbd9a730c24ff0d4e509603e476955ac5
|
cf9c61453990df0f9453670f2fe68e1b128647a2
|
|
@ -5,6 +5,7 @@ package {{(.TrimPrefix "account").SnakeName}}
|
||||||
import (
|
import (
|
||||||
"github.com/databricks/cli/libs/cmdio"
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
"github.com/databricks/cli/libs/flags"
|
"github.com/databricks/cli/libs/flags"
|
||||||
|
"github.com/databricks/cli/libs/diag"
|
||||||
"github.com/databricks/cli/cmd/root"
|
"github.com/databricks/cli/cmd/root"
|
||||||
"github.com/databricks/databricks-sdk-go/service/{{.Package.Name}}"
|
"github.com/databricks/databricks-sdk-go/service/{{.Package.Name}}"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -231,10 +232,16 @@ func new{{.PascalName}}() *cobra.Command {
|
||||||
{{- if .Request }}
|
{{- if .Request }}
|
||||||
{{ if .CanUseJson }}
|
{{ if .CanUseJson }}
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req)
|
diags := {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}{{end}}{{ if .MustUseJson }}else {
|
}{{end}}{{ if .MustUseJson }}else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}{{- end}}
|
}{{- end}}
|
||||||
|
|
|
@ -54,6 +54,7 @@ cmd/workspace/dashboards/dashboards.go linguist-generated=true
|
||||||
cmd/workspace/data-sources/data-sources.go linguist-generated=true
|
cmd/workspace/data-sources/data-sources.go linguist-generated=true
|
||||||
cmd/workspace/default-namespace/default-namespace.go linguist-generated=true
|
cmd/workspace/default-namespace/default-namespace.go linguist-generated=true
|
||||||
cmd/workspace/disable-legacy-access/disable-legacy-access.go linguist-generated=true
|
cmd/workspace/disable-legacy-access/disable-legacy-access.go linguist-generated=true
|
||||||
|
cmd/workspace/disable-legacy-dbfs/disable-legacy-dbfs.go linguist-generated=true
|
||||||
cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go linguist-generated=true
|
cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go linguist-generated=true
|
||||||
cmd/workspace/experiments/experiments.go linguist-generated=true
|
cmd/workspace/experiments/experiments.go linguist-generated=true
|
||||||
cmd/workspace/external-locations/external-locations.go linguist-generated=true
|
cmd/workspace/external-locations/external-locations.go linguist-generated=true
|
||||||
|
|
38
CHANGELOG.md
38
CHANGELOG.md
|
@ -1,5 +1,43 @@
|
||||||
# Version changelog
|
# Version changelog
|
||||||
|
|
||||||
|
## [Release] Release v0.231.0
|
||||||
|
|
||||||
|
CLI:
|
||||||
|
* Added JSON input validation for CLI commands ([#1771](https://github.com/databricks/cli/pull/1771)).
|
||||||
|
* Support Git worktrees for `sync` ([#1831](https://github.com/databricks/cli/pull/1831)).
|
||||||
|
|
||||||
|
Bundles:
|
||||||
|
* Add `bundle summary` to display URLs for deployed resources ([#1731](https://github.com/databricks/cli/pull/1731)).
|
||||||
|
* Added a warning when incorrect permissions used for `/Workspace/Shared` bundle root ([#1821](https://github.com/databricks/cli/pull/1821)).
|
||||||
|
* Show actionable errors for collaborative deployment scenarios ([#1386](https://github.com/databricks/cli/pull/1386)).
|
||||||
|
* Fix path to repository-wide exclude file ([#1837](https://github.com/databricks/cli/pull/1837)).
|
||||||
|
* Fixed typo in converting cluster permissions ([#1826](https://github.com/databricks/cli/pull/1826)).
|
||||||
|
* Ignore metastore permission error during template generation ([#1819](https://github.com/databricks/cli/pull/1819)).
|
||||||
|
* Handle normalization of `dyn.KindTime` into an any type ([#1836](https://github.com/databricks/cli/pull/1836)).
|
||||||
|
* Added support for pip options in environment dependencies ([#1842](https://github.com/databricks/cli/pull/1842)).
|
||||||
|
* Fix race condition when restarting continuous jobs ([#1849](https://github.com/databricks/cli/pull/1849)).
|
||||||
|
* Fix pipeline in default-python template not working for certain workspaces ([#1854](https://github.com/databricks/cli/pull/1854)).
|
||||||
|
* Add "output" flag to the bundle sync command ([#1853](https://github.com/databricks/cli/pull/1853)).
|
||||||
|
|
||||||
|
Internal:
|
||||||
|
* Move utility functions dealing with IAM to libs/iamutil ([#1820](https://github.com/databricks/cli/pull/1820)).
|
||||||
|
* Remove unused `IS_OWNER` constant ([#1823](https://github.com/databricks/cli/pull/1823)).
|
||||||
|
* Assert SDK version is consistent in the CLI generation process ([#1814](https://github.com/databricks/cli/pull/1814)).
|
||||||
|
* Fixed unmarshalling json input into `interface{}` type ([#1832](https://github.com/databricks/cli/pull/1832)).
|
||||||
|
* Fix `TestAccFsMkdirWhenFileExistsAtPath` in isolated Azure environments ([#1833](https://github.com/databricks/cli/pull/1833)).
|
||||||
|
* Add behavioral tests for examples from the YAML spec ([#1835](https://github.com/databricks/cli/pull/1835)).
|
||||||
|
* Remove Terraform conversion function that's no longer used ([#1840](https://github.com/databricks/cli/pull/1840)).
|
||||||
|
* Encode assumptions about the dashboards API in a test ([#1839](https://github.com/databricks/cli/pull/1839)).
|
||||||
|
* Add script to make testing of code on branches easier ([#1844](https://github.com/databricks/cli/pull/1844)).
|
||||||
|
|
||||||
|
API Changes:
|
||||||
|
* Added `databricks disable-legacy-dbfs` command group.
|
||||||
|
|
||||||
|
OpenAPI commit cf9c61453990df0f9453670f2fe68e1b128647a2 (2024-10-14)
|
||||||
|
Dependency updates:
|
||||||
|
* Upgrade TF provider to 1.54.0 ([#1852](https://github.com/databricks/cli/pull/1852)).
|
||||||
|
* Bump github.com/databricks/databricks-sdk-go from 0.48.0 to 0.49.0 ([#1843](https://github.com/databricks/cli/pull/1843)).
|
||||||
|
|
||||||
## [Release] Release v0.230.0
|
## [Release] Release v0.230.0
|
||||||
|
|
||||||
Notable changes for Databricks Asset Bundles:
|
Notable changes for Databricks Asset Bundles:
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package mutator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/libs/diag"
|
||||||
|
)
|
||||||
|
|
||||||
|
type initializeURLs struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitializeURLs makes sure the URL field of each resource is configured.
|
||||||
|
// NOTE: since this depends on an extra API call, this mutator adds some extra
|
||||||
|
// latency. As such, it should only be used when needed.
|
||||||
|
// This URL field is used for the output of the 'bundle summary' CLI command.
|
||||||
|
func InitializeURLs() bundle.Mutator {
|
||||||
|
return &initializeURLs{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *initializeURLs) Name() string {
|
||||||
|
return "InitializeURLs"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *initializeURLs) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
||||||
|
workspaceId, err := b.WorkspaceClient().CurrentWorkspaceID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return diag.FromErr(err)
|
||||||
|
}
|
||||||
|
orgId := strconv.FormatInt(workspaceId, 10)
|
||||||
|
host := b.WorkspaceClient().Config.CanonicalHostName()
|
||||||
|
initializeForWorkspace(b, orgId, host)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func initializeForWorkspace(b *bundle.Bundle, orgId string, host string) error {
|
||||||
|
baseURL, err := url.Parse(host)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add ?o=<workspace id> only if <workspace id> wasn't in the subdomain already.
|
||||||
|
// The ?o= is needed when vanity URLs / legacy workspace URLs are used.
|
||||||
|
// If it's not needed we prefer to leave it out since these URLs are rather
|
||||||
|
// long for most terminals.
|
||||||
|
//
|
||||||
|
// See https://docs.databricks.com/en/workspace/workspace-details.html for
|
||||||
|
// further reading about the '?o=' suffix.
|
||||||
|
if !strings.Contains(baseURL.Hostname(), orgId) {
|
||||||
|
values := baseURL.Query()
|
||||||
|
values.Add("o", orgId)
|
||||||
|
baseURL.RawQuery = values.Encode()
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, group := range b.Config.Resources.AllResources() {
|
||||||
|
for _, r := range group.Resources {
|
||||||
|
r.InitializeURL(*baseURL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,130 @@
|
||||||
|
package mutator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/bundle/config"
|
||||||
|
"github.com/databricks/cli/bundle/config/resources"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/catalog"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/compute"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/jobs"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/ml"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/pipelines"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/serving"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestInitializeURLs(t *testing.T) {
|
||||||
|
b := &bundle.Bundle{
|
||||||
|
Config: config.Root{
|
||||||
|
Workspace: config.Workspace{
|
||||||
|
Host: "https://mycompany.databricks.com/",
|
||||||
|
},
|
||||||
|
Resources: config.Resources{
|
||||||
|
Jobs: map[string]*resources.Job{
|
||||||
|
"job1": {
|
||||||
|
ID: "1",
|
||||||
|
JobSettings: &jobs.JobSettings{Name: "job1"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Pipelines: map[string]*resources.Pipeline{
|
||||||
|
"pipeline1": {
|
||||||
|
ID: "3",
|
||||||
|
PipelineSpec: &pipelines.PipelineSpec{Name: "pipeline1"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Experiments: map[string]*resources.MlflowExperiment{
|
||||||
|
"experiment1": {
|
||||||
|
ID: "4",
|
||||||
|
Experiment: &ml.Experiment{Name: "experiment1"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Models: map[string]*resources.MlflowModel{
|
||||||
|
"model1": {
|
||||||
|
ID: "a model uses its name for identifier",
|
||||||
|
Model: &ml.Model{Name: "a model uses its name for identifier"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{
|
||||||
|
"servingendpoint1": {
|
||||||
|
ID: "my_serving_endpoint",
|
||||||
|
CreateServingEndpoint: &serving.CreateServingEndpoint{
|
||||||
|
Name: "my_serving_endpoint",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
RegisteredModels: map[string]*resources.RegisteredModel{
|
||||||
|
"registeredmodel1": {
|
||||||
|
ID: "8",
|
||||||
|
CreateRegisteredModelRequest: &catalog.CreateRegisteredModelRequest{
|
||||||
|
Name: "my_registered_model",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
QualityMonitors: map[string]*resources.QualityMonitor{
|
||||||
|
"qualityMonitor1": {
|
||||||
|
CreateMonitor: &catalog.CreateMonitor{
|
||||||
|
TableName: "catalog.schema.qualityMonitor1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Schemas: map[string]*resources.Schema{
|
||||||
|
"schema1": {
|
||||||
|
ID: "catalog.schema",
|
||||||
|
CreateSchema: &catalog.CreateSchema{
|
||||||
|
Name: "schema",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Clusters: map[string]*resources.Cluster{
|
||||||
|
"cluster1": {
|
||||||
|
ID: "1017-103929-vlr7jzcf",
|
||||||
|
ClusterSpec: &compute.ClusterSpec{
|
||||||
|
ClusterName: "cluster1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedURLs := map[string]string{
|
||||||
|
"job1": "https://mycompany.databricks.com/jobs/1?o=123456",
|
||||||
|
"pipeline1": "https://mycompany.databricks.com/pipelines/3?o=123456",
|
||||||
|
"experiment1": "https://mycompany.databricks.com/ml/experiments/4?o=123456",
|
||||||
|
"model1": "https://mycompany.databricks.com/ml/models/a%20model%20uses%20its%20name%20for%20identifier?o=123456",
|
||||||
|
"servingendpoint1": "https://mycompany.databricks.com/ml/endpoints/my_serving_endpoint?o=123456",
|
||||||
|
"registeredmodel1": "https://mycompany.databricks.com/explore/data/models/8?o=123456",
|
||||||
|
"qualityMonitor1": "https://mycompany.databricks.com/explore/data/catalog/schema/qualityMonitor1?o=123456",
|
||||||
|
"schema1": "https://mycompany.databricks.com/explore/data/catalog/schema?o=123456",
|
||||||
|
"cluster1": "https://mycompany.databricks.com/compute/clusters/1017-103929-vlr7jzcf?o=123456",
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeForWorkspace(b, "123456", "https://mycompany.databricks.com/")
|
||||||
|
|
||||||
|
for _, group := range b.Config.Resources.AllResources() {
|
||||||
|
for key, r := range group.Resources {
|
||||||
|
require.Equal(t, expectedURLs[key], r.GetURL(), "Unexpected URL for "+key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInitializeURLsWithoutOrgId(t *testing.T) {
|
||||||
|
b := &bundle.Bundle{
|
||||||
|
Config: config.Root{
|
||||||
|
Resources: config.Resources{
|
||||||
|
Jobs: map[string]*resources.Job{
|
||||||
|
"job1": {
|
||||||
|
ID: "1",
|
||||||
|
JobSettings: &jobs.JobSettings{Name: "job1"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeForWorkspace(b, "123456", "https://adb-123456.azuredatabricks.net/")
|
||||||
|
|
||||||
|
require.Equal(t, "https://adb-123456.azuredatabricks.net/jobs/1", b.Config.Resources.Jobs["job1"].URL)
|
||||||
|
}
|
|
@ -5,8 +5,8 @@ import (
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
"github.com/databricks/cli/libs/auth"
|
|
||||||
"github.com/databricks/cli/libs/diag"
|
"github.com/databricks/cli/libs/diag"
|
||||||
|
"github.com/databricks/cli/libs/iamutil"
|
||||||
"github.com/databricks/cli/libs/tags"
|
"github.com/databricks/cli/libs/tags"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ func (m *populateCurrentUser) Apply(ctx context.Context, b *bundle.Bundle) diag.
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Config.Workspace.CurrentUser = &config.User{
|
b.Config.Workspace.CurrentUser = &config.User{
|
||||||
ShortName: auth.GetShortUserName(me),
|
ShortName: iamutil.GetShortUserName(me),
|
||||||
User: me,
|
User: me,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
"github.com/databricks/cli/libs/auth"
|
|
||||||
"github.com/databricks/cli/libs/diag"
|
"github.com/databricks/cli/libs/diag"
|
||||||
"github.com/databricks/cli/libs/dyn"
|
"github.com/databricks/cli/libs/dyn"
|
||||||
|
"github.com/databricks/cli/libs/iamutil"
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ func (m *processTargetMode) Apply(ctx context.Context, b *bundle.Bundle) diag.Di
|
||||||
transformDevelopmentMode(ctx, b)
|
transformDevelopmentMode(ctx, b)
|
||||||
return diags
|
return diags
|
||||||
case config.Production:
|
case config.Production:
|
||||||
isPrincipal := auth.IsServicePrincipal(b.Config.Workspace.CurrentUser.UserName)
|
isPrincipal := iamutil.IsServicePrincipal(b.Config.Workspace.CurrentUser.User)
|
||||||
return validateProductionMode(ctx, b, isPrincipal)
|
return validateProductionMode(ctx, b, isPrincipal)
|
||||||
case "":
|
case "":
|
||||||
// No action
|
// No action
|
||||||
|
|
|
@ -699,6 +699,9 @@ func TestTranslatePathJobEnvironments(t *testing.T) {
|
||||||
"../dist/env2.whl",
|
"../dist/env2.whl",
|
||||||
"simplejson",
|
"simplejson",
|
||||||
"/Workspace/Users/foo@bar.com/test.whl",
|
"/Workspace/Users/foo@bar.com/test.whl",
|
||||||
|
"--extra-index-url https://name:token@gitlab.com/api/v4/projects/9876/packages/pypi/simple foobar",
|
||||||
|
"foobar --extra-index-url https://name:token@gitlab.com/api/v4/projects/9876/packages/pypi/simple",
|
||||||
|
"https://foo@bar.com/packages/pypi/simple",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -719,6 +722,9 @@ func TestTranslatePathJobEnvironments(t *testing.T) {
|
||||||
assert.Equal(t, strings.Join([]string{".", "dist", "env2.whl"}, string(os.PathSeparator)), b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[1])
|
assert.Equal(t, strings.Join([]string{".", "dist", "env2.whl"}, string(os.PathSeparator)), b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[1])
|
||||||
assert.Equal(t, "simplejson", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[2])
|
assert.Equal(t, "simplejson", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[2])
|
||||||
assert.Equal(t, "/Workspace/Users/foo@bar.com/test.whl", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[3])
|
assert.Equal(t, "/Workspace/Users/foo@bar.com/test.whl", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[3])
|
||||||
|
assert.Equal(t, "--extra-index-url https://name:token@gitlab.com/api/v4/projects/9876/packages/pypi/simple foobar", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[4])
|
||||||
|
assert.Equal(t, "foobar --extra-index-url https://name:token@gitlab.com/api/v4/projects/9876/packages/pypi/simple", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[5])
|
||||||
|
assert.Equal(t, "https://foo@bar.com/packages/pypi/simple", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[6])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTranslatePathWithComplexVariables(t *testing.T) {
|
func TestTranslatePathWithComplexVariables(t *testing.T) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package config
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle/config/resources"
|
"github.com/databricks/cli/bundle/config/resources"
|
||||||
"github.com/databricks/databricks-sdk-go"
|
"github.com/databricks/databricks-sdk-go"
|
||||||
|
@ -30,6 +31,53 @@ type ConfigResource interface {
|
||||||
// Terraform equivalent name of the resource. For example "databricks_job"
|
// Terraform equivalent name of the resource. For example "databricks_job"
|
||||||
// for jobs and "databricks_pipeline" for pipelines.
|
// for jobs and "databricks_pipeline" for pipelines.
|
||||||
TerraformResourceName() string
|
TerraformResourceName() string
|
||||||
|
|
||||||
|
// GetName returns the in-product name of the resource.
|
||||||
|
GetName() string
|
||||||
|
|
||||||
|
// GetURL returns the URL of the resource.
|
||||||
|
GetURL() string
|
||||||
|
|
||||||
|
// InitializeURL initializes the URL field of the resource.
|
||||||
|
InitializeURL(baseURL url.URL)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResourceGroup represents a group of resources of the same type.
|
||||||
|
// It includes a description of the resource type and a map of resources.
|
||||||
|
type ResourceGroup struct {
|
||||||
|
Description ResourceDescription
|
||||||
|
Resources map[string]ConfigResource
|
||||||
|
}
|
||||||
|
|
||||||
|
// collectResourceMap collects resources of a specific type into a ResourceGroup.
|
||||||
|
func collectResourceMap[T ConfigResource](
|
||||||
|
description ResourceDescription,
|
||||||
|
input map[string]T,
|
||||||
|
) ResourceGroup {
|
||||||
|
resources := make(map[string]ConfigResource)
|
||||||
|
for key, resource := range input {
|
||||||
|
resources[key] = resource
|
||||||
|
}
|
||||||
|
return ResourceGroup{
|
||||||
|
Description: description,
|
||||||
|
Resources: resources,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllResources returns all resources in the bundle grouped by their resource type.
|
||||||
|
func (r *Resources) AllResources() []ResourceGroup {
|
||||||
|
descriptions := SupportedResources()
|
||||||
|
return []ResourceGroup{
|
||||||
|
collectResourceMap(descriptions["jobs"], r.Jobs),
|
||||||
|
collectResourceMap(descriptions["pipelines"], r.Pipelines),
|
||||||
|
collectResourceMap(descriptions["models"], r.Models),
|
||||||
|
collectResourceMap(descriptions["experiments"], r.Experiments),
|
||||||
|
collectResourceMap(descriptions["model_serving_endpoints"], r.ModelServingEndpoints),
|
||||||
|
collectResourceMap(descriptions["registered_models"], r.RegisteredModels),
|
||||||
|
collectResourceMap(descriptions["quality_monitors"], r.QualityMonitors),
|
||||||
|
collectResourceMap(descriptions["schemas"], r.Schemas),
|
||||||
|
collectResourceMap(descriptions["clusters"], r.Clusters),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resources) FindResourceByConfigKey(key string) (ConfigResource, error) {
|
func (r *Resources) FindResourceByConfigKey(key string) (ConfigResource, error) {
|
||||||
|
@ -61,20 +109,71 @@ func (r *Resources) FindResourceByConfigKey(key string) (ConfigResource, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResourceDescription struct {
|
type ResourceDescription struct {
|
||||||
|
// Singular and plural name when used to refer to the configuration.
|
||||||
SingularName string
|
SingularName string
|
||||||
|
PluralName string
|
||||||
|
|
||||||
|
// Singular and plural title when used in summaries / terminal UI.
|
||||||
|
SingularTitle string
|
||||||
|
PluralTitle string
|
||||||
}
|
}
|
||||||
|
|
||||||
// The keys of the map corresponds to the resource key in the bundle configuration.
|
// The keys of the map corresponds to the resource key in the bundle configuration.
|
||||||
func SupportedResources() map[string]ResourceDescription {
|
func SupportedResources() map[string]ResourceDescription {
|
||||||
return map[string]ResourceDescription{
|
return map[string]ResourceDescription{
|
||||||
"jobs": {SingularName: "job"},
|
"jobs": {
|
||||||
"pipelines": {SingularName: "pipeline"},
|
SingularName: "job",
|
||||||
"models": {SingularName: "model"},
|
PluralName: "jobs",
|
||||||
"experiments": {SingularName: "experiment"},
|
SingularTitle: "Job",
|
||||||
"model_serving_endpoints": {SingularName: "model_serving_endpoint"},
|
PluralTitle: "Jobs",
|
||||||
"registered_models": {SingularName: "registered_model"},
|
},
|
||||||
"quality_monitors": {SingularName: "quality_monitor"},
|
"pipelines": {
|
||||||
"schemas": {SingularName: "schema"},
|
SingularName: "pipeline",
|
||||||
"clusters": {SingularName: "cluster"},
|
PluralName: "pipelines",
|
||||||
|
SingularTitle: "Pipeline",
|
||||||
|
PluralTitle: "Pipelines",
|
||||||
|
},
|
||||||
|
"models": {
|
||||||
|
SingularName: "model",
|
||||||
|
PluralName: "models",
|
||||||
|
SingularTitle: "Model",
|
||||||
|
PluralTitle: "Models",
|
||||||
|
},
|
||||||
|
"experiments": {
|
||||||
|
SingularName: "experiment",
|
||||||
|
PluralName: "experiments",
|
||||||
|
SingularTitle: "Experiment",
|
||||||
|
PluralTitle: "Experiments",
|
||||||
|
},
|
||||||
|
"model_serving_endpoints": {
|
||||||
|
SingularName: "model_serving_endpoint",
|
||||||
|
PluralName: "model_serving_endpoints",
|
||||||
|
SingularTitle: "Model Serving Endpoint",
|
||||||
|
PluralTitle: "Model Serving Endpoints",
|
||||||
|
},
|
||||||
|
"registered_models": {
|
||||||
|
SingularName: "registered_model",
|
||||||
|
PluralName: "registered_models",
|
||||||
|
SingularTitle: "Registered Model",
|
||||||
|
PluralTitle: "Registered Models",
|
||||||
|
},
|
||||||
|
"quality_monitors": {
|
||||||
|
SingularName: "quality_monitor",
|
||||||
|
PluralName: "quality_monitors",
|
||||||
|
SingularTitle: "Quality Monitor",
|
||||||
|
PluralTitle: "Quality Monitors",
|
||||||
|
},
|
||||||
|
"schemas": {
|
||||||
|
SingularName: "schema",
|
||||||
|
PluralName: "schemas",
|
||||||
|
SingularTitle: "Schema",
|
||||||
|
PluralTitle: "Schemas",
|
||||||
|
},
|
||||||
|
"clusters": {
|
||||||
|
SingularName: "cluster",
|
||||||
|
PluralName: "clusters",
|
||||||
|
SingularTitle: "Cluster",
|
||||||
|
PluralTitle: "Clusters",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
"github.com/databricks/databricks-sdk-go"
|
"github.com/databricks/databricks-sdk-go"
|
||||||
|
@ -13,6 +15,7 @@ type Cluster struct {
|
||||||
ID string `json:"id,omitempty" bundle:"readonly"`
|
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||||
Permissions []Permission `json:"permissions,omitempty"`
|
Permissions []Permission `json:"permissions,omitempty"`
|
||||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||||
|
URL string `json:"url,omitempty" bundle:"internal"`
|
||||||
|
|
||||||
*compute.ClusterSpec
|
*compute.ClusterSpec
|
||||||
}
|
}
|
||||||
|
@ -37,3 +40,19 @@ func (s *Cluster) Exists(ctx context.Context, w *databricks.WorkspaceClient, id
|
||||||
func (s *Cluster) TerraformResourceName() string {
|
func (s *Cluster) TerraformResourceName() string {
|
||||||
return "databricks_cluster"
|
return "databricks_cluster"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Cluster) InitializeURL(baseURL url.URL) {
|
||||||
|
if s.ID == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
baseURL.Path = fmt.Sprintf("compute/clusters/%s", s.ID)
|
||||||
|
s.URL = baseURL.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Cluster) GetName() string {
|
||||||
|
return s.ClusterName
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Cluster) GetURL() string {
|
||||||
|
return s.URL
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
|
@ -14,6 +16,7 @@ type Job struct {
|
||||||
ID string `json:"id,omitempty" bundle:"readonly"`
|
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||||
Permissions []Permission `json:"permissions,omitempty"`
|
Permissions []Permission `json:"permissions,omitempty"`
|
||||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||||
|
URL string `json:"url,omitempty" bundle:"internal"`
|
||||||
|
|
||||||
*jobs.JobSettings
|
*jobs.JobSettings
|
||||||
}
|
}
|
||||||
|
@ -44,3 +47,19 @@ func (j *Job) Exists(ctx context.Context, w *databricks.WorkspaceClient, id stri
|
||||||
func (j *Job) TerraformResourceName() string {
|
func (j *Job) TerraformResourceName() string {
|
||||||
return "databricks_job"
|
return "databricks_job"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (j *Job) InitializeURL(baseURL url.URL) {
|
||||||
|
if j.ID == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
baseURL.Path = fmt.Sprintf("jobs/%s", j.ID)
|
||||||
|
j.URL = baseURL.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *Job) GetName() string {
|
||||||
|
return j.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j *Job) GetURL() string {
|
||||||
|
return j.URL
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
"github.com/databricks/databricks-sdk-go"
|
"github.com/databricks/databricks-sdk-go"
|
||||||
|
@ -13,6 +15,7 @@ type MlflowExperiment struct {
|
||||||
ID string `json:"id,omitempty" bundle:"readonly"`
|
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||||
Permissions []Permission `json:"permissions,omitempty"`
|
Permissions []Permission `json:"permissions,omitempty"`
|
||||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||||
|
URL string `json:"url,omitempty" bundle:"internal"`
|
||||||
|
|
||||||
*ml.Experiment
|
*ml.Experiment
|
||||||
}
|
}
|
||||||
|
@ -39,3 +42,19 @@ func (s *MlflowExperiment) Exists(ctx context.Context, w *databricks.WorkspaceCl
|
||||||
func (s *MlflowExperiment) TerraformResourceName() string {
|
func (s *MlflowExperiment) TerraformResourceName() string {
|
||||||
return "databricks_mlflow_experiment"
|
return "databricks_mlflow_experiment"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *MlflowExperiment) InitializeURL(baseURL url.URL) {
|
||||||
|
if s.ID == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
baseURL.Path = fmt.Sprintf("ml/experiments/%s", s.ID)
|
||||||
|
s.URL = baseURL.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MlflowExperiment) GetName() string {
|
||||||
|
return s.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MlflowExperiment) GetURL() string {
|
||||||
|
return s.URL
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
"github.com/databricks/databricks-sdk-go"
|
"github.com/databricks/databricks-sdk-go"
|
||||||
|
@ -13,6 +15,7 @@ type MlflowModel struct {
|
||||||
ID string `json:"id,omitempty" bundle:"readonly"`
|
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||||
Permissions []Permission `json:"permissions,omitempty"`
|
Permissions []Permission `json:"permissions,omitempty"`
|
||||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||||
|
URL string `json:"url,omitempty" bundle:"internal"`
|
||||||
|
|
||||||
*ml.Model
|
*ml.Model
|
||||||
}
|
}
|
||||||
|
@ -39,3 +42,19 @@ func (s *MlflowModel) Exists(ctx context.Context, w *databricks.WorkspaceClient,
|
||||||
func (s *MlflowModel) TerraformResourceName() string {
|
func (s *MlflowModel) TerraformResourceName() string {
|
||||||
return "databricks_mlflow_model"
|
return "databricks_mlflow_model"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *MlflowModel) InitializeURL(baseURL url.URL) {
|
||||||
|
if s.ID == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
baseURL.Path = fmt.Sprintf("ml/models/%s", s.ID)
|
||||||
|
s.URL = baseURL.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MlflowModel) GetName() string {
|
||||||
|
return s.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *MlflowModel) GetURL() string {
|
||||||
|
return s.URL
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
"github.com/databricks/databricks-sdk-go"
|
"github.com/databricks/databricks-sdk-go"
|
||||||
|
@ -23,6 +25,7 @@ type ModelServingEndpoint struct {
|
||||||
Permissions []Permission `json:"permissions,omitempty"`
|
Permissions []Permission `json:"permissions,omitempty"`
|
||||||
|
|
||||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||||
|
URL string `json:"url,omitempty" bundle:"internal"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ModelServingEndpoint) UnmarshalJSON(b []byte) error {
|
func (s *ModelServingEndpoint) UnmarshalJSON(b []byte) error {
|
||||||
|
@ -47,3 +50,19 @@ func (s *ModelServingEndpoint) Exists(ctx context.Context, w *databricks.Workspa
|
||||||
func (s *ModelServingEndpoint) TerraformResourceName() string {
|
func (s *ModelServingEndpoint) TerraformResourceName() string {
|
||||||
return "databricks_model_serving"
|
return "databricks_model_serving"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ModelServingEndpoint) InitializeURL(baseURL url.URL) {
|
||||||
|
if s.ID == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
baseURL.Path = fmt.Sprintf("ml/endpoints/%s", s.ID)
|
||||||
|
s.URL = baseURL.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ModelServingEndpoint) GetName() string {
|
||||||
|
return s.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ModelServingEndpoint) GetURL() string {
|
||||||
|
return s.URL
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
"github.com/databricks/databricks-sdk-go"
|
"github.com/databricks/databricks-sdk-go"
|
||||||
|
@ -13,6 +15,7 @@ type Pipeline struct {
|
||||||
ID string `json:"id,omitempty" bundle:"readonly"`
|
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||||
Permissions []Permission `json:"permissions,omitempty"`
|
Permissions []Permission `json:"permissions,omitempty"`
|
||||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||||
|
URL string `json:"url,omitempty" bundle:"internal"`
|
||||||
|
|
||||||
*pipelines.PipelineSpec
|
*pipelines.PipelineSpec
|
||||||
}
|
}
|
||||||
|
@ -39,3 +42,19 @@ func (p *Pipeline) Exists(ctx context.Context, w *databricks.WorkspaceClient, id
|
||||||
func (p *Pipeline) TerraformResourceName() string {
|
func (p *Pipeline) TerraformResourceName() string {
|
||||||
return "databricks_pipeline"
|
return "databricks_pipeline"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Pipeline) InitializeURL(baseURL url.URL) {
|
||||||
|
if p.ID == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
baseURL.Path = fmt.Sprintf("pipelines/%s", p.ID)
|
||||||
|
p.URL = baseURL.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pipeline) GetName() string {
|
||||||
|
return p.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Pipeline) GetURL() string {
|
||||||
|
return s.URL
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@ package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
"github.com/databricks/databricks-sdk-go"
|
"github.com/databricks/databricks-sdk-go"
|
||||||
|
@ -20,6 +23,7 @@ type QualityMonitor struct {
|
||||||
ID string `json:"id,omitempty" bundle:"readonly"`
|
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||||
|
|
||||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||||
|
URL string `json:"url,omitempty" bundle:"internal"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *QualityMonitor) UnmarshalJSON(b []byte) error {
|
func (s *QualityMonitor) UnmarshalJSON(b []byte) error {
|
||||||
|
@ -44,3 +48,19 @@ func (s *QualityMonitor) Exists(ctx context.Context, w *databricks.WorkspaceClie
|
||||||
func (s *QualityMonitor) TerraformResourceName() string {
|
func (s *QualityMonitor) TerraformResourceName() string {
|
||||||
return "databricks_quality_monitor"
|
return "databricks_quality_monitor"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *QualityMonitor) InitializeURL(baseURL url.URL) {
|
||||||
|
if s.TableName == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
baseURL.Path = fmt.Sprintf("explore/data/%s", strings.ReplaceAll(s.TableName, ".", "/"))
|
||||||
|
s.URL = baseURL.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *QualityMonitor) GetName() string {
|
||||||
|
return s.TableName
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *QualityMonitor) GetURL() string {
|
||||||
|
return s.URL
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@ package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
"github.com/databricks/databricks-sdk-go"
|
"github.com/databricks/databricks-sdk-go"
|
||||||
|
@ -24,6 +27,7 @@ type RegisteredModel struct {
|
||||||
*catalog.CreateRegisteredModelRequest
|
*catalog.CreateRegisteredModelRequest
|
||||||
|
|
||||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||||
|
URL string `json:"url,omitempty" bundle:"internal"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RegisteredModel) UnmarshalJSON(b []byte) error {
|
func (s *RegisteredModel) UnmarshalJSON(b []byte) error {
|
||||||
|
@ -48,3 +52,19 @@ func (s *RegisteredModel) Exists(ctx context.Context, w *databricks.WorkspaceCli
|
||||||
func (s *RegisteredModel) TerraformResourceName() string {
|
func (s *RegisteredModel) TerraformResourceName() string {
|
||||||
return "databricks_registered_model"
|
return "databricks_registered_model"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *RegisteredModel) InitializeURL(baseURL url.URL) {
|
||||||
|
if s.ID == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
baseURL.Path = fmt.Sprintf("explore/data/models/%s", strings.ReplaceAll(s.ID, ".", "/"))
|
||||||
|
s.URL = baseURL.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RegisteredModel) GetName() string {
|
||||||
|
return s.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *RegisteredModel) GetURL() string {
|
||||||
|
return s.URL
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
package resources
|
package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/databricks/databricks-sdk-go"
|
||||||
"github.com/databricks/databricks-sdk-go/marshal"
|
"github.com/databricks/databricks-sdk-go/marshal"
|
||||||
"github.com/databricks/databricks-sdk-go/service/catalog"
|
"github.com/databricks/databricks-sdk-go/service/catalog"
|
||||||
)
|
)
|
||||||
|
@ -16,6 +22,31 @@ type Schema struct {
|
||||||
*catalog.CreateSchema
|
*catalog.CreateSchema
|
||||||
|
|
||||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||||
|
URL string `json:"url,omitempty" bundle:"internal"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Schema) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) {
|
||||||
|
return false, fmt.Errorf("schema.Exists() is not supported")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Schema) TerraformResourceName() string {
|
||||||
|
return "databricks_schema"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Schema) InitializeURL(baseURL url.URL) {
|
||||||
|
if s.ID == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
baseURL.Path = fmt.Sprintf("explore/data/%s", strings.ReplaceAll(s.ID, ".", "/"))
|
||||||
|
s.URL = baseURL.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Schema) GetURL() string {
|
||||||
|
return s.URL
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Schema) GetName() string {
|
||||||
|
return s.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schema) UnmarshalJSON(b []byte) error {
|
func (s *Schema) UnmarshalJSON(b []byte) error {
|
||||||
|
|
|
@ -63,17 +63,37 @@ func TestCustomMarshallerIsImplemented(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResourcesAllResourcesCompleteness(t *testing.T) {
|
||||||
|
r := Resources{}
|
||||||
|
rt := reflect.TypeOf(r)
|
||||||
|
|
||||||
|
// Collect set of includes resource types
|
||||||
|
var types []string
|
||||||
|
for _, group := range r.AllResources() {
|
||||||
|
types = append(types, group.Description.PluralName)
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < rt.NumField(); i++ {
|
||||||
|
field := rt.Field(i)
|
||||||
|
jsonTag := field.Tag.Get("json")
|
||||||
|
|
||||||
|
if idx := strings.Index(jsonTag, ","); idx != -1 {
|
||||||
|
jsonTag = jsonTag[:idx]
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Contains(t, types, jsonTag, "Field %s is missing in AllResources", field.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSupportedResources(t *testing.T) {
|
func TestSupportedResources(t *testing.T) {
|
||||||
expected := map[string]ResourceDescription{}
|
// Please add your resource to the SupportedResources() function in resources.go if you add a new resource.
|
||||||
|
actual := SupportedResources()
|
||||||
|
|
||||||
typ := reflect.TypeOf(Resources{})
|
typ := reflect.TypeOf(Resources{})
|
||||||
for i := 0; i < typ.NumField(); i++ {
|
for i := 0; i < typ.NumField(); i++ {
|
||||||
field := typ.Field(i)
|
field := typ.Field(i)
|
||||||
jsonTags := strings.Split(field.Tag.Get("json"), ",")
|
jsonTags := strings.Split(field.Tag.Get("json"), ",")
|
||||||
singularName := strings.TrimSuffix(jsonTags[0], "s")
|
pluralName := jsonTags[0]
|
||||||
expected[jsonTags[0]] = ResourceDescription{SingularName: singularName}
|
assert.Equal(t, actual[pluralName].PluralName, pluralName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Please add your resource to the SupportedResources() function in resources.go
|
|
||||||
// if you are adding a new resource.
|
|
||||||
assert.Equal(t, expected, SupportedResources())
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ func (f *folderPermissions) Apply(ctx context.Context, b bundle.ReadOnlyBundle)
|
||||||
|
|
||||||
rootPath := b.Config().Workspace.RootPath
|
rootPath := b.Config().Workspace.RootPath
|
||||||
paths := []string{}
|
paths := []string{}
|
||||||
if !libraries.IsVolumesPath(rootPath) {
|
if !libraries.IsVolumesPath(rootPath) && !libraries.IsWorkspaceSharedPath(rootPath) {
|
||||||
paths = append(paths, rootPath)
|
paths = append(paths, rootPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,24 +34,21 @@ func (f *folderPermissions) Apply(ctx context.Context, b bundle.ReadOnlyBundle)
|
||||||
rootPath += "/"
|
rootPath += "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(b.Config().Workspace.ArtifactPath, rootPath) &&
|
for _, p := range []string{
|
||||||
!libraries.IsVolumesPath(b.Config().Workspace.ArtifactPath) {
|
b.Config().Workspace.ArtifactPath,
|
||||||
paths = append(paths, b.Config().Workspace.ArtifactPath)
|
b.Config().Workspace.FilePath,
|
||||||
|
b.Config().Workspace.StatePath,
|
||||||
|
b.Config().Workspace.ResourcePath,
|
||||||
|
} {
|
||||||
|
if libraries.IsWorkspaceSharedPath(p) || libraries.IsVolumesPath(p) {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(b.Config().Workspace.FilePath, rootPath) &&
|
if strings.HasPrefix(p, rootPath) {
|
||||||
!libraries.IsVolumesPath(b.Config().Workspace.FilePath) {
|
continue
|
||||||
paths = append(paths, b.Config().Workspace.FilePath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(b.Config().Workspace.StatePath, rootPath) &&
|
paths = append(paths, p)
|
||||||
!libraries.IsVolumesPath(b.Config().Workspace.StatePath) {
|
|
||||||
paths = append(paths, b.Config().Workspace.StatePath)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !strings.HasPrefix(b.Config().Workspace.ResourcePath, rootPath) &&
|
|
||||||
!libraries.IsVolumesPath(b.Config().Workspace.ResourcePath) {
|
|
||||||
paths = append(paths, b.Config().Workspace.ResourcePath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var diags diag.Diagnostics
|
var diags diag.Diagnostics
|
||||||
|
|
|
@ -122,7 +122,7 @@ func TestValidateFolderPermissionsFailsOnMissingBundlePermission(t *testing.T) {
|
||||||
|
|
||||||
diags := bundle.ApplyReadOnly(context.Background(), rb, ValidateFolderPermissions())
|
diags := bundle.ApplyReadOnly(context.Background(), rb, ValidateFolderPermissions())
|
||||||
require.Len(t, diags, 1)
|
require.Len(t, diags, 1)
|
||||||
require.Equal(t, "permissions missing", diags[0].Summary)
|
require.Equal(t, "untracked permissions apply to target workspace path", diags[0].Summary)
|
||||||
require.Equal(t, diag.Warning, diags[0].Severity)
|
require.Equal(t, diag.Warning, diags[0].Severity)
|
||||||
require.Equal(t, "The following permissions apply to the workspace folder at \"/Workspace/Users/foo@bar.com\" but are not configured in the bundle:\n- level: CAN_MANAGE, user_name: foo2@bar.com\n", diags[0].Detail)
|
require.Equal(t, "The following permissions apply to the workspace folder at \"/Workspace/Users/foo@bar.com\" but are not configured in the bundle:\n- level: CAN_MANAGE, user_name: foo2@bar.com\n", diags[0].Detail)
|
||||||
}
|
}
|
||||||
|
@ -167,12 +167,9 @@ func TestValidateFolderPermissionsFailsOnPermissionMismatch(t *testing.T) {
|
||||||
rb := bundle.ReadOnly(b)
|
rb := bundle.ReadOnly(b)
|
||||||
|
|
||||||
diags := bundle.ApplyReadOnly(context.Background(), rb, ValidateFolderPermissions())
|
diags := bundle.ApplyReadOnly(context.Background(), rb, ValidateFolderPermissions())
|
||||||
require.Len(t, diags, 2)
|
require.Len(t, diags, 1)
|
||||||
require.Equal(t, "permissions missing", diags[0].Summary)
|
require.Equal(t, "untracked permissions apply to target workspace path", diags[0].Summary)
|
||||||
require.Equal(t, diag.Warning, diags[0].Severity)
|
require.Equal(t, diag.Warning, diags[0].Severity)
|
||||||
|
|
||||||
require.Equal(t, "permissions missing", diags[1].Summary)
|
|
||||||
require.Equal(t, diag.Warning, diags[1].Severity)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateFolderPermissionsFailsOnNoRootFolder(t *testing.T) {
|
func TestValidateFolderPermissionsFailsOnNoRootFolder(t *testing.T) {
|
||||||
|
|
|
@ -2,9 +2,7 @@ package terraform
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
"github.com/databricks/cli/bundle/config/resources"
|
"github.com/databricks/cli/bundle/config/resources"
|
||||||
|
@ -14,244 +12,6 @@ import (
|
||||||
tfjson "github.com/hashicorp/terraform-json"
|
tfjson "github.com/hashicorp/terraform-json"
|
||||||
)
|
)
|
||||||
|
|
||||||
func conv(from any, to any) {
|
|
||||||
buf, _ := json.Marshal(from)
|
|
||||||
json.Unmarshal(buf, &to)
|
|
||||||
}
|
|
||||||
|
|
||||||
func convPermissions(acl []resources.Permission) *schema.ResourcePermissions {
|
|
||||||
if len(acl) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
resource := schema.ResourcePermissions{}
|
|
||||||
for _, ac := range acl {
|
|
||||||
resource.AccessControl = append(resource.AccessControl, convPermission(ac))
|
|
||||||
}
|
|
||||||
|
|
||||||
return &resource
|
|
||||||
}
|
|
||||||
|
|
||||||
func convPermission(ac resources.Permission) schema.ResourcePermissionsAccessControl {
|
|
||||||
dst := schema.ResourcePermissionsAccessControl{
|
|
||||||
PermissionLevel: ac.Level,
|
|
||||||
}
|
|
||||||
if ac.UserName != "" {
|
|
||||||
dst.UserName = ac.UserName
|
|
||||||
}
|
|
||||||
if ac.GroupName != "" {
|
|
||||||
dst.GroupName = ac.GroupName
|
|
||||||
}
|
|
||||||
if ac.ServicePrincipalName != "" {
|
|
||||||
dst.ServicePrincipalName = ac.ServicePrincipalName
|
|
||||||
}
|
|
||||||
return dst
|
|
||||||
}
|
|
||||||
|
|
||||||
func convGrants(acl []resources.Grant) *schema.ResourceGrants {
|
|
||||||
if len(acl) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
resource := schema.ResourceGrants{}
|
|
||||||
for _, ac := range acl {
|
|
||||||
resource.Grant = append(resource.Grant, schema.ResourceGrantsGrant{
|
|
||||||
Privileges: ac.Privileges,
|
|
||||||
Principal: ac.Principal,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return &resource
|
|
||||||
}
|
|
||||||
|
|
||||||
// BundleToTerraform converts resources in a bundle configuration
|
|
||||||
// to the equivalent Terraform JSON representation.
|
|
||||||
//
|
|
||||||
// Note: This function is an older implementation of the conversion logic. It is
|
|
||||||
// no longer used in any code paths. It is kept around to be used in tests.
|
|
||||||
// New resources do not need to modify this function and can instead can define
|
|
||||||
// the conversion login in the tfdyn package.
|
|
||||||
func BundleToTerraform(config *config.Root) *schema.Root {
|
|
||||||
tfroot := schema.NewRoot()
|
|
||||||
tfroot.Provider = schema.NewProviders()
|
|
||||||
tfroot.Resource = schema.NewResources()
|
|
||||||
noResources := true
|
|
||||||
|
|
||||||
for k, src := range config.Resources.Jobs {
|
|
||||||
noResources = false
|
|
||||||
var dst schema.ResourceJob
|
|
||||||
conv(src, &dst)
|
|
||||||
|
|
||||||
if src.JobSettings != nil {
|
|
||||||
sort.Slice(src.JobSettings.Tasks, func(i, j int) bool {
|
|
||||||
return src.JobSettings.Tasks[i].TaskKey < src.JobSettings.Tasks[j].TaskKey
|
|
||||||
})
|
|
||||||
|
|
||||||
for _, v := range src.Tasks {
|
|
||||||
var t schema.ResourceJobTask
|
|
||||||
conv(v, &t)
|
|
||||||
|
|
||||||
for _, v_ := range v.Libraries {
|
|
||||||
var l schema.ResourceJobTaskLibrary
|
|
||||||
conv(v_, &l)
|
|
||||||
t.Library = append(t.Library, l)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert for_each_task libraries
|
|
||||||
if v.ForEachTask != nil {
|
|
||||||
for _, v_ := range v.ForEachTask.Task.Libraries {
|
|
||||||
var l schema.ResourceJobTaskForEachTaskTaskLibrary
|
|
||||||
conv(v_, &l)
|
|
||||||
t.ForEachTask.Task.Library = append(t.ForEachTask.Task.Library, l)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
dst.Task = append(dst.Task, t)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range src.JobClusters {
|
|
||||||
var t schema.ResourceJobJobCluster
|
|
||||||
conv(v, &t)
|
|
||||||
dst.JobCluster = append(dst.JobCluster, t)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unblock downstream work. To be addressed more generally later.
|
|
||||||
if git := src.GitSource; git != nil {
|
|
||||||
dst.GitSource = &schema.ResourceJobGitSource{
|
|
||||||
Url: git.GitUrl,
|
|
||||||
Branch: git.GitBranch,
|
|
||||||
Commit: git.GitCommit,
|
|
||||||
Provider: string(git.GitProvider),
|
|
||||||
Tag: git.GitTag,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range src.Parameters {
|
|
||||||
var t schema.ResourceJobParameter
|
|
||||||
conv(v, &t)
|
|
||||||
dst.Parameter = append(dst.Parameter, t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tfroot.Resource.Job[k] = &dst
|
|
||||||
|
|
||||||
// Configure permissions for this resource.
|
|
||||||
if rp := convPermissions(src.Permissions); rp != nil {
|
|
||||||
rp.JobId = fmt.Sprintf("${databricks_job.%s.id}", k)
|
|
||||||
tfroot.Resource.Permissions["job_"+k] = rp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, src := range config.Resources.Pipelines {
|
|
||||||
noResources = false
|
|
||||||
var dst schema.ResourcePipeline
|
|
||||||
conv(src, &dst)
|
|
||||||
|
|
||||||
if src.PipelineSpec != nil {
|
|
||||||
for _, v := range src.Libraries {
|
|
||||||
var l schema.ResourcePipelineLibrary
|
|
||||||
conv(v, &l)
|
|
||||||
dst.Library = append(dst.Library, l)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range src.Clusters {
|
|
||||||
var l schema.ResourcePipelineCluster
|
|
||||||
conv(v, &l)
|
|
||||||
dst.Cluster = append(dst.Cluster, l)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range src.Notifications {
|
|
||||||
var l schema.ResourcePipelineNotification
|
|
||||||
conv(v, &l)
|
|
||||||
dst.Notification = append(dst.Notification, l)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tfroot.Resource.Pipeline[k] = &dst
|
|
||||||
|
|
||||||
// Configure permissions for this resource.
|
|
||||||
if rp := convPermissions(src.Permissions); rp != nil {
|
|
||||||
rp.PipelineId = fmt.Sprintf("${databricks_pipeline.%s.id}", k)
|
|
||||||
tfroot.Resource.Permissions["pipeline_"+k] = rp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, src := range config.Resources.Models {
|
|
||||||
noResources = false
|
|
||||||
var dst schema.ResourceMlflowModel
|
|
||||||
conv(src, &dst)
|
|
||||||
tfroot.Resource.MlflowModel[k] = &dst
|
|
||||||
|
|
||||||
// Configure permissions for this resource.
|
|
||||||
if rp := convPermissions(src.Permissions); rp != nil {
|
|
||||||
rp.RegisteredModelId = fmt.Sprintf("${databricks_mlflow_model.%s.registered_model_id}", k)
|
|
||||||
tfroot.Resource.Permissions["mlflow_model_"+k] = rp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, src := range config.Resources.Experiments {
|
|
||||||
noResources = false
|
|
||||||
var dst schema.ResourceMlflowExperiment
|
|
||||||
conv(src, &dst)
|
|
||||||
tfroot.Resource.MlflowExperiment[k] = &dst
|
|
||||||
|
|
||||||
// Configure permissions for this resource.
|
|
||||||
if rp := convPermissions(src.Permissions); rp != nil {
|
|
||||||
rp.ExperimentId = fmt.Sprintf("${databricks_mlflow_experiment.%s.id}", k)
|
|
||||||
tfroot.Resource.Permissions["mlflow_experiment_"+k] = rp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, src := range config.Resources.ModelServingEndpoints {
|
|
||||||
noResources = false
|
|
||||||
var dst schema.ResourceModelServing
|
|
||||||
conv(src, &dst)
|
|
||||||
tfroot.Resource.ModelServing[k] = &dst
|
|
||||||
|
|
||||||
// Configure permissions for this resource.
|
|
||||||
if rp := convPermissions(src.Permissions); rp != nil {
|
|
||||||
rp.ServingEndpointId = fmt.Sprintf("${databricks_model_serving.%s.serving_endpoint_id}", k)
|
|
||||||
tfroot.Resource.Permissions["model_serving_"+k] = rp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, src := range config.Resources.RegisteredModels {
|
|
||||||
noResources = false
|
|
||||||
var dst schema.ResourceRegisteredModel
|
|
||||||
conv(src, &dst)
|
|
||||||
tfroot.Resource.RegisteredModel[k] = &dst
|
|
||||||
|
|
||||||
// Configure permissions for this resource.
|
|
||||||
if rp := convGrants(src.Grants); rp != nil {
|
|
||||||
rp.Function = fmt.Sprintf("${databricks_registered_model.%s.id}", k)
|
|
||||||
tfroot.Resource.Grants["registered_model_"+k] = rp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, src := range config.Resources.QualityMonitors {
|
|
||||||
noResources = false
|
|
||||||
var dst schema.ResourceQualityMonitor
|
|
||||||
conv(src, &dst)
|
|
||||||
tfroot.Resource.QualityMonitor[k] = &dst
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, src := range config.Resources.Clusters {
|
|
||||||
noResources = false
|
|
||||||
var dst schema.ResourceCluster
|
|
||||||
conv(src, &dst)
|
|
||||||
tfroot.Resource.Cluster[k] = &dst
|
|
||||||
}
|
|
||||||
|
|
||||||
// We explicitly set "resource" to nil to omit it from a JSON encoding.
|
|
||||||
// This is required because the terraform CLI requires >= 1 resources defined
|
|
||||||
// if the "resource" property is used in a .tf.json file.
|
|
||||||
if noResources {
|
|
||||||
tfroot.Resource = nil
|
|
||||||
}
|
|
||||||
return tfroot
|
|
||||||
}
|
|
||||||
|
|
||||||
// BundleToTerraformWithDynValue converts resources in a bundle configuration
|
// BundleToTerraformWithDynValue converts resources in a bundle configuration
|
||||||
// to the equivalent Terraform JSON representation.
|
// to the equivalent Terraform JSON representation.
|
||||||
func BundleToTerraformWithDynValue(ctx context.Context, root dyn.Value) (*schema.Root, error) {
|
func BundleToTerraformWithDynValue(ctx context.Context, root dyn.Value) (*schema.Root, error) {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package terraform
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -21,6 +20,27 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func produceTerraformConfiguration(t *testing.T, config config.Root) *schema.Root {
|
||||||
|
vin, err := convert.FromTyped(config, dyn.NilValue)
|
||||||
|
require.NoError(t, err)
|
||||||
|
out, err := BundleToTerraformWithDynValue(context.Background(), vin)
|
||||||
|
require.NoError(t, err)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func convertToResourceStruct[T any](t *testing.T, resource *T, data any) {
|
||||||
|
require.NotNil(t, resource)
|
||||||
|
require.NotNil(t, data)
|
||||||
|
|
||||||
|
// Convert data to a dyn.Value.
|
||||||
|
vin, err := convert.FromTyped(data, dyn.NilValue)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Convert the dyn.Value to a struct.
|
||||||
|
err = convert.ToTyped(resource, vin)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformJob(t *testing.T) {
|
func TestBundleToTerraformJob(t *testing.T) {
|
||||||
var src = resources.Job{
|
var src = resources.Job{
|
||||||
JobSettings: &jobs.JobSettings{
|
JobSettings: &jobs.JobSettings{
|
||||||
|
@ -58,8 +78,9 @@ func TestBundleToTerraformJob(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourceJob
|
||||||
resource := out.Resource.Job["my_job"].(*schema.ResourceJob)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.Job["my_job"])
|
||||||
|
|
||||||
assert.Equal(t, "my job", resource.Name)
|
assert.Equal(t, "my job", resource.Name)
|
||||||
assert.Len(t, resource.JobCluster, 1)
|
assert.Len(t, resource.JobCluster, 1)
|
||||||
|
@ -68,8 +89,6 @@ func TestBundleToTerraformJob(t *testing.T) {
|
||||||
assert.Equal(t, "param1", resource.Parameter[0].Name)
|
assert.Equal(t, "param1", resource.Parameter[0].Name)
|
||||||
assert.Equal(t, "param2", resource.Parameter[1].Name)
|
assert.Equal(t, "param2", resource.Parameter[1].Name)
|
||||||
assert.Nil(t, out.Data)
|
assert.Nil(t, out.Data)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformJobPermissions(t *testing.T) {
|
func TestBundleToTerraformJobPermissions(t *testing.T) {
|
||||||
|
@ -90,15 +109,14 @@ func TestBundleToTerraformJobPermissions(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourcePermissions
|
||||||
resource := out.Resource.Permissions["job_my_job"].(*schema.ResourcePermissions)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.Permissions["job_my_job"])
|
||||||
|
|
||||||
assert.NotEmpty(t, resource.JobId)
|
assert.NotEmpty(t, resource.JobId)
|
||||||
assert.Len(t, resource.AccessControl, 1)
|
assert.Len(t, resource.AccessControl, 1)
|
||||||
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
||||||
assert.Equal(t, "CAN_VIEW", resource.AccessControl[0].PermissionLevel)
|
assert.Equal(t, "CAN_VIEW", resource.AccessControl[0].PermissionLevel)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformJobTaskLibraries(t *testing.T) {
|
func TestBundleToTerraformJobTaskLibraries(t *testing.T) {
|
||||||
|
@ -128,15 +146,14 @@ func TestBundleToTerraformJobTaskLibraries(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourceJob
|
||||||
resource := out.Resource.Job["my_job"].(*schema.ResourceJob)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.Job["my_job"])
|
||||||
|
|
||||||
assert.Equal(t, "my job", resource.Name)
|
assert.Equal(t, "my job", resource.Name)
|
||||||
require.Len(t, resource.Task, 1)
|
require.Len(t, resource.Task, 1)
|
||||||
require.Len(t, resource.Task[0].Library, 1)
|
require.Len(t, resource.Task[0].Library, 1)
|
||||||
assert.Equal(t, "mlflow", resource.Task[0].Library[0].Pypi.Package)
|
assert.Equal(t, "mlflow", resource.Task[0].Library[0].Pypi.Package)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformForEachTaskLibraries(t *testing.T) {
|
func TestBundleToTerraformForEachTaskLibraries(t *testing.T) {
|
||||||
|
@ -172,15 +189,14 @@ func TestBundleToTerraformForEachTaskLibraries(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourceJob
|
||||||
resource := out.Resource.Job["my_job"].(*schema.ResourceJob)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.Job["my_job"])
|
||||||
|
|
||||||
assert.Equal(t, "my job", resource.Name)
|
assert.Equal(t, "my job", resource.Name)
|
||||||
require.Len(t, resource.Task, 1)
|
require.Len(t, resource.Task, 1)
|
||||||
require.Len(t, resource.Task[0].ForEachTask.Task.Library, 1)
|
require.Len(t, resource.Task[0].ForEachTask.Task.Library, 1)
|
||||||
assert.Equal(t, "mlflow", resource.Task[0].ForEachTask.Task.Library[0].Pypi.Package)
|
assert.Equal(t, "mlflow", resource.Task[0].ForEachTask.Task.Library[0].Pypi.Package)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformPipeline(t *testing.T) {
|
func TestBundleToTerraformPipeline(t *testing.T) {
|
||||||
|
@ -230,8 +246,9 @@ func TestBundleToTerraformPipeline(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourcePipeline
|
||||||
resource := out.Resource.Pipeline["my_pipeline"].(*schema.ResourcePipeline)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.Pipeline["my_pipeline"])
|
||||||
|
|
||||||
assert.Equal(t, "my pipeline", resource.Name)
|
assert.Equal(t, "my pipeline", resource.Name)
|
||||||
assert.Len(t, resource.Library, 2)
|
assert.Len(t, resource.Library, 2)
|
||||||
|
@ -241,8 +258,6 @@ func TestBundleToTerraformPipeline(t *testing.T) {
|
||||||
assert.Equal(t, resource.Notification[1].Alerts, []string{"on-update-failure", "on-flow-failure"})
|
assert.Equal(t, resource.Notification[1].Alerts, []string{"on-update-failure", "on-flow-failure"})
|
||||||
assert.Equal(t, resource.Notification[1].EmailRecipients, []string{"jane@doe.com", "john@doe.com"})
|
assert.Equal(t, resource.Notification[1].EmailRecipients, []string{"jane@doe.com", "john@doe.com"})
|
||||||
assert.Nil(t, out.Data)
|
assert.Nil(t, out.Data)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformPipelinePermissions(t *testing.T) {
|
func TestBundleToTerraformPipelinePermissions(t *testing.T) {
|
||||||
|
@ -263,15 +278,14 @@ func TestBundleToTerraformPipelinePermissions(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourcePermissions
|
||||||
resource := out.Resource.Permissions["pipeline_my_pipeline"].(*schema.ResourcePermissions)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.Permissions["pipeline_my_pipeline"])
|
||||||
|
|
||||||
assert.NotEmpty(t, resource.PipelineId)
|
assert.NotEmpty(t, resource.PipelineId)
|
||||||
assert.Len(t, resource.AccessControl, 1)
|
assert.Len(t, resource.AccessControl, 1)
|
||||||
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
||||||
assert.Equal(t, "CAN_VIEW", resource.AccessControl[0].PermissionLevel)
|
assert.Equal(t, "CAN_VIEW", resource.AccessControl[0].PermissionLevel)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformModel(t *testing.T) {
|
func TestBundleToTerraformModel(t *testing.T) {
|
||||||
|
@ -300,8 +314,9 @@ func TestBundleToTerraformModel(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourceMlflowModel
|
||||||
resource := out.Resource.MlflowModel["my_model"].(*schema.ResourceMlflowModel)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.MlflowModel["my_model"])
|
||||||
|
|
||||||
assert.Equal(t, "name", resource.Name)
|
assert.Equal(t, "name", resource.Name)
|
||||||
assert.Equal(t, "description", resource.Description)
|
assert.Equal(t, "description", resource.Description)
|
||||||
|
@ -311,8 +326,6 @@ func TestBundleToTerraformModel(t *testing.T) {
|
||||||
assert.Equal(t, "k2", resource.Tags[1].Key)
|
assert.Equal(t, "k2", resource.Tags[1].Key)
|
||||||
assert.Equal(t, "v2", resource.Tags[1].Value)
|
assert.Equal(t, "v2", resource.Tags[1].Value)
|
||||||
assert.Nil(t, out.Data)
|
assert.Nil(t, out.Data)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformModelPermissions(t *testing.T) {
|
func TestBundleToTerraformModelPermissions(t *testing.T) {
|
||||||
|
@ -336,15 +349,14 @@ func TestBundleToTerraformModelPermissions(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourcePermissions
|
||||||
resource := out.Resource.Permissions["mlflow_model_my_model"].(*schema.ResourcePermissions)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.Permissions["mlflow_model_my_model"])
|
||||||
|
|
||||||
assert.NotEmpty(t, resource.RegisteredModelId)
|
assert.NotEmpty(t, resource.RegisteredModelId)
|
||||||
assert.Len(t, resource.AccessControl, 1)
|
assert.Len(t, resource.AccessControl, 1)
|
||||||
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
||||||
assert.Equal(t, "CAN_READ", resource.AccessControl[0].PermissionLevel)
|
assert.Equal(t, "CAN_READ", resource.AccessControl[0].PermissionLevel)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformExperiment(t *testing.T) {
|
func TestBundleToTerraformExperiment(t *testing.T) {
|
||||||
|
@ -362,13 +374,12 @@ func TestBundleToTerraformExperiment(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourceMlflowExperiment
|
||||||
resource := out.Resource.MlflowExperiment["my_experiment"].(*schema.ResourceMlflowExperiment)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.MlflowExperiment["my_experiment"])
|
||||||
|
|
||||||
assert.Equal(t, "name", resource.Name)
|
assert.Equal(t, "name", resource.Name)
|
||||||
assert.Nil(t, out.Data)
|
assert.Nil(t, out.Data)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformExperimentPermissions(t *testing.T) {
|
func TestBundleToTerraformExperimentPermissions(t *testing.T) {
|
||||||
|
@ -392,15 +403,14 @@ func TestBundleToTerraformExperimentPermissions(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourcePermissions
|
||||||
resource := out.Resource.Permissions["mlflow_experiment_my_experiment"].(*schema.ResourcePermissions)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.Permissions["mlflow_experiment_my_experiment"])
|
||||||
|
|
||||||
assert.NotEmpty(t, resource.ExperimentId)
|
assert.NotEmpty(t, resource.ExperimentId)
|
||||||
assert.Len(t, resource.AccessControl, 1)
|
assert.Len(t, resource.AccessControl, 1)
|
||||||
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
||||||
assert.Equal(t, "CAN_READ", resource.AccessControl[0].PermissionLevel)
|
assert.Equal(t, "CAN_READ", resource.AccessControl[0].PermissionLevel)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformModelServing(t *testing.T) {
|
func TestBundleToTerraformModelServing(t *testing.T) {
|
||||||
|
@ -436,8 +446,9 @@ func TestBundleToTerraformModelServing(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourceModelServing
|
||||||
resource := out.Resource.ModelServing["my_model_serving_endpoint"].(*schema.ResourceModelServing)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.ModelServing["my_model_serving_endpoint"])
|
||||||
|
|
||||||
assert.Equal(t, "name", resource.Name)
|
assert.Equal(t, "name", resource.Name)
|
||||||
assert.Equal(t, "model_name", resource.Config.ServedModels[0].ModelName)
|
assert.Equal(t, "model_name", resource.Config.ServedModels[0].ModelName)
|
||||||
|
@ -447,8 +458,6 @@ func TestBundleToTerraformModelServing(t *testing.T) {
|
||||||
assert.Equal(t, "model_name-1", resource.Config.TrafficConfig.Routes[0].ServedModelName)
|
assert.Equal(t, "model_name-1", resource.Config.TrafficConfig.Routes[0].ServedModelName)
|
||||||
assert.Equal(t, 100, resource.Config.TrafficConfig.Routes[0].TrafficPercentage)
|
assert.Equal(t, 100, resource.Config.TrafficConfig.Routes[0].TrafficPercentage)
|
||||||
assert.Nil(t, out.Data)
|
assert.Nil(t, out.Data)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformModelServingPermissions(t *testing.T) {
|
func TestBundleToTerraformModelServingPermissions(t *testing.T) {
|
||||||
|
@ -490,15 +499,14 @@ func TestBundleToTerraformModelServingPermissions(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourcePermissions
|
||||||
resource := out.Resource.Permissions["model_serving_my_model_serving_endpoint"].(*schema.ResourcePermissions)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.Permissions["model_serving_my_model_serving_endpoint"])
|
||||||
|
|
||||||
assert.NotEmpty(t, resource.ServingEndpointId)
|
assert.NotEmpty(t, resource.ServingEndpointId)
|
||||||
assert.Len(t, resource.AccessControl, 1)
|
assert.Len(t, resource.AccessControl, 1)
|
||||||
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
||||||
assert.Equal(t, "CAN_VIEW", resource.AccessControl[0].PermissionLevel)
|
assert.Equal(t, "CAN_VIEW", resource.AccessControl[0].PermissionLevel)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformRegisteredModel(t *testing.T) {
|
func TestBundleToTerraformRegisteredModel(t *testing.T) {
|
||||||
|
@ -519,16 +527,15 @@ func TestBundleToTerraformRegisteredModel(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourceRegisteredModel
|
||||||
resource := out.Resource.RegisteredModel["my_registered_model"].(*schema.ResourceRegisteredModel)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.RegisteredModel["my_registered_model"])
|
||||||
|
|
||||||
assert.Equal(t, "name", resource.Name)
|
assert.Equal(t, "name", resource.Name)
|
||||||
assert.Equal(t, "catalog", resource.CatalogName)
|
assert.Equal(t, "catalog", resource.CatalogName)
|
||||||
assert.Equal(t, "schema", resource.SchemaName)
|
assert.Equal(t, "schema", resource.SchemaName)
|
||||||
assert.Equal(t, "comment", resource.Comment)
|
assert.Equal(t, "comment", resource.Comment)
|
||||||
assert.Nil(t, out.Data)
|
assert.Nil(t, out.Data)
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformRegisteredModelGrants(t *testing.T) {
|
func TestBundleToTerraformRegisteredModelGrants(t *testing.T) {
|
||||||
|
@ -554,15 +561,14 @@ func TestBundleToTerraformRegisteredModelGrants(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out := BundleToTerraform(&config)
|
var resource schema.ResourceGrants
|
||||||
resource := out.Resource.Grants["registered_model_my_registered_model"].(*schema.ResourceGrants)
|
out := produceTerraformConfiguration(t, config)
|
||||||
|
convertToResourceStruct(t, &resource, out.Resource.Grants["registered_model_my_registered_model"])
|
||||||
|
|
||||||
assert.NotEmpty(t, resource.Function)
|
assert.NotEmpty(t, resource.Function)
|
||||||
assert.Len(t, resource.Grant, 1)
|
assert.Len(t, resource.Grant, 1)
|
||||||
assert.Equal(t, "jane@doe.com", resource.Grant[0].Principal)
|
assert.Equal(t, "jane@doe.com", resource.Grant[0].Principal)
|
||||||
assert.Equal(t, "EXECUTE", resource.Grant[0].Privileges[0])
|
assert.Equal(t, "EXECUTE", resource.Grant[0].Privileges[0])
|
||||||
|
|
||||||
bundleToTerraformEquivalenceTest(t, &config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundleToTerraformDeletedResources(t *testing.T) {
|
func TestBundleToTerraformDeletedResources(t *testing.T) {
|
||||||
|
@ -1154,25 +1160,3 @@ func AssertFullResourceCoverage(t *testing.T, config *config.Root) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertEqualTerraformRoot(t *testing.T, a, b *schema.Root) {
|
|
||||||
ba, err := json.Marshal(a)
|
|
||||||
require.NoError(t, err)
|
|
||||||
bb, err := json.Marshal(b)
|
|
||||||
require.NoError(t, err)
|
|
||||||
assert.JSONEq(t, string(ba), string(bb))
|
|
||||||
}
|
|
||||||
|
|
||||||
func bundleToTerraformEquivalenceTest(t *testing.T, config *config.Root) {
|
|
||||||
t.Run("dyn equivalence", func(t *testing.T) {
|
|
||||||
tf1 := BundleToTerraform(config)
|
|
||||||
|
|
||||||
vin, err := convert.FromTyped(config, dyn.NilValue)
|
|
||||||
require.NoError(t, err)
|
|
||||||
tf2, err := BundleToTerraformWithDynValue(context.Background(), vin)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// Compare roots
|
|
||||||
assertEqualTerraformRoot(t, tf1, tf2)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (clusterConverter) Convert(ctx context.Context, key string, vin dyn.Value,
|
||||||
|
|
||||||
// Configure permissions for this resource.
|
// Configure permissions for this resource.
|
||||||
if permissions := convertPermissionsResource(ctx, vin); permissions != nil {
|
if permissions := convertPermissionsResource(ctx, vin); permissions != nil {
|
||||||
permissions.JobId = fmt.Sprintf("${databricks_cluster.%s.id}", key)
|
permissions.ClusterId = fmt.Sprintf("${databricks_cluster.%s.id}", key)
|
||||||
out.Permissions["cluster_"+key] = permissions
|
out.Permissions["cluster_"+key] = permissions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ func TestConvertCluster(t *testing.T) {
|
||||||
|
|
||||||
// Assert equality on the permissions
|
// Assert equality on the permissions
|
||||||
assert.Equal(t, &schema.ResourcePermissions{
|
assert.Equal(t, &schema.ResourcePermissions{
|
||||||
JobId: "${databricks_cluster.my_cluster.id}",
|
ClusterId: "${databricks_cluster.my_cluster.id}",
|
||||||
AccessControl: []schema.ResourcePermissionsAccessControl{
|
AccessControl: []schema.ResourcePermissionsAccessControl{
|
||||||
{
|
{
|
||||||
PermissionLevel: "CAN_RUN",
|
PermissionLevel: "CAN_RUN",
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
const ProviderVersion = "1.53.0"
|
const ProviderVersion = "1.54.0"
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
// Generated from Databricks Terraform provider schema. DO NOT EDIT.
|
||||||
|
|
||||||
|
package schema
|
||||||
|
|
||||||
|
type DataSourceNotificationDestinationsNotificationDestinations struct {
|
||||||
|
DestinationType string `json:"destination_type,omitempty"`
|
||||||
|
DisplayName string `json:"display_name,omitempty"`
|
||||||
|
Id string `json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DataSourceNotificationDestinations struct {
|
||||||
|
DisplayNameContains string `json:"display_name_contains,omitempty"`
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
NotificationDestinations []DataSourceNotificationDestinationsNotificationDestinations `json:"notification_destinations,omitempty"`
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
// Generated from Databricks Terraform provider schema. DO NOT EDIT.
|
||||||
|
|
||||||
|
package schema
|
||||||
|
|
||||||
|
type DataSourceRegisteredModelModelInfoAliases struct {
|
||||||
|
AliasName string `json:"alias_name,omitempty"`
|
||||||
|
VersionNum int `json:"version_num,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DataSourceRegisteredModelModelInfo struct {
|
||||||
|
BrowseOnly bool `json:"browse_only,omitempty"`
|
||||||
|
CatalogName string `json:"catalog_name,omitempty"`
|
||||||
|
Comment string `json:"comment,omitempty"`
|
||||||
|
CreatedAt int `json:"created_at,omitempty"`
|
||||||
|
CreatedBy string `json:"created_by,omitempty"`
|
||||||
|
FullName string `json:"full_name,omitempty"`
|
||||||
|
MetastoreId string `json:"metastore_id,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Owner string `json:"owner,omitempty"`
|
||||||
|
SchemaName string `json:"schema_name,omitempty"`
|
||||||
|
StorageLocation string `json:"storage_location,omitempty"`
|
||||||
|
UpdatedAt int `json:"updated_at,omitempty"`
|
||||||
|
UpdatedBy string `json:"updated_by,omitempty"`
|
||||||
|
Aliases []DataSourceRegisteredModelModelInfoAliases `json:"aliases,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DataSourceRegisteredModel struct {
|
||||||
|
FullName string `json:"full_name"`
|
||||||
|
IncludeAliases bool `json:"include_aliases,omitempty"`
|
||||||
|
IncludeBrowse bool `json:"include_browse,omitempty"`
|
||||||
|
ModelInfo []DataSourceRegisteredModelModelInfo `json:"model_info,omitempty"`
|
||||||
|
}
|
|
@ -36,7 +36,9 @@ type DataSources struct {
|
||||||
NodeType map[string]any `json:"databricks_node_type,omitempty"`
|
NodeType map[string]any `json:"databricks_node_type,omitempty"`
|
||||||
Notebook map[string]any `json:"databricks_notebook,omitempty"`
|
Notebook map[string]any `json:"databricks_notebook,omitempty"`
|
||||||
NotebookPaths map[string]any `json:"databricks_notebook_paths,omitempty"`
|
NotebookPaths map[string]any `json:"databricks_notebook_paths,omitempty"`
|
||||||
|
NotificationDestinations map[string]any `json:"databricks_notification_destinations,omitempty"`
|
||||||
Pipelines map[string]any `json:"databricks_pipelines,omitempty"`
|
Pipelines map[string]any `json:"databricks_pipelines,omitempty"`
|
||||||
|
RegisteredModel map[string]any `json:"databricks_registered_model,omitempty"`
|
||||||
Schema map[string]any `json:"databricks_schema,omitempty"`
|
Schema map[string]any `json:"databricks_schema,omitempty"`
|
||||||
Schemas map[string]any `json:"databricks_schemas,omitempty"`
|
Schemas map[string]any `json:"databricks_schemas,omitempty"`
|
||||||
ServicePrincipal map[string]any `json:"databricks_service_principal,omitempty"`
|
ServicePrincipal map[string]any `json:"databricks_service_principal,omitempty"`
|
||||||
|
@ -92,7 +94,9 @@ func NewDataSources() *DataSources {
|
||||||
NodeType: make(map[string]any),
|
NodeType: make(map[string]any),
|
||||||
Notebook: make(map[string]any),
|
Notebook: make(map[string]any),
|
||||||
NotebookPaths: make(map[string]any),
|
NotebookPaths: make(map[string]any),
|
||||||
|
NotificationDestinations: make(map[string]any),
|
||||||
Pipelines: make(map[string]any),
|
Pipelines: make(map[string]any),
|
||||||
|
RegisteredModel: make(map[string]any),
|
||||||
Schema: make(map[string]any),
|
Schema: make(map[string]any),
|
||||||
Schemas: make(map[string]any),
|
Schemas: make(map[string]any),
|
||||||
ServicePrincipal: make(map[string]any),
|
ServicePrincipal: make(map[string]any),
|
||||||
|
|
|
@ -1448,6 +1448,7 @@ type ResourceJobWebhookNotifications struct {
|
||||||
|
|
||||||
type ResourceJob struct {
|
type ResourceJob struct {
|
||||||
AlwaysRunning bool `json:"always_running,omitempty"`
|
AlwaysRunning bool `json:"always_running,omitempty"`
|
||||||
|
BudgetPolicyId string `json:"budget_policy_id,omitempty"`
|
||||||
ControlRunState bool `json:"control_run_state,omitempty"`
|
ControlRunState bool `json:"control_run_state,omitempty"`
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
EditMode string `json:"edit_mode,omitempty"`
|
EditMode string `json:"edit_mode,omitempty"`
|
||||||
|
|
|
@ -23,5 +23,6 @@ type ResourceOnlineTable struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Status []any `json:"status,omitempty"`
|
Status []any `json:"status,omitempty"`
|
||||||
TableServingUrl string `json:"table_serving_url,omitempty"`
|
TableServingUrl string `json:"table_serving_url,omitempty"`
|
||||||
|
UnityCatalogProvisioningState string `json:"unity_catalog_provisioning_state,omitempty"`
|
||||||
Spec *ResourceOnlineTableSpec `json:"spec,omitempty"`
|
Spec *ResourceOnlineTableSpec `json:"spec,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,10 +142,26 @@ type ResourcePipelineGatewayDefinition struct {
|
||||||
GatewayStorageSchema string `json:"gateway_storage_schema,omitempty"`
|
GatewayStorageSchema string `json:"gateway_storage_schema,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ResourcePipelineIngestionDefinitionObjectsReportTableConfiguration struct {
|
||||||
|
PrimaryKeys []string `json:"primary_keys,omitempty"`
|
||||||
|
SalesforceIncludeFormulaFields bool `json:"salesforce_include_formula_fields,omitempty"`
|
||||||
|
ScdType string `json:"scd_type,omitempty"`
|
||||||
|
SequenceBy []string `json:"sequence_by,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResourcePipelineIngestionDefinitionObjectsReport struct {
|
||||||
|
DestinationCatalog string `json:"destination_catalog,omitempty"`
|
||||||
|
DestinationSchema string `json:"destination_schema,omitempty"`
|
||||||
|
DestinationTable string `json:"destination_table,omitempty"`
|
||||||
|
SourceUrl string `json:"source_url,omitempty"`
|
||||||
|
TableConfiguration *ResourcePipelineIngestionDefinitionObjectsReportTableConfiguration `json:"table_configuration,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type ResourcePipelineIngestionDefinitionObjectsSchemaTableConfiguration struct {
|
type ResourcePipelineIngestionDefinitionObjectsSchemaTableConfiguration struct {
|
||||||
PrimaryKeys []string `json:"primary_keys,omitempty"`
|
PrimaryKeys []string `json:"primary_keys,omitempty"`
|
||||||
SalesforceIncludeFormulaFields bool `json:"salesforce_include_formula_fields,omitempty"`
|
SalesforceIncludeFormulaFields bool `json:"salesforce_include_formula_fields,omitempty"`
|
||||||
ScdType string `json:"scd_type,omitempty"`
|
ScdType string `json:"scd_type,omitempty"`
|
||||||
|
SequenceBy []string `json:"sequence_by,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResourcePipelineIngestionDefinitionObjectsSchema struct {
|
type ResourcePipelineIngestionDefinitionObjectsSchema struct {
|
||||||
|
@ -160,6 +176,7 @@ type ResourcePipelineIngestionDefinitionObjectsTableTableConfiguration struct {
|
||||||
PrimaryKeys []string `json:"primary_keys,omitempty"`
|
PrimaryKeys []string `json:"primary_keys,omitempty"`
|
||||||
SalesforceIncludeFormulaFields bool `json:"salesforce_include_formula_fields,omitempty"`
|
SalesforceIncludeFormulaFields bool `json:"salesforce_include_formula_fields,omitempty"`
|
||||||
ScdType string `json:"scd_type,omitempty"`
|
ScdType string `json:"scd_type,omitempty"`
|
||||||
|
SequenceBy []string `json:"sequence_by,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResourcePipelineIngestionDefinitionObjectsTable struct {
|
type ResourcePipelineIngestionDefinitionObjectsTable struct {
|
||||||
|
@ -173,6 +190,7 @@ type ResourcePipelineIngestionDefinitionObjectsTable struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResourcePipelineIngestionDefinitionObjects struct {
|
type ResourcePipelineIngestionDefinitionObjects struct {
|
||||||
|
Report *ResourcePipelineIngestionDefinitionObjectsReport `json:"report,omitempty"`
|
||||||
Schema *ResourcePipelineIngestionDefinitionObjectsSchema `json:"schema,omitempty"`
|
Schema *ResourcePipelineIngestionDefinitionObjectsSchema `json:"schema,omitempty"`
|
||||||
Table *ResourcePipelineIngestionDefinitionObjectsTable `json:"table,omitempty"`
|
Table *ResourcePipelineIngestionDefinitionObjectsTable `json:"table,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -181,6 +199,7 @@ type ResourcePipelineIngestionDefinitionTableConfiguration struct {
|
||||||
PrimaryKeys []string `json:"primary_keys,omitempty"`
|
PrimaryKeys []string `json:"primary_keys,omitempty"`
|
||||||
SalesforceIncludeFormulaFields bool `json:"salesforce_include_formula_fields,omitempty"`
|
SalesforceIncludeFormulaFields bool `json:"salesforce_include_formula_fields,omitempty"`
|
||||||
ScdType string `json:"scd_type,omitempty"`
|
ScdType string `json:"scd_type,omitempty"`
|
||||||
|
SequenceBy []string `json:"sequence_by,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResourcePipelineIngestionDefinition struct {
|
type ResourcePipelineIngestionDefinition struct {
|
||||||
|
|
|
@ -21,7 +21,7 @@ type Root struct {
|
||||||
|
|
||||||
const ProviderHost = "registry.terraform.io"
|
const ProviderHost = "registry.terraform.io"
|
||||||
const ProviderSource = "databricks/databricks"
|
const ProviderSource = "databricks/databricks"
|
||||||
const ProviderVersion = "1.53.0"
|
const ProviderVersion = "1.54.0"
|
||||||
|
|
||||||
func NewRoot() *Root {
|
func NewRoot() *Root {
|
||||||
return &Root{
|
return &Root{
|
||||||
|
|
|
@ -57,6 +57,12 @@ func IsLibraryLocal(dep string) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the dependency starts with --, it's a pip flag option which is a valid
|
||||||
|
// entry for environment dependencies but not a local path
|
||||||
|
if containsPipFlag(dep) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// If the dependency is a requirements file, it's not a valid local path
|
// If the dependency is a requirements file, it's not a valid local path
|
||||||
if strings.HasPrefix(dep, "-r") {
|
if strings.HasPrefix(dep, "-r") {
|
||||||
return false
|
return false
|
||||||
|
@ -70,6 +76,11 @@ func IsLibraryLocal(dep string) bool {
|
||||||
return IsLocalPath(dep)
|
return IsLocalPath(dep)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func containsPipFlag(input string) bool {
|
||||||
|
re := regexp.MustCompile(`--[a-zA-Z0-9-]+`)
|
||||||
|
return re.MatchString(input)
|
||||||
|
}
|
||||||
|
|
||||||
// ^[a-zA-Z0-9\-_]+: Matches the package name, allowing alphanumeric characters, dashes (-), and underscores (_).
|
// ^[a-zA-Z0-9\-_]+: Matches the package name, allowing alphanumeric characters, dashes (-), and underscores (_).
|
||||||
// \[.*\])?: Optionally matches any extras specified in square brackets, e.g., [security].
|
// \[.*\])?: Optionally matches any extras specified in square brackets, e.g., [security].
|
||||||
// ((==|!=|<=|>=|~=|>|<)\d+(\.\d+){0,2}(\.\*)?): Optionally matches version specifiers, supporting various operators (==, !=, etc.) followed by a version number (e.g., 2.25.1).
|
// ((==|!=|<=|>=|~=|>|<)\d+(\.\d+){0,2}(\.\*)?): Optionally matches version specifiers, supporting various operators (==, !=, etc.) followed by a version number (e.g., 2.25.1).
|
||||||
|
|
|
@ -41,3 +41,7 @@ func IsWorkspaceLibrary(library *compute.Library) bool {
|
||||||
func IsVolumesPath(path string) bool {
|
func IsVolumesPath(path string) bool {
|
||||||
return strings.HasPrefix(path, "/Volumes/")
|
return strings.HasPrefix(path, "/Volumes/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsWorkspaceSharedPath(path string) bool {
|
||||||
|
return strings.HasPrefix(path, "/Workspace/Shared/")
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
const CAN_MANAGE = "CAN_MANAGE"
|
const CAN_MANAGE = "CAN_MANAGE"
|
||||||
const CAN_VIEW = "CAN_VIEW"
|
const CAN_VIEW = "CAN_VIEW"
|
||||||
const CAN_RUN = "CAN_RUN"
|
const CAN_RUN = "CAN_RUN"
|
||||||
const IS_OWNER = "IS_OWNER"
|
|
||||||
|
|
||||||
var allowedLevels = []string{CAN_MANAGE, CAN_VIEW, CAN_RUN}
|
var allowedLevels = []string{CAN_MANAGE, CAN_VIEW, CAN_RUN}
|
||||||
var levelsMap = map[string](map[string]string){
|
var levelsMap = map[string](map[string]string){
|
||||||
|
|
|
@ -5,8 +5,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/libs/auth"
|
|
||||||
"github.com/databricks/cli/libs/diag"
|
"github.com/databricks/cli/libs/diag"
|
||||||
|
"github.com/databricks/cli/libs/iamutil"
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,9 +17,10 @@ import (
|
||||||
func ReportPossiblePermissionDenied(ctx context.Context, b *bundle.Bundle, path string) diag.Diagnostics {
|
func ReportPossiblePermissionDenied(ctx context.Context, b *bundle.Bundle, path string) diag.Diagnostics {
|
||||||
log.Errorf(ctx, "Failed to update, encountered possible permission error: %v", path)
|
log.Errorf(ctx, "Failed to update, encountered possible permission error: %v", path)
|
||||||
|
|
||||||
user := b.Config.Workspace.CurrentUser.UserName
|
me := b.Config.Workspace.CurrentUser.User
|
||||||
if auth.IsServicePrincipal(user) {
|
userName := me.UserName
|
||||||
user = b.Config.Workspace.CurrentUser.DisplayName
|
if iamutil.IsServicePrincipal(me) {
|
||||||
|
userName = me.DisplayName
|
||||||
}
|
}
|
||||||
canManageBundle, assistance := analyzeBundlePermissions(b)
|
canManageBundle, assistance := analyzeBundlePermissions(b)
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ func ReportPossiblePermissionDenied(ctx context.Context, b *bundle.Bundle, path
|
||||||
"%s\n"+
|
"%s\n"+
|
||||||
"They may need to redeploy the bundle to apply the new permissions.\n"+
|
"They may need to redeploy the bundle to apply the new permissions.\n"+
|
||||||
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.",
|
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.",
|
||||||
path, user, assistance),
|
path, userName, assistance),
|
||||||
Severity: diag.Error,
|
Severity: diag.Error,
|
||||||
ID: diag.PathPermissionDenied,
|
ID: diag.PathPermissionDenied,
|
||||||
}}
|
}}
|
||||||
|
@ -44,7 +45,7 @@ func ReportPossiblePermissionDenied(ctx context.Context, b *bundle.Bundle, path
|
||||||
"%s\n"+
|
"%s\n"+
|
||||||
"They can redeploy the project to apply the latest set of permissions.\n"+
|
"They can redeploy the project to apply the latest set of permissions.\n"+
|
||||||
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.",
|
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.",
|
||||||
path, user, assistance),
|
path, userName, assistance),
|
||||||
Severity: diag.Error,
|
Severity: diag.Error,
|
||||||
ID: diag.CannotChangePathPermissions,
|
ID: diag.CannotChangePathPermissions,
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package permissions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/bundle/libraries"
|
||||||
|
"github.com/databricks/cli/libs/diag"
|
||||||
|
)
|
||||||
|
|
||||||
|
type validateSharedRootPermissions struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func ValidateSharedRootPermissions() bundle.Mutator {
|
||||||
|
return &validateSharedRootPermissions{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*validateSharedRootPermissions) Name() string {
|
||||||
|
return "ValidateSharedRootPermissions"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*validateSharedRootPermissions) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
||||||
|
if libraries.IsWorkspaceSharedPath(b.Config.Workspace.RootPath) {
|
||||||
|
return isUsersGroupPermissionSet(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// isUsersGroupPermissionSet checks that top-level permissions set for bundle contain group_name: users with CAN_MANAGE permission.
|
||||||
|
func isUsersGroupPermissionSet(b *bundle.Bundle) diag.Diagnostics {
|
||||||
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
|
allUsers := false
|
||||||
|
for _, p := range b.Config.Permissions {
|
||||||
|
if p.GroupName == "users" && p.Level == CAN_MANAGE {
|
||||||
|
allUsers = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !allUsers {
|
||||||
|
diags = diags.Append(diag.Diagnostic{
|
||||||
|
Severity: diag.Warning,
|
||||||
|
Summary: fmt.Sprintf("the bundle root path %s is writable by all workspace users", b.Config.Workspace.RootPath),
|
||||||
|
Detail: "The bundle is configured to use /Workspace/Shared, which will give read/write access to all users. If this is intentional, add CAN_MANAGE for 'group_name: users' permission to your bundle configuration. If the deployment should be restricted, move it to a restricted folder such as /Workspace/Users/<username or principal name>.",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return diags
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package permissions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/bundle/config"
|
||||||
|
"github.com/databricks/cli/bundle/config/resources"
|
||||||
|
"github.com/databricks/cli/libs/diag"
|
||||||
|
"github.com/databricks/databricks-sdk-go/experimental/mocks"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/jobs"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestValidateSharedRootPermissionsForShared(t *testing.T) {
|
||||||
|
b := &bundle.Bundle{
|
||||||
|
Config: config.Root{
|
||||||
|
Workspace: config.Workspace{
|
||||||
|
RootPath: "/Workspace/Shared/foo/bar",
|
||||||
|
},
|
||||||
|
Permissions: []resources.Permission{
|
||||||
|
{Level: CAN_MANAGE, GroupName: "users"},
|
||||||
|
},
|
||||||
|
Resources: config.Resources{
|
||||||
|
Jobs: map[string]*resources.Job{
|
||||||
|
"job_1": {JobSettings: &jobs.JobSettings{Name: "job_1"}},
|
||||||
|
"job_2": {JobSettings: &jobs.JobSettings{Name: "job_2"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
m := mocks.NewMockWorkspaceClient(t)
|
||||||
|
b.SetWorkpaceClient(m.WorkspaceClient)
|
||||||
|
|
||||||
|
diags := bundle.Apply(context.Background(), b, bundle.Seq(ValidateSharedRootPermissions()))
|
||||||
|
require.Empty(t, diags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValidateSharedRootPermissionsForSharedError(t *testing.T) {
|
||||||
|
b := &bundle.Bundle{
|
||||||
|
Config: config.Root{
|
||||||
|
Workspace: config.Workspace{
|
||||||
|
RootPath: "/Workspace/Shared/foo/bar",
|
||||||
|
},
|
||||||
|
Permissions: []resources.Permission{
|
||||||
|
{Level: CAN_MANAGE, UserName: "foo@bar.com"},
|
||||||
|
},
|
||||||
|
Resources: config.Resources{
|
||||||
|
Jobs: map[string]*resources.Job{
|
||||||
|
"job_1": {JobSettings: &jobs.JobSettings{Name: "job_1"}},
|
||||||
|
"job_2": {JobSettings: &jobs.JobSettings{Name: "job_2"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
m := mocks.NewMockWorkspaceClient(t)
|
||||||
|
b.SetWorkpaceClient(m.WorkspaceClient)
|
||||||
|
|
||||||
|
diags := bundle.Apply(context.Background(), b, bundle.Seq(ValidateSharedRootPermissions()))
|
||||||
|
require.Len(t, diags, 1)
|
||||||
|
require.Equal(t, "the bundle root path /Workspace/Shared/foo/bar is writable by all workspace users", diags[0].Summary)
|
||||||
|
require.Equal(t, diag.Warning, diags[0].Severity)
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ func ObjectAclToResourcePermissions(path string, acl []workspace.WorkspaceObject
|
||||||
permissions := make([]resources.Permission, 0)
|
permissions := make([]resources.Permission, 0)
|
||||||
for _, a := range acl {
|
for _, a := range acl {
|
||||||
// Skip the admin group because it's added to all resources by default.
|
// Skip the admin group because it's added to all resources by default.
|
||||||
if a.GroupName == "admin" {
|
if a.GroupName == "admins" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,22 +38,12 @@ func ObjectAclToResourcePermissions(path string, acl []workspace.WorkspaceObject
|
||||||
func (p WorkspacePathPermissions) Compare(perms []resources.Permission) diag.Diagnostics {
|
func (p WorkspacePathPermissions) Compare(perms []resources.Permission) diag.Diagnostics {
|
||||||
var diags diag.Diagnostics
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
// Check the permissions in the bundle and see if they are all set in the workspace.
|
|
||||||
ok, missing := containsAll(perms, p.Permissions)
|
|
||||||
if !ok {
|
|
||||||
diags = diags.Append(diag.Diagnostic{
|
|
||||||
Severity: diag.Warning,
|
|
||||||
Summary: "permissions missing",
|
|
||||||
Detail: fmt.Sprintf("The following permissions are configured in the bundle but are do not (yet) apply to the workspace folder at %q:\n%s", p.Path, toString(missing)),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the permissions in the workspace and see if they are all set in the bundle.
|
// Check the permissions in the workspace and see if they are all set in the bundle.
|
||||||
ok, missing = containsAll(p.Permissions, perms)
|
ok, missing := containsAll(p.Permissions, perms)
|
||||||
if !ok {
|
if !ok {
|
||||||
diags = diags.Append(diag.Diagnostic{
|
diags = diags.Append(diag.Diagnostic{
|
||||||
Severity: diag.Warning,
|
Severity: diag.Warning,
|
||||||
Summary: "permissions missing",
|
Summary: "untracked permissions apply to target workspace path",
|
||||||
Detail: fmt.Sprintf("The following permissions apply to the workspace folder at %q but are not configured in the bundle:\n%s", p.Path, toString(missing)),
|
Detail: fmt.Sprintf("The following permissions apply to the workspace folder at %q but are not configured in the bundle:\n%s", p.Path, toString(missing)),
|
||||||
})
|
})
|
||||||
}
|
}
|
|
@ -41,7 +41,7 @@ func TestWorkspacePathPermissionsCompare(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
GroupName: "admin",
|
GroupName: "admins",
|
||||||
AllPermissions: []workspace.WorkspaceObjectPermission{
|
AllPermissions: []workspace.WorkspaceObjectPermission{
|
||||||
{PermissionLevel: "CAN_MANAGE"},
|
{PermissionLevel: "CAN_MANAGE"},
|
||||||
},
|
},
|
||||||
|
@ -62,13 +62,7 @@ func TestWorkspacePathPermissionsCompare(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: diag.Diagnostics{
|
expected: nil,
|
||||||
{
|
|
||||||
Severity: diag.Warning,
|
|
||||||
Summary: "permissions missing",
|
|
||||||
Detail: "The following permissions are configured in the bundle but are do not (yet) apply to the workspace folder at \"path\":\n- level: CAN_MANAGE, service_principal_name: sp.com\n",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
perms: []resources.Permission{
|
perms: []resources.Permission{
|
||||||
|
@ -91,7 +85,7 @@ func TestWorkspacePathPermissionsCompare(t *testing.T) {
|
||||||
expected: diag.Diagnostics{
|
expected: diag.Diagnostics{
|
||||||
{
|
{
|
||||||
Severity: diag.Warning,
|
Severity: diag.Warning,
|
||||||
Summary: "permissions missing",
|
Summary: "untracked permissions apply to target workspace path",
|
||||||
Detail: "The following permissions apply to the workspace folder at \"path\" but are not configured in the bundle:\n- level: CAN_MANAGE, group_name: foo\n",
|
Detail: "The following permissions apply to the workspace folder at \"path\" but are not configured in the bundle:\n- level: CAN_MANAGE, group_name: foo\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -111,12 +105,7 @@ func TestWorkspacePathPermissionsCompare(t *testing.T) {
|
||||||
expected: diag.Diagnostics{
|
expected: diag.Diagnostics{
|
||||||
{
|
{
|
||||||
Severity: diag.Warning,
|
Severity: diag.Warning,
|
||||||
Summary: "permissions missing",
|
Summary: "untracked permissions apply to target workspace path",
|
||||||
Detail: "The following permissions are configured in the bundle but are do not (yet) apply to the workspace folder at \"path\":\n- level: CAN_MANAGE, user_name: foo@bar.com\n",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Severity: diag.Warning,
|
|
||||||
Summary: "permissions missing",
|
|
||||||
Detail: "The following permissions apply to the workspace folder at \"path\" but are not configured in the bundle:\n- level: CAN_MANAGE, user_name: foo2@bar.com\n",
|
Detail: "The following permissions apply to the workspace folder at \"path\" but are not configured in the bundle:\n- level: CAN_MANAGE, user_name: foo2@bar.com\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
|
@ -16,6 +16,10 @@ func ApplyWorkspaceRootPermissions() bundle.Mutator {
|
||||||
return &workspaceRootPermissions{}
|
return &workspaceRootPermissions{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (*workspaceRootPermissions) Name() string {
|
||||||
|
return "ApplyWorkspaceRootPermissions"
|
||||||
|
}
|
||||||
|
|
||||||
// Apply implements bundle.Mutator.
|
// Apply implements bundle.Mutator.
|
||||||
func (*workspaceRootPermissions) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
func (*workspaceRootPermissions) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
||||||
err := giveAccessForWorkspaceRoot(ctx, b)
|
err := giveAccessForWorkspaceRoot(ctx, b)
|
||||||
|
@ -26,10 +30,6 @@ func (*workspaceRootPermissions) Apply(ctx context.Context, b *bundle.Bundle) di
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*workspaceRootPermissions) Name() string {
|
|
||||||
return "ApplyWorkspaceRootPermissions"
|
|
||||||
}
|
|
||||||
|
|
||||||
func giveAccessForWorkspaceRoot(ctx context.Context, b *bundle.Bundle) error {
|
func giveAccessForWorkspaceRoot(ctx context.Context, b *bundle.Bundle) error {
|
||||||
permissions := make([]workspace.WorkspaceObjectAccessControlRequest, 0)
|
permissions := make([]workspace.WorkspaceObjectAccessControlRequest, 0)
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,6 @@ func TestApplyWorkspaceRootPermissions(t *testing.T) {
|
||||||
WorkspaceObjectType: "directories",
|
WorkspaceObjectType: "directories",
|
||||||
}).Return(nil, nil)
|
}).Return(nil, nil)
|
||||||
|
|
||||||
diags := bundle.Apply(context.Background(), b, ApplyWorkspaceRootPermissions())
|
diags := bundle.Apply(context.Background(), b, bundle.Seq(ValidateSharedRootPermissions(), ApplyWorkspaceRootPermissions()))
|
||||||
require.NoError(t, diags.Error())
|
require.Empty(t, diags)
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,11 @@ func Initialize() bundle.Mutator {
|
||||||
|
|
||||||
mutator.TranslatePaths(),
|
mutator.TranslatePaths(),
|
||||||
trampoline.WrapperWarning(),
|
trampoline.WrapperWarning(),
|
||||||
|
|
||||||
|
permissions.ValidateSharedRootPermissions(),
|
||||||
permissions.ApplyBundlePermissions(),
|
permissions.ApplyBundlePermissions(),
|
||||||
permissions.FilterCurrentUser(),
|
permissions.FilterCurrentUser(),
|
||||||
|
|
||||||
metadata.AnnotateJobs(),
|
metadata.AnnotateJobs(),
|
||||||
metadata.AnnotatePipelines(),
|
metadata.AnnotatePipelines(),
|
||||||
terraform.Initialize(),
|
terraform.Initialize(),
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
package render
|
package render
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
"github.com/databricks/cli/libs/diag"
|
"github.com/databricks/cli/libs/diag"
|
||||||
"github.com/databricks/databricks-sdk-go/service/iam"
|
"github.com/databricks/databricks-sdk-go/service/iam"
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
|
@ -28,49 +31,7 @@ var renderFuncMap = template.FuncMap{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const errorTemplate = `{{ "Error" | red }}: {{ .Summary }}
|
const summaryHeaderTemplate = `{{- if .Name -}}
|
||||||
{{- range $index, $element := .Paths }}
|
|
||||||
{{ if eq $index 0 }}at {{else}} {{ end}}{{ $element.String | green }}
|
|
||||||
{{- end }}
|
|
||||||
{{- range $index, $element := .Locations }}
|
|
||||||
{{ if eq $index 0 }}in {{else}} {{ end}}{{ $element.String | cyan }}
|
|
||||||
{{- end }}
|
|
||||||
{{- if .Detail }}
|
|
||||||
|
|
||||||
{{ .Detail }}
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
`
|
|
||||||
|
|
||||||
const warningTemplate = `{{ "Warning" | yellow }}: {{ .Summary }}
|
|
||||||
{{- range $index, $element := .Paths }}
|
|
||||||
{{ if eq $index 0 }}at {{else}} {{ end}}{{ $element.String | green }}
|
|
||||||
{{- end }}
|
|
||||||
{{- range $index, $element := .Locations }}
|
|
||||||
{{ if eq $index 0 }}in {{else}} {{ end}}{{ $element.String | cyan }}
|
|
||||||
{{- end }}
|
|
||||||
{{- if .Detail }}
|
|
||||||
|
|
||||||
{{ .Detail }}
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
`
|
|
||||||
|
|
||||||
const recommendationTemplate = `{{ "Recommendation" | blue }}: {{ .Summary }}
|
|
||||||
{{- range $index, $element := .Paths }}
|
|
||||||
{{ if eq $index 0 }}at {{else}} {{ end}}{{ $element.String | green }}
|
|
||||||
{{- end }}
|
|
||||||
{{- range $index, $element := .Locations }}
|
|
||||||
{{ if eq $index 0 }}in {{else}} {{ end}}{{ $element.String | cyan }}
|
|
||||||
{{- end }}
|
|
||||||
{{- if .Detail }}
|
|
||||||
|
|
||||||
{{ .Detail }}
|
|
||||||
{{- end }}
|
|
||||||
|
|
||||||
`
|
|
||||||
|
|
||||||
const summaryTemplate = `{{- if .Name -}}
|
|
||||||
Name: {{ .Name | bold }}
|
Name: {{ .Name | bold }}
|
||||||
{{- if .Target }}
|
{{- if .Target }}
|
||||||
Target: {{ .Target | bold }}
|
Target: {{ .Target | bold }}
|
||||||
|
@ -87,12 +48,30 @@ Workspace:
|
||||||
Path: {{ .Path | bold }}
|
Path: {{ .Path | bold }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{ end -}}`
|
||||||
|
|
||||||
{{ end -}}
|
const resourcesTemplate = `Resources:
|
||||||
|
{{- range . }}
|
||||||
{{ .Trailer }}
|
{{ .GroupName }}:
|
||||||
|
{{- range .Resources }}
|
||||||
|
{{ .Key | bold }}:
|
||||||
|
Name: {{ .Name }}
|
||||||
|
URL: {{ if .URL }}{{ .URL | cyan }}{{ else }}{{ "(not deployed)" | cyan }}{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
type ResourceGroup struct {
|
||||||
|
GroupName string
|
||||||
|
Resources []ResourceInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResourceInfo struct {
|
||||||
|
Key string
|
||||||
|
Name string
|
||||||
|
URL string
|
||||||
|
}
|
||||||
|
|
||||||
func pluralize(n int, singular, plural string) string {
|
func pluralize(n int, singular, plural string) string {
|
||||||
if n == 1 {
|
if n == 1 {
|
||||||
return fmt.Sprintf("%d %s", n, singular)
|
return fmt.Sprintf("%d %s", n, singular)
|
||||||
|
@ -115,20 +94,20 @@ func buildTrailer(diags diag.Diagnostics) string {
|
||||||
case len(parts) >= 3:
|
case len(parts) >= 3:
|
||||||
first := strings.Join(parts[:len(parts)-1], ", ")
|
first := strings.Join(parts[:len(parts)-1], ", ")
|
||||||
last := parts[len(parts)-1]
|
last := parts[len(parts)-1]
|
||||||
return fmt.Sprintf("Found %s, and %s", first, last)
|
return fmt.Sprintf("Found %s, and %s\n", first, last)
|
||||||
case len(parts) == 2:
|
case len(parts) == 2:
|
||||||
return fmt.Sprintf("Found %s and %s", parts[0], parts[1])
|
return fmt.Sprintf("Found %s and %s\n", parts[0], parts[1])
|
||||||
case len(parts) == 1:
|
case len(parts) == 1:
|
||||||
return fmt.Sprintf("Found %s", parts[0])
|
return fmt.Sprintf("Found %s\n", parts[0])
|
||||||
default:
|
default:
|
||||||
// No diagnostics to print.
|
// No diagnostics to print.
|
||||||
return color.GreenString("Validation OK!")
|
return color.GreenString("Validation OK!\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderSummaryTemplate(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics) error {
|
func renderSummaryHeaderTemplate(out io.Writer, b *bundle.Bundle) error {
|
||||||
if b == nil {
|
if b == nil {
|
||||||
return renderSummaryTemplate(out, &bundle.Bundle{}, diags)
|
return renderSummaryHeaderTemplate(out, &bundle.Bundle{})
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentUser = &iam.User{}
|
var currentUser = &iam.User{}
|
||||||
|
@ -139,36 +118,20 @@ func renderSummaryTemplate(out io.Writer, b *bundle.Bundle, diags diag.Diagnosti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t := template.Must(template.New("summary").Funcs(renderFuncMap).Parse(summaryTemplate))
|
t := template.Must(template.New("summary").Funcs(renderFuncMap).Parse(summaryHeaderTemplate))
|
||||||
err := t.Execute(out, map[string]any{
|
err := t.Execute(out, map[string]any{
|
||||||
"Name": b.Config.Bundle.Name,
|
"Name": b.Config.Bundle.Name,
|
||||||
"Target": b.Config.Bundle.Target,
|
"Target": b.Config.Bundle.Target,
|
||||||
"User": currentUser.UserName,
|
"User": currentUser.UserName,
|
||||||
"Path": b.Config.Workspace.RootPath,
|
"Path": b.Config.Workspace.RootPath,
|
||||||
"Host": b.Config.Workspace.Host,
|
"Host": b.Config.Workspace.Host,
|
||||||
"Trailer": buildTrailer(diags),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderDiagnostics(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics) error {
|
func renderDiagnosticsOnly(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics) error {
|
||||||
errorT := template.Must(template.New("error").Funcs(renderFuncMap).Parse(errorTemplate))
|
|
||||||
warningT := template.Must(template.New("warning").Funcs(renderFuncMap).Parse(warningTemplate))
|
|
||||||
recommendationT := template.Must(template.New("recommendation").Funcs(renderFuncMap).Parse(recommendationTemplate))
|
|
||||||
|
|
||||||
// Print errors and warnings.
|
|
||||||
for _, d := range diags {
|
for _, d := range diags {
|
||||||
var t *template.Template
|
|
||||||
switch d.Severity {
|
|
||||||
case diag.Error:
|
|
||||||
t = errorT
|
|
||||||
case diag.Warning:
|
|
||||||
t = warningT
|
|
||||||
case diag.Recommendation:
|
|
||||||
t = recommendationT
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := range d.Locations {
|
for i := range d.Locations {
|
||||||
if b == nil {
|
if b == nil {
|
||||||
break
|
break
|
||||||
|
@ -183,15 +146,9 @@ func renderDiagnostics(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the diagnostic with the appropriate template.
|
|
||||||
err := t.Execute(out, d)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to render template: %w", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return cmdio.RenderDiagnostics(out, diags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenderOptions contains options for rendering diagnostics.
|
// RenderOptions contains options for rendering diagnostics.
|
||||||
|
@ -201,19 +158,73 @@ type RenderOptions struct {
|
||||||
RenderSummaryTable bool
|
RenderSummaryTable bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenderTextOutput renders the diagnostics in a human-readable format.
|
// RenderDiagnostics renders the diagnostics in a human-readable format.
|
||||||
func RenderTextOutput(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics, opts RenderOptions) error {
|
func RenderDiagnostics(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics, opts RenderOptions) error {
|
||||||
err := renderDiagnostics(out, b, diags)
|
err := renderDiagnosticsOnly(out, b, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to render diagnostics: %w", err)
|
return fmt.Errorf("failed to render diagnostics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.RenderSummaryTable {
|
if opts.RenderSummaryTable {
|
||||||
err = renderSummaryTemplate(out, b, diags)
|
if b != nil {
|
||||||
|
err = renderSummaryHeaderTemplate(out, b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to render summary: %w", err)
|
return fmt.Errorf("failed to render summary: %w", err)
|
||||||
}
|
}
|
||||||
|
io.WriteString(out, "\n")
|
||||||
|
}
|
||||||
|
trailer := buildTrailer(diags)
|
||||||
|
io.WriteString(out, trailer)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RenderSummary(ctx context.Context, out io.Writer, b *bundle.Bundle) error {
|
||||||
|
if err := renderSummaryHeaderTemplate(out, b); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resourceGroups []ResourceGroup
|
||||||
|
|
||||||
|
for _, group := range b.Config.Resources.AllResources() {
|
||||||
|
resources := make([]ResourceInfo, 0, len(group.Resources))
|
||||||
|
for key, resource := range group.Resources {
|
||||||
|
resources = append(resources, ResourceInfo{
|
||||||
|
Key: key,
|
||||||
|
Name: resource.GetName(),
|
||||||
|
URL: resource.GetURL(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(resources) > 0 {
|
||||||
|
resourceGroups = append(resourceGroups, ResourceGroup{
|
||||||
|
GroupName: group.Description.PluralTitle,
|
||||||
|
Resources: resources,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := renderResourcesTemplate(out, resourceGroups); err != nil {
|
||||||
|
return fmt.Errorf("failed to render resources template: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to sort and render resource groups using the template
|
||||||
|
func renderResourcesTemplate(out io.Writer, resourceGroups []ResourceGroup) error {
|
||||||
|
// Sort everything to ensure consistent output
|
||||||
|
sort.Slice(resourceGroups, func(i, j int) bool {
|
||||||
|
return resourceGroups[i].GroupName < resourceGroups[j].GroupName
|
||||||
|
})
|
||||||
|
for _, group := range resourceGroups {
|
||||||
|
sort.Slice(group.Resources, func(i, j int) bool {
|
||||||
|
return group.Resources[i].Key < group.Resources[j].Key
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
t := template.Must(template.New("resources").Funcs(renderFuncMap).Parse(resourcesTemplate))
|
||||||
|
|
||||||
|
return t.Execute(out, resourceGroups)
|
||||||
|
}
|
||||||
|
|
|
@ -2,14 +2,21 @@ package render
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
|
"github.com/databricks/cli/bundle/config/resources"
|
||||||
"github.com/databricks/cli/libs/diag"
|
"github.com/databricks/cli/libs/diag"
|
||||||
"github.com/databricks/cli/libs/dyn"
|
"github.com/databricks/cli/libs/dyn"
|
||||||
assert "github.com/databricks/cli/libs/dyn/dynassert"
|
"github.com/databricks/databricks-sdk-go/service/catalog"
|
||||||
"github.com/databricks/databricks-sdk-go/service/iam"
|
"github.com/databricks/databricks-sdk-go/service/iam"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/jobs"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/pipelines"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/serving"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -326,7 +333,7 @@ func TestRenderTextOutput(t *testing.T) {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
writer := &bytes.Buffer{}
|
writer := &bytes.Buffer{}
|
||||||
|
|
||||||
err := RenderTextOutput(writer, tc.bundle, tc.diags, tc.opts)
|
err := RenderDiagnostics(writer, tc.bundle, tc.diags, tc.opts)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, tc.expected, writer.String())
|
assert.Equal(t, tc.expected, writer.String())
|
||||||
|
@ -468,7 +475,7 @@ func TestRenderDiagnostics(t *testing.T) {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
writer := &bytes.Buffer{}
|
writer := &bytes.Buffer{}
|
||||||
|
|
||||||
err := renderDiagnostics(writer, bundle, tc.diags)
|
err := renderDiagnosticsOnly(writer, bundle, tc.diags)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, tc.expected, writer.String())
|
assert.Equal(t, tc.expected, writer.String())
|
||||||
|
@ -479,8 +486,105 @@ func TestRenderDiagnostics(t *testing.T) {
|
||||||
func TestRenderSummaryTemplate_nilBundle(t *testing.T) {
|
func TestRenderSummaryTemplate_nilBundle(t *testing.T) {
|
||||||
writer := &bytes.Buffer{}
|
writer := &bytes.Buffer{}
|
||||||
|
|
||||||
err := renderSummaryTemplate(writer, nil, nil)
|
err := renderSummaryHeaderTemplate(writer, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
io.WriteString(writer, buildTrailer(nil))
|
||||||
|
|
||||||
assert.Equal(t, "Validation OK!\n", writer.String())
|
assert.Equal(t, "Validation OK!\n", writer.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRenderSummary(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
// Create a mock bundle with various resources
|
||||||
|
b := &bundle.Bundle{
|
||||||
|
Config: config.Root{
|
||||||
|
Bundle: config.Bundle{
|
||||||
|
Name: "test-bundle",
|
||||||
|
Target: "test-target",
|
||||||
|
},
|
||||||
|
Workspace: config.Workspace{
|
||||||
|
Host: "https://mycompany.databricks.com/",
|
||||||
|
},
|
||||||
|
Resources: config.Resources{
|
||||||
|
Jobs: map[string]*resources.Job{
|
||||||
|
"job1": {
|
||||||
|
ID: "1",
|
||||||
|
URL: "https://url1",
|
||||||
|
JobSettings: &jobs.JobSettings{Name: "job1-name"},
|
||||||
|
},
|
||||||
|
"job2": {
|
||||||
|
ID: "2",
|
||||||
|
URL: "https://url2",
|
||||||
|
JobSettings: &jobs.JobSettings{Name: "job2-name"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Pipelines: map[string]*resources.Pipeline{
|
||||||
|
"pipeline2": {
|
||||||
|
ID: "4",
|
||||||
|
// no URL
|
||||||
|
PipelineSpec: &pipelines.PipelineSpec{Name: "pipeline2-name"},
|
||||||
|
},
|
||||||
|
"pipeline1": {
|
||||||
|
ID: "3",
|
||||||
|
URL: "https://url3",
|
||||||
|
PipelineSpec: &pipelines.PipelineSpec{Name: "pipeline1-name"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Schemas: map[string]*resources.Schema{
|
||||||
|
"schema1": {
|
||||||
|
ID: "catalog.schema",
|
||||||
|
CreateSchema: &catalog.CreateSchema{
|
||||||
|
Name: "schema",
|
||||||
|
},
|
||||||
|
// no URL
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ModelServingEndpoints: map[string]*resources.ModelServingEndpoint{
|
||||||
|
"endpoint1": {
|
||||||
|
ID: "7",
|
||||||
|
CreateServingEndpoint: &serving.CreateServingEndpoint{
|
||||||
|
Name: "my_serving_endpoint",
|
||||||
|
},
|
||||||
|
URL: "https://url4",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
writer := &bytes.Buffer{}
|
||||||
|
err := RenderSummary(ctx, writer, b)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
expectedSummary := `Name: test-bundle
|
||||||
|
Target: test-target
|
||||||
|
Workspace:
|
||||||
|
Host: https://mycompany.databricks.com/
|
||||||
|
Resources:
|
||||||
|
Jobs:
|
||||||
|
job1:
|
||||||
|
Name: job1-name
|
||||||
|
URL: https://url1
|
||||||
|
job2:
|
||||||
|
Name: job2-name
|
||||||
|
URL: https://url2
|
||||||
|
Model Serving Endpoints:
|
||||||
|
endpoint1:
|
||||||
|
Name: my_serving_endpoint
|
||||||
|
URL: https://url4
|
||||||
|
Pipelines:
|
||||||
|
pipeline1:
|
||||||
|
Name: pipeline1-name
|
||||||
|
URL: https://url3
|
||||||
|
pipeline2:
|
||||||
|
Name: pipeline2-name
|
||||||
|
URL: (not deployed)
|
||||||
|
Schemas:
|
||||||
|
schema1:
|
||||||
|
Name: schema
|
||||||
|
URL: (not deployed)
|
||||||
|
`
|
||||||
|
assert.Equal(t, expectedSummary, writer.String())
|
||||||
|
}
|
||||||
|
|
|
@ -317,6 +317,29 @@ func (r *jobRunner) Cancel(ctx context.Context) error {
|
||||||
return errGroup.Wait()
|
return errGroup.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *jobRunner) Restart(ctx context.Context, opts *Options) (output.RunOutput, error) {
|
||||||
|
// We don't need to cancel existing runs if the job is continuous and unpaused.
|
||||||
|
// the /jobs/run-now API will automatically cancel any existing runs before starting a new one.
|
||||||
|
//
|
||||||
|
// /jobs/run-now will not cancel existing runs if the job is continuous and paused.
|
||||||
|
// New job runs will be queued instead and will wait for existing runs to finish.
|
||||||
|
// In this case, we need to cancel the existing runs before starting a new one.
|
||||||
|
continuous := r.job.JobSettings.Continuous
|
||||||
|
if continuous != nil && continuous.PauseStatus == jobs.PauseStatusUnpaused {
|
||||||
|
return r.Run(ctx, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
s := cmdio.Spinner(ctx)
|
||||||
|
s <- "Cancelling all active job runs"
|
||||||
|
err := r.Cancel(ctx)
|
||||||
|
close(s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.Run(ctx, opts)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *jobRunner) ParseArgs(args []string, opts *Options) error {
|
func (r *jobRunner) ParseArgs(args []string, opts *Options) error {
|
||||||
return r.posArgsHandler().ParseArgs(args, opts)
|
return r.posArgsHandler().ParseArgs(args, opts)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package run
|
package run
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -8,6 +9,8 @@ import (
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
"github.com/databricks/cli/bundle/config/resources"
|
"github.com/databricks/cli/bundle/config/resources"
|
||||||
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
"github.com/databricks/cli/libs/flags"
|
||||||
"github.com/databricks/databricks-sdk-go/experimental/mocks"
|
"github.com/databricks/databricks-sdk-go/experimental/mocks"
|
||||||
"github.com/databricks/databricks-sdk-go/service/jobs"
|
"github.com/databricks/databricks-sdk-go/service/jobs"
|
||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
|
@ -126,3 +129,132 @@ func TestJobRunnerCancelWithNoActiveRuns(t *testing.T) {
|
||||||
err := runner.Cancel(context.Background())
|
err := runner.Cancel(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestJobRunnerRestart(t *testing.T) {
|
||||||
|
for _, jobSettings := range []*jobs.JobSettings{
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
Continuous: &jobs.Continuous{
|
||||||
|
PauseStatus: jobs.PauseStatusPaused,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
job := &resources.Job{
|
||||||
|
ID: "123",
|
||||||
|
JobSettings: jobSettings,
|
||||||
|
}
|
||||||
|
b := &bundle.Bundle{
|
||||||
|
Config: config.Root{
|
||||||
|
Resources: config.Resources{
|
||||||
|
Jobs: map[string]*resources.Job{
|
||||||
|
"test_job": job,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
runner := jobRunner{key: "test", bundle: b, job: job}
|
||||||
|
|
||||||
|
m := mocks.NewMockWorkspaceClient(t)
|
||||||
|
b.SetWorkpaceClient(m.WorkspaceClient)
|
||||||
|
ctx := context.Background()
|
||||||
|
ctx = cmdio.InContext(ctx, cmdio.NewIO(flags.OutputText, &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}, "", ""))
|
||||||
|
ctx = cmdio.NewContext(ctx, cmdio.NewLogger(flags.ModeAppend))
|
||||||
|
|
||||||
|
jobApi := m.GetMockJobsAPI()
|
||||||
|
jobApi.EXPECT().ListRunsAll(mock.Anything, jobs.ListRunsRequest{
|
||||||
|
ActiveOnly: true,
|
||||||
|
JobId: 123,
|
||||||
|
}).Return([]jobs.BaseRun{
|
||||||
|
{RunId: 1},
|
||||||
|
{RunId: 2},
|
||||||
|
}, nil)
|
||||||
|
|
||||||
|
// Mock the runner cancelling existing job runs.
|
||||||
|
mockWait := &jobs.WaitGetRunJobTerminatedOrSkipped[struct{}]{
|
||||||
|
Poll: func(time time.Duration, f func(j *jobs.Run)) (*jobs.Run, error) {
|
||||||
|
return nil, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
jobApi.EXPECT().CancelRun(mock.Anything, jobs.CancelRun{
|
||||||
|
RunId: 1,
|
||||||
|
}).Return(mockWait, nil)
|
||||||
|
jobApi.EXPECT().CancelRun(mock.Anything, jobs.CancelRun{
|
||||||
|
RunId: 2,
|
||||||
|
}).Return(mockWait, nil)
|
||||||
|
|
||||||
|
// Mock the runner triggering a job run
|
||||||
|
mockWaitForRun := &jobs.WaitGetRunJobTerminatedOrSkipped[jobs.RunNowResponse]{
|
||||||
|
Poll: func(d time.Duration, f func(*jobs.Run)) (*jobs.Run, error) {
|
||||||
|
return &jobs.Run{
|
||||||
|
State: &jobs.RunState{
|
||||||
|
ResultState: jobs.RunResultStateSuccess,
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
jobApi.EXPECT().RunNow(mock.Anything, jobs.RunNow{
|
||||||
|
JobId: 123,
|
||||||
|
}).Return(mockWaitForRun, nil)
|
||||||
|
|
||||||
|
// Mock the runner getting the job output
|
||||||
|
jobApi.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{}).Return(&jobs.Run{}, nil)
|
||||||
|
|
||||||
|
_, err := runner.Restart(ctx, &Options{})
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestJobRunnerRestartForContinuousUnpausedJobs(t *testing.T) {
|
||||||
|
job := &resources.Job{
|
||||||
|
ID: "123",
|
||||||
|
JobSettings: &jobs.JobSettings{
|
||||||
|
Continuous: &jobs.Continuous{
|
||||||
|
PauseStatus: jobs.PauseStatusUnpaused,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
b := &bundle.Bundle{
|
||||||
|
Config: config.Root{
|
||||||
|
Resources: config.Resources{
|
||||||
|
Jobs: map[string]*resources.Job{
|
||||||
|
"test_job": job,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
runner := jobRunner{key: "test", bundle: b, job: job}
|
||||||
|
|
||||||
|
m := mocks.NewMockWorkspaceClient(t)
|
||||||
|
b.SetWorkpaceClient(m.WorkspaceClient)
|
||||||
|
ctx := context.Background()
|
||||||
|
ctx = cmdio.InContext(ctx, cmdio.NewIO(flags.OutputText, &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}, "", "..."))
|
||||||
|
ctx = cmdio.NewContext(ctx, cmdio.NewLogger(flags.ModeAppend))
|
||||||
|
|
||||||
|
jobApi := m.GetMockJobsAPI()
|
||||||
|
|
||||||
|
// The runner should not try and cancel existing job runs for unpaused continuous jobs.
|
||||||
|
jobApi.AssertNotCalled(t, "ListRunsAll")
|
||||||
|
jobApi.AssertNotCalled(t, "CancelRun")
|
||||||
|
|
||||||
|
// Mock the runner triggering a job run
|
||||||
|
mockWaitForRun := &jobs.WaitGetRunJobTerminatedOrSkipped[jobs.RunNowResponse]{
|
||||||
|
Poll: func(d time.Duration, f func(*jobs.Run)) (*jobs.Run, error) {
|
||||||
|
return &jobs.Run{
|
||||||
|
State: &jobs.RunState{
|
||||||
|
ResultState: jobs.RunResultStateSuccess,
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
jobApi.EXPECT().RunNow(mock.Anything, jobs.RunNow{
|
||||||
|
JobId: 123,
|
||||||
|
}).Return(mockWaitForRun, nil)
|
||||||
|
|
||||||
|
// Mock the runner getting the job output
|
||||||
|
jobApi.EXPECT().GetRun(mock.Anything, jobs.GetRunRequest{}).Return(&jobs.Run{}, nil)
|
||||||
|
|
||||||
|
_, err := runner.Restart(ctx, &Options{})
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
|
@ -183,6 +183,18 @@ func (r *pipelineRunner) Cancel(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *pipelineRunner) Restart(ctx context.Context, opts *Options) (output.RunOutput, error) {
|
||||||
|
s := cmdio.Spinner(ctx)
|
||||||
|
s <- "Cancelling the active pipeline update"
|
||||||
|
err := r.Cancel(ctx)
|
||||||
|
close(s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.Run(ctx, opts)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *pipelineRunner) ParseArgs(args []string, opts *Options) error {
|
func (r *pipelineRunner) ParseArgs(args []string, opts *Options) error {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package run
|
package run
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -8,8 +9,12 @@ import (
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
"github.com/databricks/cli/bundle/config/resources"
|
"github.com/databricks/cli/bundle/config/resources"
|
||||||
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
"github.com/databricks/cli/libs/flags"
|
||||||
|
sdk_config "github.com/databricks/databricks-sdk-go/config"
|
||||||
"github.com/databricks/databricks-sdk-go/experimental/mocks"
|
"github.com/databricks/databricks-sdk-go/experimental/mocks"
|
||||||
"github.com/databricks/databricks-sdk-go/service/pipelines"
|
"github.com/databricks/databricks-sdk-go/service/pipelines"
|
||||||
|
"github.com/stretchr/testify/mock"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,3 +52,68 @@ func TestPipelineRunnerCancel(t *testing.T) {
|
||||||
err := runner.Cancel(context.Background())
|
err := runner.Cancel(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPipelineRunnerRestart(t *testing.T) {
|
||||||
|
pipeline := &resources.Pipeline{
|
||||||
|
ID: "123",
|
||||||
|
}
|
||||||
|
|
||||||
|
b := &bundle.Bundle{
|
||||||
|
Config: config.Root{
|
||||||
|
Resources: config.Resources{
|
||||||
|
Pipelines: map[string]*resources.Pipeline{
|
||||||
|
"test_pipeline": pipeline,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
runner := pipelineRunner{key: "test", bundle: b, pipeline: pipeline}
|
||||||
|
|
||||||
|
m := mocks.NewMockWorkspaceClient(t)
|
||||||
|
m.WorkspaceClient.Config = &sdk_config.Config{
|
||||||
|
Host: "https://test.com",
|
||||||
|
}
|
||||||
|
b.SetWorkpaceClient(m.WorkspaceClient)
|
||||||
|
ctx := context.Background()
|
||||||
|
ctx = cmdio.InContext(ctx, cmdio.NewIO(flags.OutputText, &bytes.Buffer{}, &bytes.Buffer{}, &bytes.Buffer{}, "", "..."))
|
||||||
|
ctx = cmdio.NewContext(ctx, cmdio.NewLogger(flags.ModeAppend))
|
||||||
|
|
||||||
|
mockWait := &pipelines.WaitGetPipelineIdle[struct{}]{
|
||||||
|
Poll: func(time.Duration, func(*pipelines.GetPipelineResponse)) (*pipelines.GetPipelineResponse, error) {
|
||||||
|
return nil, nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
pipelineApi := m.GetMockPipelinesAPI()
|
||||||
|
pipelineApi.EXPECT().Stop(mock.Anything, pipelines.StopRequest{
|
||||||
|
PipelineId: "123",
|
||||||
|
}).Return(mockWait, nil)
|
||||||
|
|
||||||
|
pipelineApi.EXPECT().GetByPipelineId(mock.Anything, "123").Return(&pipelines.GetPipelineResponse{}, nil)
|
||||||
|
|
||||||
|
// Mock runner starting a new update
|
||||||
|
pipelineApi.EXPECT().StartUpdate(mock.Anything, pipelines.StartUpdate{
|
||||||
|
PipelineId: "123",
|
||||||
|
}).Return(&pipelines.StartUpdateResponse{
|
||||||
|
UpdateId: "456",
|
||||||
|
}, nil)
|
||||||
|
|
||||||
|
// Mock runner polling for events
|
||||||
|
pipelineApi.EXPECT().ListPipelineEventsAll(mock.Anything, pipelines.ListPipelineEventsRequest{
|
||||||
|
Filter: `update_id = '456'`,
|
||||||
|
MaxResults: 100,
|
||||||
|
PipelineId: "123",
|
||||||
|
}).Return([]pipelines.PipelineEvent{}, nil)
|
||||||
|
|
||||||
|
// Mock runner polling for update status
|
||||||
|
pipelineApi.EXPECT().GetUpdateByPipelineIdAndUpdateId(mock.Anything, "123", "456").
|
||||||
|
Return(&pipelines.GetUpdateResponse{
|
||||||
|
Update: &pipelines.UpdateInfo{
|
||||||
|
State: pipelines.UpdateInfoStateCompleted,
|
||||||
|
},
|
||||||
|
}, nil)
|
||||||
|
|
||||||
|
_, err := runner.Restart(ctx, &Options{})
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,10 @@ type Runner interface {
|
||||||
// Run the underlying worklow.
|
// Run the underlying worklow.
|
||||||
Run(ctx context.Context, opts *Options) (output.RunOutput, error)
|
Run(ctx context.Context, opts *Options) (output.RunOutput, error)
|
||||||
|
|
||||||
|
// Restart the underlying workflow by cancelling any existing runs before
|
||||||
|
// starting a new one.
|
||||||
|
Restart(ctx context.Context, opts *Options) (output.RunOutput, error)
|
||||||
|
|
||||||
// Cancel the underlying workflow.
|
// Cancel the underlying workflow.
|
||||||
Cancel(ctx context.Context) error
|
Cancel(ctx context.Context) error
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,10 @@
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"budget_policy_id": {
|
||||||
|
"description": "The id of the user specified budget policy to use for this job.\nIf not specified, a default budget policy may be applied when creating or modifying the job.\nSee `effective_budget_policy_id` for the budget policy used by this workload.",
|
||||||
|
"$ref": "#/$defs/string"
|
||||||
|
},
|
||||||
"continuous": {
|
"continuous": {
|
||||||
"description": "An optional continuous property for this job. The continuous property will ensure that there is always one run executing. Only one of `schedule` and `continuous` can be used.",
|
"description": "An optional continuous property for this job. The continuous property will ensure that there is always one run executing. Only one of `schedule` and `continuous` can be used.",
|
||||||
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.Continuous"
|
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.Continuous"
|
||||||
|
@ -3901,6 +3905,10 @@
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"report": {
|
||||||
|
"description": "Select tables from a specific source report.",
|
||||||
|
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/pipelines.ReportSpec"
|
||||||
|
},
|
||||||
"schema": {
|
"schema": {
|
||||||
"description": "Select tables from a specific source schema.",
|
"description": "Select tables from a specific source schema.",
|
||||||
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/pipelines.SchemaSpec"
|
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/pipelines.SchemaSpec"
|
||||||
|
@ -4233,6 +4241,40 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"pipelines.ReportSpec": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"destination_catalog": {
|
||||||
|
"description": "Required. Destination catalog to store table.",
|
||||||
|
"$ref": "#/$defs/string"
|
||||||
|
},
|
||||||
|
"destination_schema": {
|
||||||
|
"description": "Required. Destination schema to store table.",
|
||||||
|
"$ref": "#/$defs/string"
|
||||||
|
},
|
||||||
|
"destination_table": {
|
||||||
|
"description": "Required. Destination table name. The pipeline fails if a table with that name already exists.",
|
||||||
|
"$ref": "#/$defs/string"
|
||||||
|
},
|
||||||
|
"source_url": {
|
||||||
|
"description": "Required. Report URL in the source system.",
|
||||||
|
"$ref": "#/$defs/string"
|
||||||
|
},
|
||||||
|
"table_configuration": {
|
||||||
|
"description": "Configuration settings to control the ingestion of tables. These settings override the table_configuration defined in the IngestionPipelineDefinition object.",
|
||||||
|
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/pipelines.TableSpecificConfig"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"pipelines.SchemaSpec": {
|
"pipelines.SchemaSpec": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
|
@ -4281,7 +4323,7 @@
|
||||||
"$ref": "#/$defs/string"
|
"$ref": "#/$defs/string"
|
||||||
},
|
},
|
||||||
"destination_table": {
|
"destination_table": {
|
||||||
"description": "Optional. Destination table name. The pipeline fails If a table with that name already exists. If not set, the source table name is used.",
|
"description": "Optional. Destination table name. The pipeline fails if a table with that name already exists. If not set, the source table name is used.",
|
||||||
"$ref": "#/$defs/string"
|
"$ref": "#/$defs/string"
|
||||||
},
|
},
|
||||||
"source_catalog": {
|
"source_catalog": {
|
||||||
|
@ -4329,6 +4371,10 @@
|
||||||
"SCD_TYPE_1",
|
"SCD_TYPE_1",
|
||||||
"SCD_TYPE_2"
|
"SCD_TYPE_2"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"sequence_by": {
|
||||||
|
"description": "The column names specifying the logical order of events in the source data. Delta Live Tables uses this sequencing to handle change events that arrive out of order.",
|
||||||
|
"$ref": "#/$defs/slice/string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
bundle:
|
||||||
|
name: issue_1828
|
||||||
|
|
||||||
|
variables:
|
||||||
|
# One entry for each of the underlying YAML (or [dyn.Kind]) types.
|
||||||
|
# The test confirms we can convert to and from the typed configuration without losing information.
|
||||||
|
|
||||||
|
map:
|
||||||
|
default:
|
||||||
|
foo: bar
|
||||||
|
|
||||||
|
sequence:
|
||||||
|
default:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
|
|
||||||
|
string:
|
||||||
|
default: foo
|
||||||
|
|
||||||
|
bool:
|
||||||
|
default: true
|
||||||
|
|
||||||
|
int:
|
||||||
|
default: 42
|
||||||
|
|
||||||
|
float:
|
||||||
|
default: 3.14
|
||||||
|
|
||||||
|
time:
|
||||||
|
default: 2021-01-01
|
||||||
|
|
||||||
|
nil:
|
||||||
|
default:
|
|
@ -0,0 +1,48 @@
|
||||||
|
package config_tests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIssue1828(t *testing.T) {
|
||||||
|
b := load(t, "./issue_1828")
|
||||||
|
|
||||||
|
if assert.Contains(t, b.Config.Variables, "map") {
|
||||||
|
assert.Equal(t, map[string]any{
|
||||||
|
"foo": "bar",
|
||||||
|
}, b.Config.Variables["map"].Default)
|
||||||
|
}
|
||||||
|
|
||||||
|
if assert.Contains(t, b.Config.Variables, "sequence") {
|
||||||
|
assert.Equal(t, []any{
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
}, b.Config.Variables["sequence"].Default)
|
||||||
|
}
|
||||||
|
|
||||||
|
if assert.Contains(t, b.Config.Variables, "string") {
|
||||||
|
assert.Equal(t, "foo", b.Config.Variables["string"].Default)
|
||||||
|
}
|
||||||
|
|
||||||
|
if assert.Contains(t, b.Config.Variables, "bool") {
|
||||||
|
assert.Equal(t, true, b.Config.Variables["bool"].Default)
|
||||||
|
}
|
||||||
|
|
||||||
|
if assert.Contains(t, b.Config.Variables, "int") {
|
||||||
|
assert.Equal(t, 42, b.Config.Variables["int"].Default)
|
||||||
|
}
|
||||||
|
|
||||||
|
if assert.Contains(t, b.Config.Variables, "float") {
|
||||||
|
assert.Equal(t, 3.14, b.Config.Variables["float"].Default)
|
||||||
|
}
|
||||||
|
|
||||||
|
if assert.Contains(t, b.Config.Variables, "time") {
|
||||||
|
assert.Equal(t, "2021-01-01", b.Config.Variables["time"].Default)
|
||||||
|
}
|
||||||
|
|
||||||
|
if assert.Contains(t, b.Config.Variables, "nil") {
|
||||||
|
assert.Equal(t, nil, b.Config.Variables["nil"].Default)
|
||||||
|
}
|
||||||
|
}
|
|
@ -205,10 +205,16 @@ func newUpdateRuleSet() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateRuleSetJson.Unmarshal(&updateRuleSetReq)
|
diags := updateRuleSetJson.Unmarshal(&updateRuleSetReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,10 +78,16 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
@ -316,10 +322,16 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,10 +90,16 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,10 +129,16 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,11 +88,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response, err := a.CustomAppIntegration.Create(ctx, createReq)
|
response, err := a.CustomAppIntegration.Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -320,11 +326,17 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updateReq.IntegrationId = args[0]
|
updateReq.IntegrationId = args[0]
|
||||||
|
|
||||||
err = a.CustomAppIntegration.Update(ctx, updateReq)
|
err = a.CustomAppIntegration.Update(ctx, updateReq)
|
||||||
|
|
|
@ -185,10 +185,16 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,10 +107,16 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,10 +127,16 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,11 +97,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response, err := a.Groups.Create(ctx, createReq)
|
response, err := a.Groups.Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -358,11 +364,17 @@ func newPatch() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = patchJson.Unmarshal(&patchReq)
|
diags := patchJson.Unmarshal(&patchReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
|
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
|
||||||
|
@ -446,11 +458,17 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
|
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
|
||||||
|
|
|
@ -132,11 +132,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
createReq.Label = args[0]
|
createReq.Label = args[0]
|
||||||
}
|
}
|
||||||
|
@ -411,11 +417,17 @@ func newReplace() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = replaceJson.Unmarshal(&replaceReq)
|
diags := replaceJson.Unmarshal(&replaceReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
replaceReq.IpAccessListId = args[0]
|
replaceReq.IpAccessListId = args[0]
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
replaceReq.Label = args[1]
|
replaceReq.Label = args[1]
|
||||||
|
@ -505,11 +517,17 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No IP_ACCESS_LIST_ID argument specified. Loading names for Account Ip Access Lists drop-down."
|
promptSpinner <- "No IP_ACCESS_LIST_ID argument specified. Loading names for Account Ip Access Lists drop-down."
|
||||||
|
|
|
@ -162,11 +162,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response, err := a.LogDelivery.Create(ctx, createReq)
|
response, err := a.LogDelivery.Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -369,11 +375,17 @@ func newPatchStatus() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = patchStatusJson.Unmarshal(&patchStatusReq)
|
diags := patchStatusJson.Unmarshal(&patchStatusReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
patchStatusReq.LogDeliveryConfigurationId = args[0]
|
patchStatusReq.LogDeliveryConfigurationId = args[0]
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
_, err = fmt.Sscan(args[1], &patchStatusReq.Status)
|
_, err = fmt.Sscan(args[1], &patchStatusReq.Status)
|
||||||
|
|
|
@ -85,11 +85,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_, err = fmt.Sscan(args[0], &createReq.WorkspaceId)
|
_, err = fmt.Sscan(args[0], &createReq.WorkspaceId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
|
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
|
||||||
|
@ -343,11 +349,17 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)
|
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
|
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
|
||||||
|
|
|
@ -80,11 +80,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response, err := a.Metastores.Create(ctx, createReq)
|
response, err := a.Metastores.Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -304,11 +310,17 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updateReq.MetastoreId = args[0]
|
updateReq.MetastoreId = args[0]
|
||||||
|
|
||||||
response, err := a.Metastores.Update(ctx, updateReq)
|
response, err := a.Metastores.Update(ctx, updateReq)
|
||||||
|
|
|
@ -96,11 +96,17 @@ func newCreateNetworkConnectivityConfiguration() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createNetworkConnectivityConfigurationJson.Unmarshal(&createNetworkConnectivityConfigurationReq)
|
diags := createNetworkConnectivityConfigurationJson.Unmarshal(&createNetworkConnectivityConfigurationReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
createNetworkConnectivityConfigurationReq.Name = args[0]
|
createNetworkConnectivityConfigurationReq.Name = args[0]
|
||||||
}
|
}
|
||||||
|
@ -187,11 +193,17 @@ func newCreatePrivateEndpointRule() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createPrivateEndpointRuleJson.Unmarshal(&createPrivateEndpointRuleReq)
|
diags := createPrivateEndpointRuleJson.Unmarshal(&createPrivateEndpointRuleReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
createPrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0]
|
createPrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0]
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
createPrivateEndpointRuleReq.ResourceId = args[1]
|
createPrivateEndpointRuleReq.ResourceId = args[1]
|
||||||
|
|
|
@ -97,11 +97,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
createReq.NetworkName = args[0]
|
createReq.NetworkName = args[0]
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,10 +189,16 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,11 +109,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
createReq.PrivateAccessSettingsName = args[0]
|
createReq.PrivateAccessSettingsName = args[0]
|
||||||
}
|
}
|
||||||
|
@ -411,11 +417,17 @@ func newReplace() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = replaceJson.Unmarshal(&replaceReq)
|
diags := replaceJson.Unmarshal(&replaceReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
replaceReq.PrivateAccessSettingsId = args[0]
|
replaceReq.PrivateAccessSettingsId = args[0]
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
replaceReq.PrivateAccessSettingsName = args[1]
|
replaceReq.PrivateAccessSettingsName = args[1]
|
||||||
|
|
|
@ -85,11 +85,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response, err := a.PublishedAppIntegration.Create(ctx, createReq)
|
response, err := a.PublishedAppIntegration.Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -315,11 +321,17 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updateReq.IntegrationId = args[0]
|
updateReq.IntegrationId = args[0]
|
||||||
|
|
||||||
err = a.PublishedAppIntegration.Update(ctx, updateReq)
|
err = a.PublishedAppIntegration.Update(ctx, updateReq)
|
||||||
|
|
|
@ -95,11 +95,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response, err := a.ServicePrincipals.Create(ctx, createReq)
|
response, err := a.ServicePrincipals.Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -358,11 +364,17 @@ func newPatch() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = patchJson.Unmarshal(&patchReq)
|
diags := patchJson.Unmarshal(&patchReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
|
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
|
||||||
|
@ -448,11 +460,17 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
|
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
|
||||||
|
|
|
@ -88,11 +88,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
createReq.MetastoreId = args[0]
|
createReq.MetastoreId = args[0]
|
||||||
|
|
||||||
response, err := a.StorageCredentials.Create(ctx, createReq)
|
response, err := a.StorageCredentials.Create(ctx, createReq)
|
||||||
|
@ -340,11 +346,17 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updateReq.MetastoreId = args[0]
|
updateReq.MetastoreId = args[0]
|
||||||
updateReq.StorageCredentialName = args[1]
|
updateReq.StorageCredentialName = args[1]
|
||||||
|
|
||||||
|
|
|
@ -87,10 +87,16 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,11 +80,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response, err := a.UsageDashboards.Create(ctx, createReq)
|
response, err := a.UsageDashboards.Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -103,11 +103,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response, err := a.Users.Create(ctx, createReq)
|
response, err := a.Users.Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -374,11 +380,17 @@ func newPatch() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = patchJson.Unmarshal(&patchReq)
|
diags := patchJson.Unmarshal(&patchReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
|
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
|
||||||
|
@ -465,11 +477,17 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
|
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
|
||||||
|
|
|
@ -104,11 +104,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
createReq.VpcEndpointName = args[0]
|
createReq.VpcEndpointName = args[0]
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,11 +273,17 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)
|
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
|
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
|
||||||
|
|
|
@ -133,11 +133,17 @@ func newCreate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
createReq.WorkspaceName = args[0]
|
createReq.WorkspaceName = args[0]
|
||||||
}
|
}
|
||||||
|
@ -551,11 +557,17 @@ func newUpdate() *cobra.Command {
|
||||||
a := root.AccountClient(ctx)
|
a := root.AccountClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Workspaces drop-down."
|
promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Workspaces drop-down."
|
||||||
|
|
|
@ -42,9 +42,9 @@ func makeCommand(method string) *cobra.Command {
|
||||||
var path = args[0]
|
var path = args[0]
|
||||||
|
|
||||||
var request any
|
var request any
|
||||||
err := payload.Unmarshal(&request)
|
diags := payload.Unmarshal(&request)
|
||||||
if err != nil {
|
if diags.HasError() {
|
||||||
return err
|
return diags.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := &config.Config{}
|
cfg := &config.Config{}
|
||||||
|
|
|
@ -78,7 +78,7 @@ func newDeployCommand() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderOpts := render.RenderOptions{RenderSummaryTable: false}
|
renderOpts := render.RenderOptions{RenderSummaryTable: false}
|
||||||
err := render.RenderTextOutput(cmd.OutOrStdout(), b, diags, renderOpts)
|
err := render.RenderDiagnostics(cmd.OutOrStdout(), b, diags, renderOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to render output: %w", err)
|
return fmt.Errorf("failed to render output: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/databricks/cli/bundle/deploy/terraform"
|
"github.com/databricks/cli/bundle/deploy/terraform"
|
||||||
"github.com/databricks/cli/bundle/phases"
|
"github.com/databricks/cli/bundle/phases"
|
||||||
"github.com/databricks/cli/bundle/run"
|
"github.com/databricks/cli/bundle/run"
|
||||||
|
"github.com/databricks/cli/bundle/run/output"
|
||||||
"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"
|
||||||
"github.com/databricks/cli/libs/cmdio"
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
@ -100,19 +101,16 @@ task or a Python wheel task, the second example applies.
|
||||||
}
|
}
|
||||||
|
|
||||||
runOptions.NoWait = noWait
|
runOptions.NoWait = noWait
|
||||||
|
var output output.RunOutput
|
||||||
if restart {
|
if restart {
|
||||||
s := cmdio.Spinner(ctx)
|
output, err = runner.Restart(ctx, &runOptions)
|
||||||
s <- "Cancelling all runs"
|
} else {
|
||||||
err := runner.Cancel(ctx)
|
output, err = runner.Run(ctx, &runOptions)
|
||||||
close(s)
|
}
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output, err := runner.Run(ctx, &runOptions)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if output != nil {
|
if output != nil {
|
||||||
switch root.OutputType(cmd) {
|
switch root.OutputType(cmd) {
|
||||||
case flags.OutputText:
|
case flags.OutputText:
|
||||||
|
|
|
@ -8,8 +8,10 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/bundle/config/mutator"
|
||||||
"github.com/databricks/cli/bundle/deploy/terraform"
|
"github.com/databricks/cli/bundle/deploy/terraform"
|
||||||
"github.com/databricks/cli/bundle/phases"
|
"github.com/databricks/cli/bundle/phases"
|
||||||
|
"github.com/databricks/cli/bundle/render"
|
||||||
"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"
|
||||||
"github.com/databricks/cli/libs/flags"
|
"github.com/databricks/cli/libs/flags"
|
||||||
|
@ -19,11 +21,8 @@ import (
|
||||||
func newSummaryCommand() *cobra.Command {
|
func newSummaryCommand() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "summary",
|
Use: "summary",
|
||||||
Short: "Describe the bundle resources and their deployment states",
|
Short: "Summarize resources deployed by this bundle",
|
||||||
Args: root.NoArgs,
|
Args: root.NoArgs,
|
||||||
|
|
||||||
// This command is currently intended for the Databricks VSCode extension only
|
|
||||||
Hidden: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var forcePull bool
|
var forcePull bool
|
||||||
|
@ -60,14 +59,15 @@ func newSummaryCommand() *cobra.Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diags = bundle.Apply(ctx, b, terraform.Load())
|
diags = bundle.Apply(ctx, b,
|
||||||
|
bundle.Seq(terraform.Load(), mutator.InitializeURLs()))
|
||||||
if err := diags.Error(); err != nil {
|
if err := diags.Error(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
switch root.OutputType(cmd) {
|
switch root.OutputType(cmd) {
|
||||||
case flags.OutputText:
|
case flags.OutputText:
|
||||||
return fmt.Errorf("%w, only json output is supported", errors.ErrUnsupported)
|
return render.RenderSummary(ctx, cmd.OutOrStdout(), b)
|
||||||
case flags.OutputJSON:
|
case flags.OutputJSON:
|
||||||
buf, err := json.MarshalIndent(b.Config, "", " ")
|
buf, err := json.MarshalIndent(b.Config, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package bundle
|
package bundle
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
|
@ -9,6 +11,7 @@ import (
|
||||||
"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"
|
||||||
|
"github.com/databricks/cli/libs/flags"
|
||||||
"github.com/databricks/cli/libs/log"
|
"github.com/databricks/cli/libs/log"
|
||||||
"github.com/databricks/cli/libs/sync"
|
"github.com/databricks/cli/libs/sync"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -18,6 +21,7 @@ type syncFlags struct {
|
||||||
interval time.Duration
|
interval time.Duration
|
||||||
full bool
|
full bool
|
||||||
watch bool
|
watch bool
|
||||||
|
output flags.Output
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *syncFlags) syncOptionsFromBundle(cmd *cobra.Command, b *bundle.Bundle) (*sync.SyncOptions, error) {
|
func (f *syncFlags) syncOptionsFromBundle(cmd *cobra.Command, b *bundle.Bundle) (*sync.SyncOptions, error) {
|
||||||
|
@ -26,6 +30,21 @@ func (f *syncFlags) syncOptionsFromBundle(cmd *cobra.Command, b *bundle.Bundle)
|
||||||
return nil, fmt.Errorf("cannot get sync options: %w", err)
|
return nil, fmt.Errorf("cannot get sync options: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if f.output != "" {
|
||||||
|
var outputFunc func(context.Context, <-chan sync.Event, io.Writer)
|
||||||
|
switch f.output {
|
||||||
|
case flags.OutputText:
|
||||||
|
outputFunc = sync.TextOutput
|
||||||
|
case flags.OutputJSON:
|
||||||
|
outputFunc = sync.JsonOutput
|
||||||
|
}
|
||||||
|
if outputFunc != nil {
|
||||||
|
opts.OutputHandler = func(ctx context.Context, c <-chan sync.Event) {
|
||||||
|
outputFunc(ctx, c, cmd.OutOrStdout())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
opts.Full = f.full
|
opts.Full = f.full
|
||||||
opts.PollInterval = f.interval
|
opts.PollInterval = f.interval
|
||||||
return opts, nil
|
return opts, nil
|
||||||
|
@ -42,6 +61,7 @@ func newSyncCommand() *cobra.Command {
|
||||||
cmd.Flags().DurationVar(&f.interval, "interval", 1*time.Second, "file system polling interval (for --watch)")
|
cmd.Flags().DurationVar(&f.interval, "interval", 1*time.Second, "file system polling interval (for --watch)")
|
||||||
cmd.Flags().BoolVar(&f.full, "full", false, "perform full synchronization (default is incremental)")
|
cmd.Flags().BoolVar(&f.full, "full", false, "perform full synchronization (default is incremental)")
|
||||||
cmd.Flags().BoolVar(&f.watch, "watch", false, "watch local file system for changes")
|
cmd.Flags().BoolVar(&f.watch, "watch", false, "watch local file system for changes")
|
||||||
|
cmd.Flags().Var(&f.output, "output", "type of the output format")
|
||||||
|
|
||||||
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
|
@ -65,6 +85,7 @@ func newSyncCommand() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer s.Close()
|
||||||
|
|
||||||
log.Infof(ctx, "Remote file sync location: %v", opts.RemotePath)
|
log.Infof(ctx, "Remote file sync location: %v", opts.RemotePath)
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ func newValidateCommand() *cobra.Command {
|
||||||
switch root.OutputType(cmd) {
|
switch root.OutputType(cmd) {
|
||||||
case flags.OutputText:
|
case flags.OutputText:
|
||||||
renderOpts := render.RenderOptions{RenderSummaryTable: true}
|
renderOpts := render.RenderOptions{RenderSummaryTable: true}
|
||||||
err := render.RenderTextOutput(cmd.OutOrStdout(), b, diags, renderOpts)
|
err := render.RenderDiagnostics(cmd.OutOrStdout(), b, diags, renderOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to render output: %w", err)
|
return fmt.Errorf("failed to render output: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,10 +93,16 @@ func newCreate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
@ -357,10 +363,16 @@ func newUpdate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,11 +85,17 @@ func newCreate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response, err := w.Alerts.Create(ctx, createReq)
|
response, err := w.Alerts.Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -354,11 +360,17 @@ func newUpdate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updateReq.Id = args[0]
|
updateReq.Id = args[0]
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
updateReq.UpdateMask = args[1]
|
updateReq.UpdateMask = args[1]
|
||||||
|
|
|
@ -28,9 +28,6 @@ func New() *cobra.Command {
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"package": "apps",
|
"package": "apps",
|
||||||
},
|
},
|
||||||
|
|
||||||
// This service is being previewed; hide from help output.
|
|
||||||
Hidden: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add methods
|
// Add methods
|
||||||
|
@ -113,11 +110,17 @@ func newCreate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
createReq.Name = args[0]
|
createReq.Name = args[0]
|
||||||
}
|
}
|
||||||
|
@ -267,11 +270,17 @@ func newDeploy() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = deployJson.Unmarshal(&deployReq)
|
diags := deployJson.Unmarshal(&deployReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
deployReq.AppName = args[0]
|
deployReq.AppName = args[0]
|
||||||
|
|
||||||
wait, err := w.Apps.Deploy(ctx, deployReq)
|
wait, err := w.Apps.Deploy(ctx, deployReq)
|
||||||
|
@ -702,11 +711,17 @@ func newSetPermissions() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
setPermissionsReq.AppName = args[0]
|
setPermissionsReq.AppName = args[0]
|
||||||
|
|
||||||
response, err := w.Apps.SetPermissions(ctx, setPermissionsReq)
|
response, err := w.Apps.SetPermissions(ctx, setPermissionsReq)
|
||||||
|
@ -936,11 +951,17 @@ func newUpdate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updateReq.Name = args[0]
|
updateReq.Name = args[0]
|
||||||
|
|
||||||
response, err := w.Apps.Update(ctx, updateReq)
|
response, err := w.Apps.Update(ctx, updateReq)
|
||||||
|
@ -1005,11 +1026,17 @@ func newUpdatePermissions() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updatePermissionsReq.AppName = args[0]
|
updatePermissionsReq.AppName = args[0]
|
||||||
|
|
||||||
response, err := w.Apps.UpdatePermissions(ctx, updatePermissionsReq)
|
response, err := w.Apps.UpdatePermissions(ctx, updatePermissionsReq)
|
||||||
|
|
|
@ -145,10 +145,16 @@ func newUpdate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,10 +127,16 @@ func newUpdate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,11 +105,17 @@ func newCreate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
createReq.Name = args[0]
|
createReq.Name = args[0]
|
||||||
}
|
}
|
||||||
|
@ -363,11 +369,17 @@ func newUpdate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updateReq.Name = args[0]
|
updateReq.Name = args[0]
|
||||||
|
|
||||||
response, err := w.Catalogs.Update(ctx, updateReq)
|
response, err := w.Catalogs.Update(ctx, updateReq)
|
||||||
|
|
|
@ -85,10 +85,16 @@ func newCreate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
@ -344,11 +350,17 @@ func newUpdate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
updateReq.Name = args[0]
|
updateReq.Name = args[0]
|
||||||
|
|
||||||
response, err := w.CleanRooms.Update(ctx, updateReq)
|
response, err := w.CleanRooms.Update(ctx, updateReq)
|
||||||
|
|
|
@ -113,11 +113,17 @@ func newCreate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response, err := w.ClusterPolicies.Create(ctx, createReq)
|
response, err := w.ClusterPolicies.Create(ctx, createReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -185,10 +191,16 @@ func newDelete() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = deleteJson.Unmarshal(&deleteReq)
|
diags := deleteJson.Unmarshal(&deleteReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
@ -284,10 +296,16 @@ func newEdit() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = editJson.Unmarshal(&editReq)
|
diags := editJson.Unmarshal(&editReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
@ -630,11 +648,17 @@ func newSetPermissions() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."
|
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."
|
||||||
|
@ -711,11 +735,17 @@ func newUpdatePermissions() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."
|
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."
|
||||||
|
|
|
@ -134,11 +134,17 @@ func newChangeOwner() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = changeOwnerJson.Unmarshal(&changeOwnerReq)
|
diags := changeOwnerJson.Unmarshal(&changeOwnerReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
changeOwnerReq.ClusterId = args[0]
|
changeOwnerReq.ClusterId = args[0]
|
||||||
}
|
}
|
||||||
|
@ -268,11 +274,17 @@ func newCreate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
createReq.SparkVersion = args[0]
|
createReq.SparkVersion = args[0]
|
||||||
}
|
}
|
||||||
|
@ -362,10 +374,16 @@ func newDelete() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = deleteJson.Unmarshal(&deleteReq)
|
diags := deleteJson.Unmarshal(&deleteReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
@ -519,11 +537,17 @@ func newEdit() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = editJson.Unmarshal(&editReq)
|
diags := editJson.Unmarshal(&editReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
editReq.ClusterId = args[0]
|
editReq.ClusterId = args[0]
|
||||||
}
|
}
|
||||||
|
@ -617,10 +641,16 @@ func newEvents() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = eventsJson.Unmarshal(&eventsReq)
|
diags := eventsJson.Unmarshal(&eventsReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
@ -1069,10 +1099,16 @@ func newPermanentDelete() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = permanentDeleteJson.Unmarshal(&permanentDeleteReq)
|
diags := permanentDeleteJson.Unmarshal(&permanentDeleteReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
@ -1161,10 +1197,16 @@ func newPin() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = pinJson.Unmarshal(&pinReq)
|
diags := pinJson.Unmarshal(&pinReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
@ -1260,10 +1302,16 @@ func newResize() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = resizeJson.Unmarshal(&resizeReq)
|
diags := resizeJson.Unmarshal(&resizeReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
@ -1370,10 +1418,16 @@ func newRestart() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = restartJson.Unmarshal(&restartReq)
|
diags := restartJson.Unmarshal(&restartReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
@ -1464,11 +1518,17 @@ func newSetPermissions() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."
|
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."
|
||||||
|
@ -1608,10 +1668,16 @@ func newStart() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = startJson.Unmarshal(&startReq)
|
diags := startJson.Unmarshal(&startReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
@ -1712,10 +1778,16 @@ func newUnpin() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = unpinJson.Unmarshal(&unpinReq)
|
diags := unpinJson.Unmarshal(&unpinReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
@ -1824,11 +1896,17 @@ func newUpdate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if !cmd.Flags().Changed("json") {
|
if !cmd.Flags().Changed("json") {
|
||||||
updateReq.ClusterId = args[0]
|
updateReq.ClusterId = args[0]
|
||||||
}
|
}
|
||||||
|
@ -1905,11 +1983,17 @@ func newUpdatePermissions() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."
|
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."
|
||||||
|
|
|
@ -130,10 +130,16 @@ func newUpdate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,10 +92,16 @@ func newCreate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
@ -355,10 +361,16 @@ func newUpdate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,11 +86,17 @@ func newCreate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = createJson.Unmarshal(&createReq)
|
diags := createJson.Unmarshal(&createReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
createReq.ListingId = args[0]
|
createReq.ListingId = args[0]
|
||||||
|
|
||||||
response, err := w.ConsumerInstallations.Create(ctx, createReq)
|
response, err := w.ConsumerInstallations.Create(ctx, createReq)
|
||||||
|
@ -319,10 +325,16 @@ func newUpdate() *cobra.Command {
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
diags := updateJson.Unmarshal(&updateReq)
|
||||||
|
if diags.HasError() {
|
||||||
|
return diags.Error()
|
||||||
|
}
|
||||||
|
if len(diags) > 0 {
|
||||||
|
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue