mirror of https://github.com/databricks/cli.git
Compare commits
No commits in common. "dda138fa63163d87ff78d6e757c8bf3fdf2937b9" and "f6232f5aaec40812893bef5b04fa34b83327ced6" have entirely different histories.
dda138fa63
...
f6232f5aae
|
@ -11,7 +11,6 @@
|
|||
"toolchain": {
|
||||
"required": ["go"],
|
||||
"post_generate": [
|
||||
"go test -timeout 240s -run TestConsistentDatabricksSdkVersion github.com/databricks/cli/internal/build",
|
||||
"go run ./bundle/internal/schema/*.go ./bundle/schema/jsonschema.json",
|
||||
"echo 'bundle/internal/tf/schema/\\*.go linguist-generated=true' >> ./.gitattributes",
|
||||
"echo 'go.sum linguist-generated=true' >> ./.gitattributes",
|
||||
|
|
|
@ -5,7 +5,6 @@ package {{(.TrimPrefix "account").SnakeName}}
|
|||
import (
|
||||
"github.com/databricks/cli/libs/cmdio"
|
||||
"github.com/databricks/cli/libs/flags"
|
||||
"github.com/databricks/cli/libs/diag"
|
||||
"github.com/databricks/cli/cmd/root"
|
||||
"github.com/databricks/databricks-sdk-go/service/{{.Package.Name}}"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -232,16 +231,10 @@ func new{{.PascalName}}() *cobra.Command {
|
|||
{{- if .Request }}
|
||||
{{ if .CanUseJson }}
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}{{end}}{{ if .MustUseJson }}else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}{{- end}}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
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
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
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)
|
||||
}
|
|
@ -699,9 +699,6 @@ func TestTranslatePathJobEnvironments(t *testing.T) {
|
|||
"../dist/env2.whl",
|
||||
"simplejson",
|
||||
"/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",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -722,9 +719,6 @@ 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, "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, "--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) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package config
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/databricks/cli/bundle/config/resources"
|
||||
"github.com/databricks/databricks-sdk-go"
|
||||
|
@ -31,53 +30,6 @@ type ConfigResource interface {
|
|||
// Terraform equivalent name of the resource. For example "databricks_job"
|
||||
// for jobs and "databricks_pipeline" for pipelines.
|
||||
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) {
|
||||
|
@ -109,71 +61,20 @@ func (r *Resources) FindResourceByConfigKey(key string) (ConfigResource, error)
|
|||
}
|
||||
|
||||
type ResourceDescription struct {
|
||||
// Singular and plural name when used to refer to the configuration.
|
||||
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.
|
||||
func SupportedResources() map[string]ResourceDescription {
|
||||
return map[string]ResourceDescription{
|
||||
"jobs": {
|
||||
SingularName: "job",
|
||||
PluralName: "jobs",
|
||||
SingularTitle: "Job",
|
||||
PluralTitle: "Jobs",
|
||||
},
|
||||
"pipelines": {
|
||||
SingularName: "pipeline",
|
||||
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",
|
||||
},
|
||||
"jobs": {SingularName: "job"},
|
||||
"pipelines": {SingularName: "pipeline"},
|
||||
"models": {SingularName: "model"},
|
||||
"experiments": {SingularName: "experiment"},
|
||||
"model_serving_endpoints": {SingularName: "model_serving_endpoint"},
|
||||
"registered_models": {SingularName: "registered_model"},
|
||||
"quality_monitors": {SingularName: "quality_monitor"},
|
||||
"schemas": {SingularName: "schema"},
|
||||
"clusters": {SingularName: "cluster"},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ package resources
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/databricks/cli/libs/log"
|
||||
"github.com/databricks/databricks-sdk-go"
|
||||
|
@ -15,7 +13,6 @@ type Cluster struct {
|
|||
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||
Permissions []Permission `json:"permissions,omitempty"`
|
||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||
URL string `json:"url,omitempty" bundle:"internal"`
|
||||
|
||||
*compute.ClusterSpec
|
||||
}
|
||||
|
@ -40,19 +37,3 @@ func (s *Cluster) Exists(ctx context.Context, w *databricks.WorkspaceClient, id
|
|||
func (s *Cluster) TerraformResourceName() string {
|
||||
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,8 +2,6 @@ package resources
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/databricks/cli/libs/log"
|
||||
|
@ -16,7 +14,6 @@ type Job struct {
|
|||
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||
Permissions []Permission `json:"permissions,omitempty"`
|
||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||
URL string `json:"url,omitempty" bundle:"internal"`
|
||||
|
||||
*jobs.JobSettings
|
||||
}
|
||||
|
@ -47,19 +44,3 @@ func (j *Job) Exists(ctx context.Context, w *databricks.WorkspaceClient, id stri
|
|||
func (j *Job) TerraformResourceName() string {
|
||||
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,8 +2,6 @@ package resources
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/databricks/cli/libs/log"
|
||||
"github.com/databricks/databricks-sdk-go"
|
||||
|
@ -15,7 +13,6 @@ type MlflowExperiment struct {
|
|||
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||
Permissions []Permission `json:"permissions,omitempty"`
|
||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||
URL string `json:"url,omitempty" bundle:"internal"`
|
||||
|
||||
*ml.Experiment
|
||||
}
|
||||
|
@ -42,19 +39,3 @@ func (s *MlflowExperiment) Exists(ctx context.Context, w *databricks.WorkspaceCl
|
|||
func (s *MlflowExperiment) TerraformResourceName() string {
|
||||
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,8 +2,6 @@ package resources
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/databricks/cli/libs/log"
|
||||
"github.com/databricks/databricks-sdk-go"
|
||||
|
@ -15,7 +13,6 @@ type MlflowModel struct {
|
|||
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||
Permissions []Permission `json:"permissions,omitempty"`
|
||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||
URL string `json:"url,omitempty" bundle:"internal"`
|
||||
|
||||
*ml.Model
|
||||
}
|
||||
|
@ -42,19 +39,3 @@ func (s *MlflowModel) Exists(ctx context.Context, w *databricks.WorkspaceClient,
|
|||
func (s *MlflowModel) TerraformResourceName() string {
|
||||
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,8 +2,6 @@ package resources
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/databricks/cli/libs/log"
|
||||
"github.com/databricks/databricks-sdk-go"
|
||||
|
@ -25,7 +23,6 @@ type ModelServingEndpoint struct {
|
|||
Permissions []Permission `json:"permissions,omitempty"`
|
||||
|
||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||
URL string `json:"url,omitempty" bundle:"internal"`
|
||||
}
|
||||
|
||||
func (s *ModelServingEndpoint) UnmarshalJSON(b []byte) error {
|
||||
|
@ -50,19 +47,3 @@ func (s *ModelServingEndpoint) Exists(ctx context.Context, w *databricks.Workspa
|
|||
func (s *ModelServingEndpoint) TerraformResourceName() string {
|
||||
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,8 +2,6 @@ package resources
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/databricks/cli/libs/log"
|
||||
"github.com/databricks/databricks-sdk-go"
|
||||
|
@ -15,7 +13,6 @@ type Pipeline struct {
|
|||
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||
Permissions []Permission `json:"permissions,omitempty"`
|
||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||
URL string `json:"url,omitempty" bundle:"internal"`
|
||||
|
||||
*pipelines.PipelineSpec
|
||||
}
|
||||
|
@ -42,19 +39,3 @@ func (p *Pipeline) Exists(ctx context.Context, w *databricks.WorkspaceClient, id
|
|||
func (p *Pipeline) TerraformResourceName() string {
|
||||
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,9 +2,6 @@ package resources
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/databricks/cli/libs/log"
|
||||
"github.com/databricks/databricks-sdk-go"
|
||||
|
@ -23,7 +20,6 @@ type QualityMonitor struct {
|
|||
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||
|
||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||
URL string `json:"url,omitempty" bundle:"internal"`
|
||||
}
|
||||
|
||||
func (s *QualityMonitor) UnmarshalJSON(b []byte) error {
|
||||
|
@ -48,19 +44,3 @@ func (s *QualityMonitor) Exists(ctx context.Context, w *databricks.WorkspaceClie
|
|||
func (s *QualityMonitor) TerraformResourceName() string {
|
||||
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,9 +2,6 @@ package resources
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/databricks/cli/libs/log"
|
||||
"github.com/databricks/databricks-sdk-go"
|
||||
|
@ -27,7 +24,6 @@ type RegisteredModel struct {
|
|||
*catalog.CreateRegisteredModelRequest
|
||||
|
||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||
URL string `json:"url,omitempty" bundle:"internal"`
|
||||
}
|
||||
|
||||
func (s *RegisteredModel) UnmarshalJSON(b []byte) error {
|
||||
|
@ -52,19 +48,3 @@ func (s *RegisteredModel) Exists(ctx context.Context, w *databricks.WorkspaceCli
|
|||
func (s *RegisteredModel) TerraformResourceName() string {
|
||||
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,12 +1,6 @@
|
|||
package resources
|
||||
|
||||
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/service/catalog"
|
||||
)
|
||||
|
@ -22,31 +16,6 @@ type Schema struct {
|
|||
*catalog.CreateSchema
|
||||
|
||||
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 {
|
||||
|
|
|
@ -63,37 +63,17 @@ 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) {
|
||||
// Please add your resource to the SupportedResources() function in resources.go if you add a new resource.
|
||||
actual := SupportedResources()
|
||||
|
||||
expected := map[string]ResourceDescription{}
|
||||
typ := reflect.TypeOf(Resources{})
|
||||
for i := 0; i < typ.NumField(); i++ {
|
||||
field := typ.Field(i)
|
||||
jsonTags := strings.Split(field.Tag.Get("json"), ",")
|
||||
pluralName := jsonTags[0]
|
||||
assert.Equal(t, actual[pluralName].PluralName, pluralName)
|
||||
singularName := strings.TrimSuffix(jsonTags[0], "s")
|
||||
expected[jsonTags[0]] = ResourceDescription{SingularName: singularName}
|
||||
}
|
||||
|
||||
// Please add your resource to the SupportedResources() function in resources.go
|
||||
// if you are adding a new resource.
|
||||
assert.Equal(t, expected, SupportedResources())
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package terraform
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/databricks/cli/bundle/config"
|
||||
"github.com/databricks/cli/bundle/config/resources"
|
||||
|
@ -12,6 +14,244 @@ import (
|
|||
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
|
||||
// to the equivalent Terraform JSON representation.
|
||||
func BundleToTerraformWithDynValue(ctx context.Context, root dyn.Value) (*schema.Root, error) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package terraform
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
|
@ -20,27 +21,6 @@ import (
|
|||
"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) {
|
||||
var src = resources.Job{
|
||||
JobSettings: &jobs.JobSettings{
|
||||
|
@ -78,9 +58,8 @@ func TestBundleToTerraformJob(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourceJob
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.Job["my_job"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.Job["my_job"].(*schema.ResourceJob)
|
||||
|
||||
assert.Equal(t, "my job", resource.Name)
|
||||
assert.Len(t, resource.JobCluster, 1)
|
||||
|
@ -89,6 +68,8 @@ func TestBundleToTerraformJob(t *testing.T) {
|
|||
assert.Equal(t, "param1", resource.Parameter[0].Name)
|
||||
assert.Equal(t, "param2", resource.Parameter[1].Name)
|
||||
assert.Nil(t, out.Data)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformJobPermissions(t *testing.T) {
|
||||
|
@ -109,14 +90,15 @@ func TestBundleToTerraformJobPermissions(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourcePermissions
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.Permissions["job_my_job"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.Permissions["job_my_job"].(*schema.ResourcePermissions)
|
||||
|
||||
assert.NotEmpty(t, resource.JobId)
|
||||
assert.Len(t, resource.AccessControl, 1)
|
||||
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
||||
assert.Equal(t, "CAN_VIEW", resource.AccessControl[0].PermissionLevel)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformJobTaskLibraries(t *testing.T) {
|
||||
|
@ -146,14 +128,15 @@ func TestBundleToTerraformJobTaskLibraries(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourceJob
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.Job["my_job"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.Job["my_job"].(*schema.ResourceJob)
|
||||
|
||||
assert.Equal(t, "my job", resource.Name)
|
||||
require.Len(t, resource.Task, 1)
|
||||
require.Len(t, resource.Task[0].Library, 1)
|
||||
assert.Equal(t, "mlflow", resource.Task[0].Library[0].Pypi.Package)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformForEachTaskLibraries(t *testing.T) {
|
||||
|
@ -189,14 +172,15 @@ func TestBundleToTerraformForEachTaskLibraries(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourceJob
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.Job["my_job"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.Job["my_job"].(*schema.ResourceJob)
|
||||
|
||||
assert.Equal(t, "my job", resource.Name)
|
||||
require.Len(t, resource.Task, 1)
|
||||
require.Len(t, resource.Task[0].ForEachTask.Task.Library, 1)
|
||||
assert.Equal(t, "mlflow", resource.Task[0].ForEachTask.Task.Library[0].Pypi.Package)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformPipeline(t *testing.T) {
|
||||
|
@ -246,9 +230,8 @@ func TestBundleToTerraformPipeline(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourcePipeline
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.Pipeline["my_pipeline"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.Pipeline["my_pipeline"].(*schema.ResourcePipeline)
|
||||
|
||||
assert.Equal(t, "my pipeline", resource.Name)
|
||||
assert.Len(t, resource.Library, 2)
|
||||
|
@ -258,6 +241,8 @@ 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].EmailRecipients, []string{"jane@doe.com", "john@doe.com"})
|
||||
assert.Nil(t, out.Data)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformPipelinePermissions(t *testing.T) {
|
||||
|
@ -278,14 +263,15 @@ func TestBundleToTerraformPipelinePermissions(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourcePermissions
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.Permissions["pipeline_my_pipeline"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.Permissions["pipeline_my_pipeline"].(*schema.ResourcePermissions)
|
||||
|
||||
assert.NotEmpty(t, resource.PipelineId)
|
||||
assert.Len(t, resource.AccessControl, 1)
|
||||
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
||||
assert.Equal(t, "CAN_VIEW", resource.AccessControl[0].PermissionLevel)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformModel(t *testing.T) {
|
||||
|
@ -314,9 +300,8 @@ func TestBundleToTerraformModel(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourceMlflowModel
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.MlflowModel["my_model"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.MlflowModel["my_model"].(*schema.ResourceMlflowModel)
|
||||
|
||||
assert.Equal(t, "name", resource.Name)
|
||||
assert.Equal(t, "description", resource.Description)
|
||||
|
@ -326,6 +311,8 @@ func TestBundleToTerraformModel(t *testing.T) {
|
|||
assert.Equal(t, "k2", resource.Tags[1].Key)
|
||||
assert.Equal(t, "v2", resource.Tags[1].Value)
|
||||
assert.Nil(t, out.Data)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformModelPermissions(t *testing.T) {
|
||||
|
@ -349,14 +336,15 @@ func TestBundleToTerraformModelPermissions(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourcePermissions
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.Permissions["mlflow_model_my_model"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.Permissions["mlflow_model_my_model"].(*schema.ResourcePermissions)
|
||||
|
||||
assert.NotEmpty(t, resource.RegisteredModelId)
|
||||
assert.Len(t, resource.AccessControl, 1)
|
||||
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
||||
assert.Equal(t, "CAN_READ", resource.AccessControl[0].PermissionLevel)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformExperiment(t *testing.T) {
|
||||
|
@ -374,12 +362,13 @@ func TestBundleToTerraformExperiment(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourceMlflowExperiment
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.MlflowExperiment["my_experiment"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.MlflowExperiment["my_experiment"].(*schema.ResourceMlflowExperiment)
|
||||
|
||||
assert.Equal(t, "name", resource.Name)
|
||||
assert.Nil(t, out.Data)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformExperimentPermissions(t *testing.T) {
|
||||
|
@ -403,14 +392,15 @@ func TestBundleToTerraformExperimentPermissions(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourcePermissions
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.Permissions["mlflow_experiment_my_experiment"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.Permissions["mlflow_experiment_my_experiment"].(*schema.ResourcePermissions)
|
||||
|
||||
assert.NotEmpty(t, resource.ExperimentId)
|
||||
assert.Len(t, resource.AccessControl, 1)
|
||||
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
||||
assert.Equal(t, "CAN_READ", resource.AccessControl[0].PermissionLevel)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformModelServing(t *testing.T) {
|
||||
|
@ -446,9 +436,8 @@ func TestBundleToTerraformModelServing(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourceModelServing
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.ModelServing["my_model_serving_endpoint"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.ModelServing["my_model_serving_endpoint"].(*schema.ResourceModelServing)
|
||||
|
||||
assert.Equal(t, "name", resource.Name)
|
||||
assert.Equal(t, "model_name", resource.Config.ServedModels[0].ModelName)
|
||||
|
@ -458,6 +447,8 @@ func TestBundleToTerraformModelServing(t *testing.T) {
|
|||
assert.Equal(t, "model_name-1", resource.Config.TrafficConfig.Routes[0].ServedModelName)
|
||||
assert.Equal(t, 100, resource.Config.TrafficConfig.Routes[0].TrafficPercentage)
|
||||
assert.Nil(t, out.Data)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformModelServingPermissions(t *testing.T) {
|
||||
|
@ -499,14 +490,15 @@ func TestBundleToTerraformModelServingPermissions(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourcePermissions
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.Permissions["model_serving_my_model_serving_endpoint"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.Permissions["model_serving_my_model_serving_endpoint"].(*schema.ResourcePermissions)
|
||||
|
||||
assert.NotEmpty(t, resource.ServingEndpointId)
|
||||
assert.Len(t, resource.AccessControl, 1)
|
||||
assert.Equal(t, "jane@doe.com", resource.AccessControl[0].UserName)
|
||||
assert.Equal(t, "CAN_VIEW", resource.AccessControl[0].PermissionLevel)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformRegisteredModel(t *testing.T) {
|
||||
|
@ -527,15 +519,16 @@ func TestBundleToTerraformRegisteredModel(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourceRegisteredModel
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.RegisteredModel["my_registered_model"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.RegisteredModel["my_registered_model"].(*schema.ResourceRegisteredModel)
|
||||
|
||||
assert.Equal(t, "name", resource.Name)
|
||||
assert.Equal(t, "catalog", resource.CatalogName)
|
||||
assert.Equal(t, "schema", resource.SchemaName)
|
||||
assert.Equal(t, "comment", resource.Comment)
|
||||
assert.Nil(t, out.Data)
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformRegisteredModelGrants(t *testing.T) {
|
||||
|
@ -561,14 +554,15 @@ func TestBundleToTerraformRegisteredModelGrants(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
var resource schema.ResourceGrants
|
||||
out := produceTerraformConfiguration(t, config)
|
||||
convertToResourceStruct(t, &resource, out.Resource.Grants["registered_model_my_registered_model"])
|
||||
out := BundleToTerraform(&config)
|
||||
resource := out.Resource.Grants["registered_model_my_registered_model"].(*schema.ResourceGrants)
|
||||
|
||||
assert.NotEmpty(t, resource.Function)
|
||||
assert.Len(t, resource.Grant, 1)
|
||||
assert.Equal(t, "jane@doe.com", resource.Grant[0].Principal)
|
||||
assert.Equal(t, "EXECUTE", resource.Grant[0].Privileges[0])
|
||||
|
||||
bundleToTerraformEquivalenceTest(t, &config)
|
||||
}
|
||||
|
||||
func TestBundleToTerraformDeletedResources(t *testing.T) {
|
||||
|
@ -1160,3 +1154,25 @@ 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.
|
||||
if permissions := convertPermissionsResource(ctx, vin); permissions != nil {
|
||||
permissions.ClusterId = fmt.Sprintf("${databricks_cluster.%s.id}", key)
|
||||
permissions.JobId = fmt.Sprintf("${databricks_cluster.%s.id}", key)
|
||||
out.Permissions["cluster_"+key] = permissions
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ func TestConvertCluster(t *testing.T) {
|
|||
|
||||
// Assert equality on the permissions
|
||||
assert.Equal(t, &schema.ResourcePermissions{
|
||||
ClusterId: "${databricks_cluster.my_cluster.id}",
|
||||
JobId: "${databricks_cluster.my_cluster.id}",
|
||||
AccessControl: []schema.ResourcePermissionsAccessControl{
|
||||
{
|
||||
PermissionLevel: "CAN_RUN",
|
||||
|
|
|
@ -57,12 +57,6 @@ 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 strings.HasPrefix(dep, "-r") {
|
||||
return false
|
||||
|
@ -76,11 +70,6 @@ func IsLibraryLocal(dep string) bool {
|
|||
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 (_).
|
||||
// \[.*\])?: 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).
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
const CAN_MANAGE = "CAN_MANAGE"
|
||||
const CAN_VIEW = "CAN_VIEW"
|
||||
const CAN_RUN = "CAN_RUN"
|
||||
const IS_OWNER = "IS_OWNER"
|
||||
|
||||
var allowedLevels = []string{CAN_MANAGE, CAN_VIEW, CAN_RUN}
|
||||
var levelsMap = map[string](map[string]string){
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
package permissions
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/databricks/cli/bundle"
|
||||
"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 isWorkspaceSharedRoot(b.Config.Workspace.RootPath) {
|
||||
return isUsersGroupPermissionSet(b)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func isWorkspaceSharedRoot(path string) bool {
|
||||
return strings.HasPrefix(path, "/Workspace/Shared/")
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
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)
|
||||
}
|
|
@ -16,10 +16,6 @@ func ApplyWorkspaceRootPermissions() bundle.Mutator {
|
|||
return &workspaceRootPermissions{}
|
||||
}
|
||||
|
||||
func (*workspaceRootPermissions) Name() string {
|
||||
return "ApplyWorkspaceRootPermissions"
|
||||
}
|
||||
|
||||
// Apply implements bundle.Mutator.
|
||||
func (*workspaceRootPermissions) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
||||
err := giveAccessForWorkspaceRoot(ctx, b)
|
||||
|
@ -30,6 +26,10 @@ func (*workspaceRootPermissions) Apply(ctx context.Context, b *bundle.Bundle) di
|
|||
return nil
|
||||
}
|
||||
|
||||
func (*workspaceRootPermissions) Name() string {
|
||||
return "ApplyWorkspaceRootPermissions"
|
||||
}
|
||||
|
||||
func giveAccessForWorkspaceRoot(ctx context.Context, b *bundle.Bundle) error {
|
||||
permissions := make([]workspace.WorkspaceObjectAccessControlRequest, 0)
|
||||
|
||||
|
|
|
@ -69,6 +69,6 @@ func TestApplyWorkspaceRootPermissions(t *testing.T) {
|
|||
WorkspaceObjectType: "directories",
|
||||
}).Return(nil, nil)
|
||||
|
||||
diags := bundle.Apply(context.Background(), b, bundle.Seq(ValidateSharedRootPermissions(), ApplyWorkspaceRootPermissions()))
|
||||
require.Empty(t, diags)
|
||||
diags := bundle.Apply(context.Background(), b, ApplyWorkspaceRootPermissions())
|
||||
require.NoError(t, diags.Error())
|
||||
}
|
||||
|
|
|
@ -76,11 +76,8 @@ func Initialize() bundle.Mutator {
|
|||
|
||||
mutator.TranslatePaths(),
|
||||
trampoline.WrapperWarning(),
|
||||
|
||||
permissions.ValidateSharedRootPermissions(),
|
||||
permissions.ApplyBundlePermissions(),
|
||||
permissions.FilterCurrentUser(),
|
||||
|
||||
metadata.AnnotateJobs(),
|
||||
metadata.AnnotatePipelines(),
|
||||
terraform.Initialize(),
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
package render
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/databricks/cli/bundle"
|
||||
"github.com/databricks/cli/libs/cmdio"
|
||||
"github.com/databricks/cli/libs/diag"
|
||||
"github.com/databricks/databricks-sdk-go/service/iam"
|
||||
"github.com/fatih/color"
|
||||
|
@ -31,7 +28,49 @@ var renderFuncMap = template.FuncMap{
|
|||
},
|
||||
}
|
||||
|
||||
const summaryHeaderTemplate = `{{- if .Name -}}
|
||||
const errorTemplate = `{{ "Error" | red }}: {{ .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 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 }}
|
||||
{{- if .Target }}
|
||||
Target: {{ .Target | bold }}
|
||||
|
@ -48,30 +87,12 @@ Workspace:
|
|||
Path: {{ .Path | bold }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{ end -}}`
|
||||
|
||||
const resourcesTemplate = `Resources:
|
||||
{{- range . }}
|
||||
{{ .GroupName }}:
|
||||
{{- range .Resources }}
|
||||
{{ .Key | bold }}:
|
||||
Name: {{ .Name }}
|
||||
URL: {{ if .URL }}{{ .URL | cyan }}{{ else }}{{ "(not deployed)" | cyan }}{{ end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{ end -}}
|
||||
|
||||
{{ .Trailer }}
|
||||
`
|
||||
|
||||
type ResourceGroup struct {
|
||||
GroupName string
|
||||
Resources []ResourceInfo
|
||||
}
|
||||
|
||||
type ResourceInfo struct {
|
||||
Key string
|
||||
Name string
|
||||
URL string
|
||||
}
|
||||
|
||||
func pluralize(n int, singular, plural string) string {
|
||||
if n == 1 {
|
||||
return fmt.Sprintf("%d %s", n, singular)
|
||||
|
@ -94,20 +115,20 @@ func buildTrailer(diags diag.Diagnostics) string {
|
|||
case len(parts) >= 3:
|
||||
first := strings.Join(parts[:len(parts)-1], ", ")
|
||||
last := parts[len(parts)-1]
|
||||
return fmt.Sprintf("Found %s, and %s\n", first, last)
|
||||
return fmt.Sprintf("Found %s, and %s", first, last)
|
||||
case len(parts) == 2:
|
||||
return fmt.Sprintf("Found %s and %s\n", parts[0], parts[1])
|
||||
return fmt.Sprintf("Found %s and %s", parts[0], parts[1])
|
||||
case len(parts) == 1:
|
||||
return fmt.Sprintf("Found %s\n", parts[0])
|
||||
return fmt.Sprintf("Found %s", parts[0])
|
||||
default:
|
||||
// No diagnostics to print.
|
||||
return color.GreenString("Validation OK!\n")
|
||||
return color.GreenString("Validation OK!")
|
||||
}
|
||||
}
|
||||
|
||||
func renderSummaryHeaderTemplate(out io.Writer, b *bundle.Bundle) error {
|
||||
func renderSummaryTemplate(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics) error {
|
||||
if b == nil {
|
||||
return renderSummaryHeaderTemplate(out, &bundle.Bundle{})
|
||||
return renderSummaryTemplate(out, &bundle.Bundle{}, diags)
|
||||
}
|
||||
|
||||
var currentUser = &iam.User{}
|
||||
|
@ -118,20 +139,36 @@ func renderSummaryHeaderTemplate(out io.Writer, b *bundle.Bundle) error {
|
|||
}
|
||||
}
|
||||
|
||||
t := template.Must(template.New("summary").Funcs(renderFuncMap).Parse(summaryHeaderTemplate))
|
||||
t := template.Must(template.New("summary").Funcs(renderFuncMap).Parse(summaryTemplate))
|
||||
err := t.Execute(out, map[string]any{
|
||||
"Name": b.Config.Bundle.Name,
|
||||
"Target": b.Config.Bundle.Target,
|
||||
"User": currentUser.UserName,
|
||||
"Path": b.Config.Workspace.RootPath,
|
||||
"Host": b.Config.Workspace.Host,
|
||||
"Trailer": buildTrailer(diags),
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func renderDiagnosticsOnly(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics) error {
|
||||
func renderDiagnostics(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 {
|
||||
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 {
|
||||
if b == nil {
|
||||
break
|
||||
|
@ -146,9 +183,15 @@ func renderDiagnosticsOnly(out io.Writer, b *bundle.Bundle, diags diag.Diagnosti
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 cmdio.RenderDiagnostics(out, diags)
|
||||
return nil
|
||||
}
|
||||
|
||||
// RenderOptions contains options for rendering diagnostics.
|
||||
|
@ -158,73 +201,19 @@ type RenderOptions struct {
|
|||
RenderSummaryTable bool
|
||||
}
|
||||
|
||||
// RenderDiagnostics renders the diagnostics in a human-readable format.
|
||||
func RenderDiagnostics(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics, opts RenderOptions) error {
|
||||
err := renderDiagnosticsOnly(out, b, diags)
|
||||
// RenderTextOutput renders the diagnostics in a human-readable format.
|
||||
func RenderTextOutput(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics, opts RenderOptions) error {
|
||||
err := renderDiagnostics(out, b, diags)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to render diagnostics: %w", err)
|
||||
}
|
||||
|
||||
if opts.RenderSummaryTable {
|
||||
if b != nil {
|
||||
err = renderSummaryHeaderTemplate(out, b)
|
||||
err = renderSummaryTemplate(out, b, diags)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to render summary: %w", err)
|
||||
}
|
||||
io.WriteString(out, "\n")
|
||||
}
|
||||
trailer := buildTrailer(diags)
|
||||
io.WriteString(out, trailer)
|
||||
}
|
||||
|
||||
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,21 +2,14 @@ package render
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"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/cli/libs/dyn"
|
||||
"github.com/databricks/databricks-sdk-go/service/catalog"
|
||||
assert "github.com/databricks/cli/libs/dyn/dynassert"
|
||||
"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"
|
||||
)
|
||||
|
||||
|
@ -333,7 +326,7 @@ func TestRenderTextOutput(t *testing.T) {
|
|||
t.Run(tc.name, func(t *testing.T) {
|
||||
writer := &bytes.Buffer{}
|
||||
|
||||
err := RenderDiagnostics(writer, tc.bundle, tc.diags, tc.opts)
|
||||
err := RenderTextOutput(writer, tc.bundle, tc.diags, tc.opts)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, tc.expected, writer.String())
|
||||
|
@ -475,7 +468,7 @@ func TestRenderDiagnostics(t *testing.T) {
|
|||
t.Run(tc.name, func(t *testing.T) {
|
||||
writer := &bytes.Buffer{}
|
||||
|
||||
err := renderDiagnosticsOnly(writer, bundle, tc.diags)
|
||||
err := renderDiagnostics(writer, bundle, tc.diags)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, tc.expected, writer.String())
|
||||
|
@ -486,105 +479,8 @@ func TestRenderDiagnostics(t *testing.T) {
|
|||
func TestRenderSummaryTemplate_nilBundle(t *testing.T) {
|
||||
writer := &bytes.Buffer{}
|
||||
|
||||
err := renderSummaryHeaderTemplate(writer, nil)
|
||||
err := renderSummaryTemplate(writer, nil, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
io.WriteString(writer, buildTrailer(nil))
|
||||
|
||||
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())
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
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:
|
|
@ -1,48 +0,0 @@
|
|||
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,16 +205,10 @@ func newUpdateRuleSet() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateRuleSetJson.Unmarshal(&updateRuleSetReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateRuleSetJson.Unmarshal(&updateRuleSetReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -78,16 +78,10 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -322,16 +316,10 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -90,16 +90,10 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -129,16 +129,10 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -88,17 +88,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := a.CustomAppIntegration.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -326,17 +320,11 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.IntegrationId = args[0]
|
||||
|
||||
err = a.CustomAppIntegration.Update(ctx, updateReq)
|
||||
|
|
|
@ -185,16 +185,10 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -107,16 +107,10 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -127,16 +127,10 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -97,17 +97,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := a.Groups.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -364,17 +358,11 @@ func newPatch() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := patchJson.Unmarshal(&patchReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = patchJson.Unmarshal(&patchReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
|
||||
|
@ -458,17 +446,11 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
|
||||
|
|
|
@ -132,17 +132,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.Label = args[0]
|
||||
}
|
||||
|
@ -417,17 +411,11 @@ func newReplace() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := replaceJson.Unmarshal(&replaceReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = replaceJson.Unmarshal(&replaceReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
replaceReq.IpAccessListId = args[0]
|
||||
if !cmd.Flags().Changed("json") {
|
||||
replaceReq.Label = args[1]
|
||||
|
@ -517,17 +505,11 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No IP_ACCESS_LIST_ID argument specified. Loading names for Account Ip Access Lists drop-down."
|
||||
|
|
|
@ -162,17 +162,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := a.LogDelivery.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -375,17 +369,11 @@ func newPatchStatus() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := patchStatusJson.Unmarshal(&patchStatusReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = patchStatusJson.Unmarshal(&patchStatusReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
patchStatusReq.LogDeliveryConfigurationId = args[0]
|
||||
if !cmd.Flags().Changed("json") {
|
||||
_, err = fmt.Sscan(args[1], &patchStatusReq.Status)
|
||||
|
|
|
@ -85,17 +85,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err = fmt.Sscan(args[0], &createReq.WorkspaceId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
|
||||
|
@ -349,17 +343,11 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
|
||||
|
|
|
@ -80,17 +80,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := a.Metastores.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -310,17 +304,11 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.MetastoreId = args[0]
|
||||
|
||||
response, err := a.Metastores.Update(ctx, updateReq)
|
||||
|
|
|
@ -96,17 +96,11 @@ func newCreateNetworkConnectivityConfiguration() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createNetworkConnectivityConfigurationJson.Unmarshal(&createNetworkConnectivityConfigurationReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createNetworkConnectivityConfigurationJson.Unmarshal(&createNetworkConnectivityConfigurationReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createNetworkConnectivityConfigurationReq.Name = args[0]
|
||||
}
|
||||
|
@ -193,17 +187,11 @@ func newCreatePrivateEndpointRule() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createPrivateEndpointRuleJson.Unmarshal(&createPrivateEndpointRuleReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createPrivateEndpointRuleJson.Unmarshal(&createPrivateEndpointRuleReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
createPrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0]
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createPrivateEndpointRuleReq.ResourceId = args[1]
|
||||
|
|
|
@ -97,17 +97,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.NetworkName = args[0]
|
||||
}
|
||||
|
|
|
@ -189,16 +189,10 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -109,17 +109,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.PrivateAccessSettingsName = args[0]
|
||||
}
|
||||
|
@ -417,17 +411,11 @@ func newReplace() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := replaceJson.Unmarshal(&replaceReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = replaceJson.Unmarshal(&replaceReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
replaceReq.PrivateAccessSettingsId = args[0]
|
||||
if !cmd.Flags().Changed("json") {
|
||||
replaceReq.PrivateAccessSettingsName = args[1]
|
||||
|
|
|
@ -85,17 +85,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := a.PublishedAppIntegration.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -321,17 +315,11 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.IntegrationId = args[0]
|
||||
|
||||
err = a.PublishedAppIntegration.Update(ctx, updateReq)
|
||||
|
|
|
@ -95,17 +95,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := a.ServicePrincipals.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -364,17 +358,11 @@ func newPatch() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := patchJson.Unmarshal(&patchReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = patchJson.Unmarshal(&patchReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
|
||||
|
@ -460,17 +448,11 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
|
||||
|
|
|
@ -88,17 +88,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
createReq.MetastoreId = args[0]
|
||||
|
||||
response, err := a.StorageCredentials.Create(ctx, createReq)
|
||||
|
@ -346,17 +340,11 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.MetastoreId = args[0]
|
||||
updateReq.StorageCredentialName = args[1]
|
||||
|
||||
|
|
|
@ -87,16 +87,10 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -80,17 +80,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := a.UsageDashboards.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
|
|
@ -103,17 +103,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := a.Users.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -380,17 +374,11 @@ func newPatch() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := patchJson.Unmarshal(&patchReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = patchJson.Unmarshal(&patchReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
|
||||
|
@ -477,17 +465,11 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
|
||||
|
|
|
@ -104,17 +104,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.VpcEndpointName = args[0]
|
||||
}
|
||||
|
|
|
@ -273,17 +273,11 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
|
||||
|
|
|
@ -133,17 +133,11 @@ func newCreate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.WorkspaceName = args[0]
|
||||
}
|
||||
|
@ -557,17 +551,11 @@ func newUpdate() *cobra.Command {
|
|||
a := root.AccountClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
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 request any
|
||||
diags := payload.Unmarshal(&request)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
err := payload.Unmarshal(&request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cfg := &config.Config{}
|
||||
|
|
|
@ -78,7 +78,7 @@ func newDeployCommand() *cobra.Command {
|
|||
}
|
||||
|
||||
renderOpts := render.RenderOptions{RenderSummaryTable: false}
|
||||
err := render.RenderDiagnostics(cmd.OutOrStdout(), b, diags, renderOpts)
|
||||
err := render.RenderTextOutput(cmd.OutOrStdout(), b, diags, renderOpts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to render output: %w", err)
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ func (n *downloader) markNotebookForDownload(ctx context.Context, notebookPath *
|
|||
|
||||
ext := notebook.GetExtensionByLanguage(info)
|
||||
|
||||
filename := path.Base(*notebookPath) + string(ext)
|
||||
filename := path.Base(*notebookPath) + ext
|
||||
targetPath := filepath.Join(n.sourceDir, filename)
|
||||
|
||||
n.files[targetPath] = *notebookPath
|
||||
|
|
|
@ -8,10 +8,8 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"github.com/databricks/cli/bundle"
|
||||
"github.com/databricks/cli/bundle/config/mutator"
|
||||
"github.com/databricks/cli/bundle/deploy/terraform"
|
||||
"github.com/databricks/cli/bundle/phases"
|
||||
"github.com/databricks/cli/bundle/render"
|
||||
"github.com/databricks/cli/cmd/bundle/utils"
|
||||
"github.com/databricks/cli/cmd/root"
|
||||
"github.com/databricks/cli/libs/flags"
|
||||
|
@ -21,8 +19,11 @@ import (
|
|||
func newSummaryCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "summary",
|
||||
Short: "Summarize resources deployed by this bundle",
|
||||
Short: "Describe the bundle resources and their deployment states",
|
||||
Args: root.NoArgs,
|
||||
|
||||
// This command is currently intended for the Databricks VSCode extension only
|
||||
Hidden: true,
|
||||
}
|
||||
|
||||
var forcePull bool
|
||||
|
@ -59,15 +60,14 @@ func newSummaryCommand() *cobra.Command {
|
|||
}
|
||||
}
|
||||
|
||||
diags = bundle.Apply(ctx, b,
|
||||
bundle.Seq(terraform.Load(), mutator.InitializeURLs()))
|
||||
diags = bundle.Apply(ctx, b, terraform.Load())
|
||||
if err := diags.Error(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch root.OutputType(cmd) {
|
||||
case flags.OutputText:
|
||||
return render.RenderSummary(ctx, cmd.OutOrStdout(), b)
|
||||
return fmt.Errorf("%w, only json output is supported", errors.ErrUnsupported)
|
||||
case flags.OutputJSON:
|
||||
buf, err := json.MarshalIndent(b.Config, "", " ")
|
||||
if err != nil {
|
||||
|
|
|
@ -54,7 +54,7 @@ func newValidateCommand() *cobra.Command {
|
|||
switch root.OutputType(cmd) {
|
||||
case flags.OutputText:
|
||||
renderOpts := render.RenderOptions{RenderSummaryTable: true}
|
||||
err := render.RenderDiagnostics(cmd.OutOrStdout(), b, diags, renderOpts)
|
||||
err := render.RenderTextOutput(cmd.OutOrStdout(), b, diags, renderOpts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to render output: %w", err)
|
||||
}
|
||||
|
|
|
@ -93,16 +93,10 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -363,16 +357,10 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -85,17 +85,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := w.Alerts.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -360,17 +354,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.Id = args[0]
|
||||
if !cmd.Flags().Changed("json") {
|
||||
updateReq.UpdateMask = args[1]
|
||||
|
|
|
@ -113,17 +113,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.Name = args[0]
|
||||
}
|
||||
|
@ -273,17 +267,11 @@ func newDeploy() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := deployJson.Unmarshal(&deployReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = deployJson.Unmarshal(&deployReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
deployReq.AppName = args[0]
|
||||
|
||||
wait, err := w.Apps.Deploy(ctx, deployReq)
|
||||
|
@ -714,17 +702,11 @@ func newSetPermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
setPermissionsReq.AppName = args[0]
|
||||
|
||||
response, err := w.Apps.SetPermissions(ctx, setPermissionsReq)
|
||||
|
@ -954,17 +936,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.Name = args[0]
|
||||
|
||||
response, err := w.Apps.Update(ctx, updateReq)
|
||||
|
@ -1029,17 +1005,11 @@ func newUpdatePermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updatePermissionsReq.AppName = args[0]
|
||||
|
||||
response, err := w.Apps.UpdatePermissions(ctx, updatePermissionsReq)
|
||||
|
|
|
@ -145,16 +145,10 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -127,16 +127,10 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -105,17 +105,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.Name = args[0]
|
||||
}
|
||||
|
@ -369,17 +363,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.Name = args[0]
|
||||
|
||||
response, err := w.Catalogs.Update(ctx, updateReq)
|
||||
|
|
|
@ -85,16 +85,10 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -350,17 +344,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.Name = args[0]
|
||||
|
||||
response, err := w.CleanRooms.Update(ctx, updateReq)
|
||||
|
|
|
@ -113,17 +113,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := w.ClusterPolicies.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -191,16 +185,10 @@ func newDelete() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := deleteJson.Unmarshal(&deleteReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = deleteJson.Unmarshal(&deleteReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -296,16 +284,10 @@ func newEdit() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := editJson.Unmarshal(&editReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = editJson.Unmarshal(&editReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -648,17 +630,11 @@ func newSetPermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."
|
||||
|
@ -735,17 +711,11 @@ func newUpdatePermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."
|
||||
|
|
|
@ -134,17 +134,11 @@ func newChangeOwner() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := changeOwnerJson.Unmarshal(&changeOwnerReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = changeOwnerJson.Unmarshal(&changeOwnerReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
changeOwnerReq.ClusterId = args[0]
|
||||
}
|
||||
|
@ -274,17 +268,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.SparkVersion = args[0]
|
||||
}
|
||||
|
@ -374,16 +362,10 @@ func newDelete() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := deleteJson.Unmarshal(&deleteReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = deleteJson.Unmarshal(&deleteReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -537,17 +519,11 @@ func newEdit() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := editJson.Unmarshal(&editReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = editJson.Unmarshal(&editReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
editReq.ClusterId = args[0]
|
||||
}
|
||||
|
@ -641,16 +617,10 @@ func newEvents() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := eventsJson.Unmarshal(&eventsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = eventsJson.Unmarshal(&eventsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -1099,16 +1069,10 @@ func newPermanentDelete() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := permanentDeleteJson.Unmarshal(&permanentDeleteReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = permanentDeleteJson.Unmarshal(&permanentDeleteReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -1197,16 +1161,10 @@ func newPin() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := pinJson.Unmarshal(&pinReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = pinJson.Unmarshal(&pinReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -1302,16 +1260,10 @@ func newResize() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := resizeJson.Unmarshal(&resizeReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = resizeJson.Unmarshal(&resizeReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -1418,16 +1370,10 @@ func newRestart() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := restartJson.Unmarshal(&restartReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = restartJson.Unmarshal(&restartReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -1518,17 +1464,11 @@ func newSetPermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."
|
||||
|
@ -1668,16 +1608,10 @@ func newStart() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := startJson.Unmarshal(&startReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = startJson.Unmarshal(&startReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -1778,16 +1712,10 @@ func newUnpin() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := unpinJson.Unmarshal(&unpinReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = unpinJson.Unmarshal(&unpinReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -1896,17 +1824,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
updateReq.ClusterId = args[0]
|
||||
}
|
||||
|
@ -1983,17 +1905,11 @@ func newUpdatePermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."
|
||||
|
|
|
@ -130,16 +130,10 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -92,16 +92,10 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -361,16 +355,10 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -86,17 +86,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
createReq.ListingId = args[0]
|
||||
|
||||
response, err := w.ConsumerInstallations.Create(ctx, createReq)
|
||||
|
@ -325,16 +319,10 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -85,16 +85,10 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -75,16 +75,10 @@ func newExchangeToken() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := exchangeTokenJson.Unmarshal(&exchangeTokenReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = exchangeTokenJson.Unmarshal(&exchangeTokenReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -75,16 +75,10 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -202,16 +196,10 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -78,16 +78,10 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -411,17 +405,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No DASHBOARD_ID argument specified. Loading names for Dashboards drop-down."
|
||||
|
|
|
@ -199,16 +199,10 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -187,16 +187,10 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -132,16 +132,10 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -130,17 +130,11 @@ func newCreateExperiment() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createExperimentJson.Unmarshal(&createExperimentReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createExperimentJson.Unmarshal(&createExperimentReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createExperimentReq.Name = args[0]
|
||||
}
|
||||
|
@ -209,17 +203,11 @@ func newCreateRun() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createRunJson.Unmarshal(&createRunReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createRunJson.Unmarshal(&createRunReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := w.Experiments.CreateRun(ctx, createRunReq)
|
||||
if err != nil {
|
||||
|
@ -289,17 +277,11 @@ func newDeleteExperiment() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := deleteExperimentJson.Unmarshal(&deleteExperimentReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = deleteExperimentJson.Unmarshal(&deleteExperimentReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
deleteExperimentReq.ExperimentId = args[0]
|
||||
}
|
||||
|
@ -370,17 +352,11 @@ func newDeleteRun() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := deleteRunJson.Unmarshal(&deleteRunReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = deleteRunJson.Unmarshal(&deleteRunReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
deleteRunReq.RunId = args[0]
|
||||
}
|
||||
|
@ -459,17 +435,11 @@ func newDeleteRuns() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := deleteRunsJson.Unmarshal(&deleteRunsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = deleteRunsJson.Unmarshal(&deleteRunsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
deleteRunsReq.ExperimentId = args[0]
|
||||
}
|
||||
|
@ -548,17 +518,11 @@ func newDeleteTag() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := deleteTagJson.Unmarshal(&deleteTagReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = deleteTagJson.Unmarshal(&deleteTagReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
deleteTagReq.RunId = args[0]
|
||||
}
|
||||
|
@ -1144,17 +1108,11 @@ func newLogBatch() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := logBatchJson.Unmarshal(&logBatchReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = logBatchJson.Unmarshal(&logBatchReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = w.Experiments.LogBatch(ctx, logBatchReq)
|
||||
if err != nil {
|
||||
|
@ -1216,17 +1174,11 @@ func newLogInputs() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := logInputsJson.Unmarshal(&logInputsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = logInputsJson.Unmarshal(&logInputsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = w.Experiments.LogInputs(ctx, logInputsReq)
|
||||
if err != nil {
|
||||
|
@ -1302,17 +1254,11 @@ func newLogMetric() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := logMetricJson.Unmarshal(&logMetricReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = logMetricJson.Unmarshal(&logMetricReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
logMetricReq.Key = args[0]
|
||||
}
|
||||
|
@ -1389,17 +1335,11 @@ func newLogModel() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := logModelJson.Unmarshal(&logModelReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = logModelJson.Unmarshal(&logModelReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = w.Experiments.LogModel(ctx, logModelReq)
|
||||
if err != nil {
|
||||
|
@ -1474,17 +1414,11 @@ func newLogParam() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := logParamJson.Unmarshal(&logParamReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = logParamJson.Unmarshal(&logParamReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
logParamReq.Key = args[0]
|
||||
}
|
||||
|
@ -1563,17 +1497,11 @@ func newRestoreExperiment() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := restoreExperimentJson.Unmarshal(&restoreExperimentReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = restoreExperimentJson.Unmarshal(&restoreExperimentReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
restoreExperimentReq.ExperimentId = args[0]
|
||||
}
|
||||
|
@ -1644,17 +1572,11 @@ func newRestoreRun() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := restoreRunJson.Unmarshal(&restoreRunReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = restoreRunJson.Unmarshal(&restoreRunReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
restoreRunReq.RunId = args[0]
|
||||
}
|
||||
|
@ -1733,17 +1655,11 @@ func newRestoreRuns() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := restoreRunsJson.Unmarshal(&restoreRunsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = restoreRunsJson.Unmarshal(&restoreRunsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
restoreRunsReq.ExperimentId = args[0]
|
||||
}
|
||||
|
@ -1816,17 +1732,11 @@ func newSearchExperiments() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := searchExperimentsJson.Unmarshal(&searchExperimentsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = searchExperimentsJson.Unmarshal(&searchExperimentsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response := w.Experiments.SearchExperiments(ctx, searchExperimentsReq)
|
||||
return cmdio.RenderIterator(ctx, response)
|
||||
|
@ -1890,17 +1800,11 @@ func newSearchRuns() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := searchRunsJson.Unmarshal(&searchRunsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = searchRunsJson.Unmarshal(&searchRunsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response := w.Experiments.SearchRuns(ctx, searchRunsReq)
|
||||
return cmdio.RenderIterator(ctx, response)
|
||||
|
@ -1970,17 +1874,11 @@ func newSetExperimentTag() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := setExperimentTagJson.Unmarshal(&setExperimentTagReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = setExperimentTagJson.Unmarshal(&setExperimentTagReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
setExperimentTagReq.ExperimentId = args[0]
|
||||
}
|
||||
|
@ -2053,17 +1951,11 @@ func newSetPermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
setPermissionsReq.ExperimentId = args[0]
|
||||
|
||||
response, err := w.Experiments.SetPermissions(ctx, setPermissionsReq)
|
||||
|
@ -2140,17 +2032,11 @@ func newSetTag() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := setTagJson.Unmarshal(&setTagReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = setTagJson.Unmarshal(&setTagReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
setTagReq.Key = args[0]
|
||||
}
|
||||
|
@ -2226,17 +2112,11 @@ func newUpdateExperiment() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateExperimentJson.Unmarshal(&updateExperimentReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateExperimentJson.Unmarshal(&updateExperimentReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
updateExperimentReq.ExperimentId = args[0]
|
||||
}
|
||||
|
@ -2303,17 +2183,11 @@ func newUpdatePermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updatePermissionsReq.ExperimentId = args[0]
|
||||
|
||||
response, err := w.Experiments.UpdatePermissions(ctx, updatePermissionsReq)
|
||||
|
@ -2377,17 +2251,11 @@ func newUpdateRun() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateRunJson.Unmarshal(&updateRunReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateRunJson.Unmarshal(&updateRunReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := w.Experiments.UpdateRun(ctx, updateRunReq)
|
||||
if err != nil {
|
||||
|
|
|
@ -112,17 +112,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.Name = args[0]
|
||||
}
|
||||
|
@ -387,17 +381,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.Name = args[0]
|
||||
|
||||
response, err := w.ExternalLocations.Update(ctx, updateReq)
|
||||
|
|
|
@ -85,16 +85,10 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -387,17 +381,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No NAME argument specified. Loading names for Functions drop-down."
|
||||
|
|
|
@ -105,17 +105,11 @@ func newCreateMessage() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createMessageJson.Unmarshal(&createMessageReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createMessageJson.Unmarshal(&createMessageReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
createMessageReq.SpaceId = args[0]
|
||||
createMessageReq.ConversationId = args[1]
|
||||
if !cmd.Flags().Changed("json") {
|
||||
|
@ -398,17 +392,11 @@ func newStartConversation() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := startConversationJson.Unmarshal(&startConversationReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = startConversationJson.Unmarshal(&startConversationReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
startConversationReq.SpaceId = args[0]
|
||||
if !cmd.Flags().Changed("json") {
|
||||
startConversationReq.Content = args[1]
|
||||
|
|
|
@ -103,17 +103,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.GitProvider = args[0]
|
||||
}
|
||||
|
@ -377,17 +371,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err = fmt.Sscan(args[0], &updateReq.CredentialId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid CREDENTIAL_ID: %s", args[0])
|
||||
|
|
|
@ -101,17 +101,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.Name = args[0]
|
||||
}
|
||||
|
@ -373,17 +367,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.ScriptId = args[0]
|
||||
if !cmd.Flags().Changed("json") {
|
||||
updateReq.Name = args[1]
|
||||
|
|
|
@ -223,17 +223,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err = fmt.Sscan(args[0], &updateReq.SecurableType)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid SECURABLE_TYPE: %s", args[0])
|
||||
|
|
|
@ -97,17 +97,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := w.Groups.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -364,17 +358,11 @@ func newPatch() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := patchJson.Unmarshal(&patchReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = patchJson.Unmarshal(&patchReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No ID argument specified. Loading names for Groups drop-down."
|
||||
|
@ -458,17 +446,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No ID argument specified. Loading names for Groups drop-down."
|
||||
|
|
|
@ -128,17 +128,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.InstancePoolName = args[0]
|
||||
}
|
||||
|
@ -212,16 +206,10 @@ func newDelete() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := deleteJson.Unmarshal(&deleteReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = deleteJson.Unmarshal(&deleteReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -321,17 +309,11 @@ func newEdit() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := editJson.Unmarshal(&editReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = editJson.Unmarshal(&editReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
editReq.InstancePoolId = args[0]
|
||||
}
|
||||
|
@ -649,17 +631,11 @@ func newSetPermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down."
|
||||
|
@ -736,17 +712,11 @@ func newUpdatePermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down."
|
||||
|
|
|
@ -99,17 +99,11 @@ func newAdd() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := addJson.Unmarshal(&addReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = addJson.Unmarshal(&addReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
addReq.InstanceProfileArn = args[0]
|
||||
}
|
||||
|
@ -198,17 +192,11 @@ func newEdit() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := editJson.Unmarshal(&editReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = editJson.Unmarshal(&editReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
editReq.InstanceProfileArn = args[0]
|
||||
}
|
||||
|
@ -323,17 +311,11 @@ func newRemove() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := removeJson.Unmarshal(&removeReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = removeJson.Unmarshal(&removeReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
removeReq.InstanceProfileArn = args[0]
|
||||
}
|
||||
|
|
|
@ -133,17 +133,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.Label = args[0]
|
||||
}
|
||||
|
@ -420,17 +414,11 @@ func newReplace() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := replaceJson.Unmarshal(&replaceReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = replaceJson.Unmarshal(&replaceReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
replaceReq.IpAccessListId = args[0]
|
||||
if !cmd.Flags().Changed("json") {
|
||||
replaceReq.Label = args[1]
|
||||
|
@ -522,17 +510,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No IP_ACCESS_LIST_ID argument specified. Loading names for Ip Access Lists drop-down."
|
||||
|
|
|
@ -116,17 +116,11 @@ func newCancelAllRuns() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := cancelAllRunsJson.Unmarshal(&cancelAllRunsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = cancelAllRunsJson.Unmarshal(&cancelAllRunsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err = w.Jobs.CancelAllRuns(ctx, cancelAllRunsReq)
|
||||
if err != nil {
|
||||
|
@ -199,16 +193,10 @@ func newCancelRun() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := cancelRunJson.Unmarshal(&cancelRunReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = cancelRunJson.Unmarshal(&cancelRunReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -303,16 +291,10 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -382,16 +364,10 @@ func newDelete() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := deleteJson.Unmarshal(&deleteReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = deleteJson.Unmarshal(&deleteReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -481,16 +457,10 @@ func newDeleteRun() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := deleteRunJson.Unmarshal(&deleteRunReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = deleteRunJson.Unmarshal(&deleteRunReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -1173,16 +1143,10 @@ func newRepairRun() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := repairRunJson.Unmarshal(&repairRunReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = repairRunJson.Unmarshal(&repairRunReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -1278,16 +1242,10 @@ func newReset() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := resetJson.Unmarshal(&resetReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = resetJson.Unmarshal(&resetReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -1374,16 +1332,10 @@ func newRunNow() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := runNowJson.Unmarshal(&runNowReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = runNowJson.Unmarshal(&runNowReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -1484,17 +1436,11 @@ func newSetPermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No JOB_ID argument specified. Loading names for Jobs drop-down."
|
||||
|
@ -1592,17 +1538,11 @@ func newSubmit() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := submitJson.Unmarshal(&submitReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = submitJson.Unmarshal(&submitReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wait, err := w.Jobs.Submit(ctx, submitReq)
|
||||
if err != nil {
|
||||
|
@ -1692,16 +1632,10 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
|
@ -1783,17 +1717,11 @@ func newUpdatePermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No JOB_ID argument specified. Loading names for Jobs drop-down."
|
||||
|
|
|
@ -108,17 +108,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.DisplayName = args[0]
|
||||
}
|
||||
|
@ -186,16 +180,10 @@ func newCreateSchedule() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createScheduleJson.Unmarshal(&createScheduleReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createScheduleJson.Unmarshal(&createScheduleReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -262,16 +250,10 @@ func newCreateSubscription() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createSubscriptionJson.Unmarshal(&createSubscriptionReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createSubscriptionJson.Unmarshal(&createSubscriptionReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -888,17 +870,11 @@ func newMigrate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := migrateJson.Unmarshal(&migrateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = migrateJson.Unmarshal(&migrateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
migrateReq.SourceDashboardId = args[0]
|
||||
}
|
||||
|
@ -965,17 +941,11 @@ func newPublish() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := publishJson.Unmarshal(&publishReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = publishJson.Unmarshal(&publishReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
publishReq.DashboardId = args[0]
|
||||
|
||||
response, err := w.Lakeview.Publish(ctx, publishReq)
|
||||
|
@ -1158,17 +1128,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.DashboardId = args[0]
|
||||
|
||||
response, err := w.Lakeview.Update(ctx, updateReq)
|
||||
|
@ -1236,16 +1200,10 @@ func newUpdateSchedule() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateScheduleJson.Unmarshal(&updateScheduleReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateScheduleJson.Unmarshal(&updateScheduleReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -190,16 +190,10 @@ func newInstall() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := installJson.Unmarshal(&installReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = installJson.Unmarshal(&installReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -257,16 +251,10 @@ func newUninstall() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := uninstallJson.Unmarshal(&uninstallReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = uninstallJson.Unmarshal(&uninstallReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
|
|
@ -112,17 +112,11 @@ func newAssign() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := assignJson.Unmarshal(&assignReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = assignJson.Unmarshal(&assignReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
_, err = fmt.Sscan(args[0], &assignReq.WorkspaceId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
|
||||
|
@ -207,17 +201,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.Name = args[0]
|
||||
}
|
||||
|
@ -618,17 +606,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No ID argument specified. Loading names for Metastores drop-down."
|
||||
|
@ -708,17 +690,11 @@ func newUpdateAssignment() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateAssignmentJson.Unmarshal(&updateAssignmentReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateAssignmentJson.Unmarshal(&updateAssignmentReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
promptSpinner := cmdio.Spinner(ctx)
|
||||
promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Metastores drop-down."
|
||||
|
|
|
@ -141,17 +141,11 @@ func newApproveTransitionRequest() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := approveTransitionRequestJson.Unmarshal(&approveTransitionRequestReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = approveTransitionRequestJson.Unmarshal(&approveTransitionRequestReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
approveTransitionRequestReq.Name = args[0]
|
||||
}
|
||||
|
@ -241,17 +235,11 @@ func newCreateComment() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createCommentJson.Unmarshal(&createCommentReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createCommentJson.Unmarshal(&createCommentReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createCommentReq.Name = args[0]
|
||||
}
|
||||
|
@ -334,17 +322,11 @@ func newCreateModel() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createModelJson.Unmarshal(&createModelReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createModelJson.Unmarshal(&createModelReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createModelReq.Name = args[0]
|
||||
}
|
||||
|
@ -421,17 +403,11 @@ func newCreateModelVersion() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createModelVersionJson.Unmarshal(&createModelVersionReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createModelVersionJson.Unmarshal(&createModelVersionReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createModelVersionReq.Name = args[0]
|
||||
}
|
||||
|
@ -517,17 +493,11 @@ func newCreateTransitionRequest() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createTransitionRequestJson.Unmarshal(&createTransitionRequestReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createTransitionRequestJson.Unmarshal(&createTransitionRequestReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createTransitionRequestReq.Name = args[0]
|
||||
}
|
||||
|
@ -600,16 +570,10 @@ func newCreateWebhook() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createWebhookJson.Unmarshal(&createWebhookReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createWebhookJson.Unmarshal(&createWebhookReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||
}
|
||||
|
@ -1115,17 +1079,11 @@ func newGetLatestVersions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := getLatestVersionsJson.Unmarshal(&getLatestVersionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = getLatestVersionsJson.Unmarshal(&getLatestVersionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
getLatestVersionsReq.Name = args[0]
|
||||
}
|
||||
|
@ -1671,17 +1629,11 @@ func newRejectTransitionRequest() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := rejectTransitionRequestJson.Unmarshal(&rejectTransitionRequestReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = rejectTransitionRequestJson.Unmarshal(&rejectTransitionRequestReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
rejectTransitionRequestReq.Name = args[0]
|
||||
}
|
||||
|
@ -1763,17 +1715,11 @@ func newRenameModel() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := renameModelJson.Unmarshal(&renameModelReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = renameModelJson.Unmarshal(&renameModelReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
renameModelReq.Name = args[0]
|
||||
}
|
||||
|
@ -1961,17 +1907,11 @@ func newSetModelTag() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := setModelTagJson.Unmarshal(&setModelTagReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = setModelTagJson.Unmarshal(&setModelTagReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
setModelTagReq.Name = args[0]
|
||||
}
|
||||
|
@ -2056,17 +1996,11 @@ func newSetModelVersionTag() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := setModelVersionTagJson.Unmarshal(&setModelVersionTagReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = setModelVersionTagJson.Unmarshal(&setModelVersionTagReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
setModelVersionTagReq.Name = args[0]
|
||||
}
|
||||
|
@ -2142,17 +2076,11 @@ func newSetPermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
setPermissionsReq.RegisteredModelId = args[0]
|
||||
|
||||
response, err := w.ModelRegistry.SetPermissions(ctx, setPermissionsReq)
|
||||
|
@ -2238,17 +2166,11 @@ func newTestRegistryWebhook() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := testRegistryWebhookJson.Unmarshal(&testRegistryWebhookReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = testRegistryWebhookJson.Unmarshal(&testRegistryWebhookReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
testRegistryWebhookReq.Id = args[0]
|
||||
}
|
||||
|
@ -2337,17 +2259,11 @@ func newTransitionStage() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := transitionStageJson.Unmarshal(&transitionStageReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = transitionStageJson.Unmarshal(&transitionStageReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
transitionStageReq.Name = args[0]
|
||||
}
|
||||
|
@ -2434,17 +2350,11 @@ func newUpdateComment() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateCommentJson.Unmarshal(&updateCommentReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateCommentJson.Unmarshal(&updateCommentReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
updateCommentReq.Id = args[0]
|
||||
}
|
||||
|
@ -2520,17 +2430,11 @@ func newUpdateModel() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateModelJson.Unmarshal(&updateModelReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateModelJson.Unmarshal(&updateModelReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
updateModelReq.Name = args[0]
|
||||
}
|
||||
|
@ -2604,17 +2508,11 @@ func newUpdateModelVersion() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateModelVersionJson.Unmarshal(&updateModelVersionReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateModelVersionJson.Unmarshal(&updateModelVersionReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
updateModelVersionReq.Name = args[0]
|
||||
}
|
||||
|
@ -2684,17 +2582,11 @@ func newUpdatePermissions() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updatePermissionsReq.RegisteredModelId = args[0]
|
||||
|
||||
response, err := w.ModelRegistry.UpdatePermissions(ctx, updatePermissionsReq)
|
||||
|
@ -2771,17 +2663,11 @@ func newUpdateWebhook() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateWebhookJson.Unmarshal(&updateWebhookReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateWebhookJson.Unmarshal(&updateWebhookReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
updateWebhookReq.Id = args[0]
|
||||
}
|
||||
|
|
|
@ -377,17 +377,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.FullName = args[0]
|
||||
_, err = fmt.Sscan(args[1], &updateReq.Version)
|
||||
if err != nil {
|
||||
|
|
|
@ -84,17 +84,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := w.NotificationDestinations.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -319,17 +313,11 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = updateJson.Unmarshal(&updateReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
updateReq.Id = args[0]
|
||||
|
||||
response, err := w.NotificationDestinations.Update(ctx, updateReq)
|
||||
|
|
|
@ -79,17 +79,11 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
if len(diags) > 0 {
|
||||
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
|
||||
err = createJson.Unmarshal(&createReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response, err := w.OnlineTables.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue