Compare commits

..

No commits in common. "0773084da581778e7d94ec220867e7ef0bd32725" and "5c7753330df8de57ad578c91cd1ecdce7ba5f6ae" have entirely different histories.

177 changed files with 1301 additions and 4576 deletions

View File

@ -1 +1 @@
0c86ea6dbd9a730c24ff0d4e509603e476955ac5
6f6b1371e640f2dfeba72d365ac566368656f6b6

View File

@ -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,15 +231,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -1,33 +1,5 @@
# Version changelog
## [Release] Release v0.230.0
Notable changes for Databricks Asset Bundles:
Workspace paths are automatically prefixed with `/Workspace`. In addition, all usage of path strings such as `/Workspace/${workspace.root_path}/...` in bundle configuration is automatically replaced with `${workspace.root_path}/...` and generates a warning as part of bundle validate.
More details can be found here: https://docs.databricks.com/en/release-notes/dev-tools/bundles.html#workspace-paths
Bundles:
* Add an error if state files grow bigger than the export limit ([#1795](https://github.com/databricks/cli/pull/1795)).
* Always prepend bundle remote paths with /Workspace ([#1724](https://github.com/databricks/cli/pull/1724)).
* Add resource path field to bundle workspace configuration ([#1800](https://github.com/databricks/cli/pull/1800)).
* Add validation for files with a `.(resource-name).yml` extension ([#1780](https://github.com/databricks/cli/pull/1780)).
Internal:
* Remove deprecated or readonly fields from the bundle schema ([#1809](https://github.com/databricks/cli/pull/1809)).
API Changes:
* Changed `databricks git-credentials create`, `databricks git-credentials delete`, `databricks git-credentials get`, `databricks git-credentials list`, `databricks git-credentials update` commands .
* Changed `databricks repos create`, `databricks repos delete`, `databricks repos get`, `databricks repos update` command .
OpenAPI commit 0c86ea6dbd9a730c24ff0d4e509603e476955ac5 (2024-10-02)
Dependency updates:
* Upgrade TF provider to 1.53.0 ([#1815](https://github.com/databricks/cli/pull/1815)).
* Bump golang.org/x/term from 0.24.0 to 0.25.0 ([#1811](https://github.com/databricks/cli/pull/1811)).
* Bump golang.org/x/text from 0.18.0 to 0.19.0 ([#1812](https://github.com/databricks/cli/pull/1812)).
* Bump github.com/databricks/databricks-sdk-go from 0.47.0 to 0.48.0 ([#1810](https://github.com/databricks/cli/pull/1810)).
## [Release] Release v0.229.0
Bundles:

View File

@ -5,8 +5,8 @@ import (
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/libs/auth"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/iamutil"
"github.com/databricks/cli/libs/tags"
)
@ -33,7 +33,7 @@ func (m *populateCurrentUser) Apply(ctx context.Context, b *bundle.Bundle) diag.
}
b.Config.Workspace.CurrentUser = &config.User{
ShortName: iamutil.GetShortUserName(me),
ShortName: auth.GetShortUserName(me),
User: me,
}

View File

@ -6,9 +6,9 @@ import (
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/libs/auth"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/dyn"
"github.com/databricks/cli/libs/iamutil"
"github.com/databricks/cli/libs/log"
)
@ -174,7 +174,7 @@ func (m *processTargetMode) Apply(ctx context.Context, b *bundle.Bundle) diag.Di
transformDevelopmentMode(ctx, b)
return diags
case config.Production:
isPrincipal := iamutil.IsServicePrincipal(b.Config.Workspace.CurrentUser.User)
isPrincipal := auth.IsServicePrincipal(b.Config.Workspace.CurrentUser.UserName)
return validateProductionMode(ctx, b, isPrincipal)
case "":
// No action

View File

@ -30,44 +30,50 @@ func (m *setRunAs) Name() string {
return "SetRunAs"
}
func reportRunAsNotSupported(resourceType string, location dyn.Location, currentUser string, runAsUser string) diag.Diagnostics {
return diag.Diagnostics{{
Summary: fmt.Sprintf("%s do not support a setting a run_as user that is different from the owner.\n"+
"Current identity: %s. Run as identity: %s.\n"+
"See https://docs.databricks.com/dev-tools/bundles/run-as.html to learn more about the run_as property.", resourceType, currentUser, runAsUser),
Locations: []dyn.Location{location},
Severity: diag.Error,
}}
type errUnsupportedResourceTypeForRunAs struct {
resourceType string
resourceLocation dyn.Location
currentUser string
runAsUser string
}
func validateRunAs(b *bundle.Bundle) diag.Diagnostics {
diags := diag.Diagnostics{}
func (e errUnsupportedResourceTypeForRunAs) Error() string {
return fmt.Sprintf("%s are not supported when the current deployment user is different from the bundle's run_as identity. Please deploy as the run_as identity. Please refer to the documentation at https://docs.databricks.com/dev-tools/bundles/run-as.html for more details. Location of the unsupported resource: %s. Current identity: %s. Run as identity: %s", e.resourceType, e.resourceLocation, e.currentUser, e.runAsUser)
}
neitherSpecifiedErr := diag.Diagnostics{{
Summary: "run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified",
Locations: []dyn.Location{b.Config.GetLocation("run_as")},
Severity: diag.Error,
}}
type errBothSpAndUserSpecified struct {
spName string
spLoc dyn.Location
userName string
userLoc dyn.Location
}
// Fail fast if neither service_principal_name nor user_name are specified, but the
func (e errBothSpAndUserSpecified) Error() string {
return fmt.Sprintf("run_as section must specify exactly one identity. A service_principal_name %q is specified at %s. A user_name %q is defined at %s", e.spName, e.spLoc, e.userName, e.userLoc)
}
func validateRunAs(b *bundle.Bundle) error {
neitherSpecifiedErr := fmt.Errorf("run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified at %s", b.Config.GetLocation("run_as"))
// Error if neither service_principal_name nor user_name are specified, but the
// run_as section is present.
if b.Config.Value().Get("run_as").Kind() == dyn.KindNil {
return neitherSpecifiedErr
}
// Fail fast if one or both of service_principal_name and user_name are specified,
// Error if one or both of service_principal_name and user_name are specified,
// but with empty values.
runAs := b.Config.RunAs
if runAs.ServicePrincipalName == "" && runAs.UserName == "" {
if b.Config.RunAs.ServicePrincipalName == "" && b.Config.RunAs.UserName == "" {
return neitherSpecifiedErr
}
// Error if both service_principal_name and user_name are specified
runAs := b.Config.RunAs
if runAs.UserName != "" && runAs.ServicePrincipalName != "" {
diags = diags.Extend(diag.Diagnostics{{
Summary: "run_as section cannot specify both user_name and service_principal_name",
Locations: []dyn.Location{b.Config.GetLocation("run_as")},
Severity: diag.Error,
}})
return errBothSpAndUserSpecified{
spName: runAs.ServicePrincipalName,
userName: runAs.UserName,
spLoc: b.Config.GetLocation("run_as.service_principal_name"),
userLoc: b.Config.GetLocation("run_as.user_name"),
}
}
identity := runAs.ServicePrincipalName
@ -77,40 +83,40 @@ func validateRunAs(b *bundle.Bundle) diag.Diagnostics {
// All resources are supported if the run_as identity is the same as the current deployment identity.
if identity == b.Config.Workspace.CurrentUser.UserName {
return diags
return nil
}
// DLT pipelines do not support run_as in the API.
if len(b.Config.Resources.Pipelines) > 0 {
diags = diags.Extend(reportRunAsNotSupported(
"pipelines",
b.Config.GetLocation("resources.pipelines"),
b.Config.Workspace.CurrentUser.UserName,
identity,
))
return errUnsupportedResourceTypeForRunAs{
resourceType: "pipelines",
resourceLocation: b.Config.GetLocation("resources.pipelines"),
currentUser: b.Config.Workspace.CurrentUser.UserName,
runAsUser: identity,
}
}
// Model serving endpoints do not support run_as in the API.
if len(b.Config.Resources.ModelServingEndpoints) > 0 {
diags = diags.Extend(reportRunAsNotSupported(
"model_serving_endpoints",
b.Config.GetLocation("resources.model_serving_endpoints"),
b.Config.Workspace.CurrentUser.UserName,
identity,
))
return errUnsupportedResourceTypeForRunAs{
resourceType: "model_serving_endpoints",
resourceLocation: b.Config.GetLocation("resources.model_serving_endpoints"),
currentUser: b.Config.Workspace.CurrentUser.UserName,
runAsUser: identity,
}
}
// Monitors do not support run_as in the API.
if len(b.Config.Resources.QualityMonitors) > 0 {
diags = diags.Extend(reportRunAsNotSupported(
"quality_monitors",
b.Config.GetLocation("resources.quality_monitors"),
b.Config.Workspace.CurrentUser.UserName,
identity,
))
return errUnsupportedResourceTypeForRunAs{
resourceType: "quality_monitors",
resourceLocation: b.Config.GetLocation("resources.quality_monitors"),
currentUser: b.Config.Workspace.CurrentUser.UserName,
runAsUser: identity,
}
}
return diags
return nil
}
func setRunAsForJobs(b *bundle.Bundle) {
@ -181,9 +187,8 @@ func (m *setRunAs) Apply(_ context.Context, b *bundle.Bundle) diag.Diagnostics {
}
// Assert the run_as configuration is valid in the context of the bundle
diags := validateRunAs(b)
if diags.HasError() {
return diags
if err := validateRunAs(b); err != nil {
return diag.FromErr(err)
}
setRunAsForJobs(b)

View File

@ -188,8 +188,11 @@ func TestRunAsErrorForUnsupportedResources(t *testing.T) {
Config: *r,
}
diags := bundle.Apply(context.Background(), b, SetRunAs())
assert.Contains(t, diags.Error().Error(), "do not support a setting a run_as user that is different from the owner.\n"+
"Current identity: alice. Run as identity: bob.\n"+
"See https://docs.databricks.com/dev-tools/bundles/run-as.html to learn more about the run_as property.", rt)
assert.Equal(t, diags.Error().Error(), errUnsupportedResourceTypeForRunAs{
resourceType: rt,
resourceLocation: dyn.Location{},
currentUser: "alice",
runAsUser: "bob",
}.Error(), "expected run_as with a different identity than the current deployment user to not supported for resources of type: %s", rt)
}
}

View File

@ -2,12 +2,9 @@ package files
import (
"context"
"errors"
"fmt"
"io/fs"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/permissions"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/log"
@ -38,9 +35,6 @@ func (m *upload) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
b.Files, err = sync.RunOnce(ctx)
if err != nil {
if errors.Is(err, fs.ErrPermission) {
return permissions.ReportPossiblePermissionDenied(ctx, b, b.Config.Workspace.FilePath)
}
return diag.FromErr(err)
}

View File

@ -3,10 +3,8 @@ package lock
import (
"context"
"errors"
"io/fs"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/permissions"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/filer"
"github.com/databricks/cli/libs/locker"
@ -53,17 +51,12 @@ func (m *acquire) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics
if err != nil {
log.Errorf(ctx, "Failed to acquire deployment lock: %v", err)
if errors.Is(err, fs.ErrPermission) {
return permissions.ReportPossiblePermissionDenied(ctx, b, b.Config.Workspace.StatePath)
}
notExistsError := filer.NoSuchDirectoryError{}
if errors.As(err, &notExistsError) {
// If we get a "doesn't exist" error from the API this indicates
// we either don't have permissions or the path is invalid.
return permissions.ReportPossiblePermissionDenied(ctx, b, b.Config.Workspace.StatePath)
return diag.Errorf("cannot write to deployment root (this can indicate a previous deploy was done with a different identity): %s", b.Config.Workspace.RootPath)
}
return diag.FromErr(err)
}

View File

@ -4,7 +4,6 @@ import (
"context"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/permissions"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/log"
"github.com/hashicorp/terraform-exec/tfexec"
@ -35,10 +34,6 @@ func (w *apply) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
// Apply terraform according to the computed plan
err := tf.Apply(ctx, tfexec.DirOrPlan(b.Plan.Path))
if err != nil {
diags := permissions.TryExtendTerraformPermissionError(ctx, b, err)
if diags != nil {
return diags
}
return diag.Errorf("terraform apply: %v", err)
}

View File

@ -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
}

View File

@ -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",

View File

@ -8,10 +8,8 @@ import (
"reflect"
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/bundle/config/resources"
"github.com/databricks/cli/bundle/config/variable"
"github.com/databricks/cli/libs/jsonschema"
"github.com/databricks/databricks-sdk-go/service/jobs"
)
func interpolationPattern(s string) string {
@ -68,31 +66,6 @@ func addInterpolationPatterns(typ reflect.Type, s jsonschema.Schema) jsonschema.
}
}
func removeJobsFields(typ reflect.Type, s jsonschema.Schema) jsonschema.Schema {
switch typ {
case reflect.TypeOf(resources.Job{}):
// This field has been deprecated in jobs API v2.1 and is always set to
// "MULTI_TASK" in the backend. We should not expose it to the user.
delete(s.Properties, "format")
// These fields are only meant to be set by the DABs client (ie the CLI)
// and thus should not be exposed to the user. These are used to annotate
// jobs that were created by DABs.
delete(s.Properties, "deployment")
delete(s.Properties, "edit_mode")
case reflect.TypeOf(jobs.GitSource{}):
// These fields are readonly and are not meant to be set by the user.
delete(s.Properties, "job_source")
delete(s.Properties, "git_snapshot")
default:
// Do nothing
}
return s
}
func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: go run main.go <output-file>")
@ -117,7 +90,6 @@ func main() {
s, err := jsonschema.FromType(reflect.TypeOf(config.Root{}), []func(reflect.Type, jsonschema.Schema) jsonschema.Schema{
p.addDescriptions,
p.addEnums,
removeJobsFields,
addInterpolationPatterns,
})
if err != nil {

View File

@ -1,4 +0,0 @@
resources:
jobs:
foo:
format: SINGLE_TASK

View File

@ -1,6 +0,0 @@
resources:
jobs:
foo:
deployment:
kind: BUNDLE
metadata_file_path: /a/b/c

View File

@ -1,6 +0,0 @@
targets:
foo:
resources:
jobs:
bar:
edit_mode: whatever

View File

@ -1,8 +0,0 @@
resources:
jobs:
foo:
git_source:
git_provider: GITHUB
git_url: www.whatever.com
git_snapshot:
used_commit: abcdef

View File

@ -1,9 +0,0 @@
resources:
jobs:
foo:
git_source:
git_provider: GITHUB
git_url: www.whatever.com
job_source:
import_from_git_branch: master
job_config_path: def

View File

@ -32,6 +32,7 @@ resources:
name: myjob
continuous:
pause_status: PAUSED
edit_mode: EDITABLE
max_concurrent_runs: 10
description: "my job description"
email_notifications:
@ -42,12 +43,10 @@ resources:
dependencies:
- python=3.7
client: "myclient"
format: MULTI_TASK
tags:
foo: bar
bar: baz
git_source:
git_provider: gitHub
git_url: www.github.com/a/b
tasks:
- task_key: mytask
notebook_task:

View File

@ -1,3 +1,3 @@
package schema
const ProviderVersion = "1.53.0"
const ProviderVersion = "1.52.0"

View File

@ -10,7 +10,6 @@ type DataSourceCurrentMetastoreMetastoreInfo struct {
DeltaSharingOrganizationName string `json:"delta_sharing_organization_name,omitempty"`
DeltaSharingRecipientTokenLifetimeInSeconds int `json:"delta_sharing_recipient_token_lifetime_in_seconds,omitempty"`
DeltaSharingScope string `json:"delta_sharing_scope,omitempty"`
ExternalAccessEnabled bool `json:"external_access_enabled,omitempty"`
GlobalMetastoreId string `json:"global_metastore_id,omitempty"`
MetastoreId string `json:"metastore_id,omitempty"`
Name string `json:"name,omitempty"`

View File

@ -10,7 +10,6 @@ type DataSourceMetastoreMetastoreInfo struct {
DeltaSharingOrganizationName string `json:"delta_sharing_organization_name,omitempty"`
DeltaSharingRecipientTokenLifetimeInSeconds int `json:"delta_sharing_recipient_token_lifetime_in_seconds,omitempty"`
DeltaSharingScope string `json:"delta_sharing_scope,omitempty"`
ExternalAccessEnabled bool `json:"external_access_enabled,omitempty"`
GlobalMetastoreId string `json:"global_metastore_id,omitempty"`
MetastoreId string `json:"metastore_id,omitempty"`
Name string `json:"name,omitempty"`

View File

@ -1,8 +0,0 @@
// Generated from Databricks Terraform provider schema. DO NOT EDIT.
package schema
type DataSourceMlflowModels struct {
Id string `json:"id,omitempty"`
Names []string `json:"names,omitempty"`
}

View File

@ -30,7 +30,6 @@ type DataSources struct {
Metastores map[string]any `json:"databricks_metastores,omitempty"`
MlflowExperiment map[string]any `json:"databricks_mlflow_experiment,omitempty"`
MlflowModel map[string]any `json:"databricks_mlflow_model,omitempty"`
MlflowModels map[string]any `json:"databricks_mlflow_models,omitempty"`
MwsCredentials map[string]any `json:"databricks_mws_credentials,omitempty"`
MwsWorkspaces map[string]any `json:"databricks_mws_workspaces,omitempty"`
NodeType map[string]any `json:"databricks_node_type,omitempty"`
@ -86,7 +85,6 @@ func NewDataSources() *DataSources {
Metastores: make(map[string]any),
MlflowExperiment: make(map[string]any),
MlflowModel: make(map[string]any),
MlflowModels: make(map[string]any),
MwsCredentials: make(map[string]any),
MwsWorkspaces: make(map[string]any),
NodeType: make(map[string]any),

View File

@ -1,49 +0,0 @@
// Generated from Databricks Terraform provider schema. DO NOT EDIT.
package schema
type ResourceBudgetAlertConfigurationsActionConfigurations struct {
ActionConfigurationId string `json:"action_configuration_id,omitempty"`
ActionType string `json:"action_type,omitempty"`
Target string `json:"target,omitempty"`
}
type ResourceBudgetAlertConfigurations struct {
AlertConfigurationId string `json:"alert_configuration_id,omitempty"`
QuantityThreshold string `json:"quantity_threshold,omitempty"`
QuantityType string `json:"quantity_type,omitempty"`
TimePeriod string `json:"time_period,omitempty"`
TriggerType string `json:"trigger_type,omitempty"`
ActionConfigurations []ResourceBudgetAlertConfigurationsActionConfigurations `json:"action_configurations,omitempty"`
}
type ResourceBudgetFilterTagsValue struct {
Operator string `json:"operator,omitempty"`
Values []string `json:"values,omitempty"`
}
type ResourceBudgetFilterTags struct {
Key string `json:"key,omitempty"`
Value *ResourceBudgetFilterTagsValue `json:"value,omitempty"`
}
type ResourceBudgetFilterWorkspaceId struct {
Operator string `json:"operator,omitempty"`
Values []int `json:"values,omitempty"`
}
type ResourceBudgetFilter struct {
Tags []ResourceBudgetFilterTags `json:"tags,omitempty"`
WorkspaceId *ResourceBudgetFilterWorkspaceId `json:"workspace_id,omitempty"`
}
type ResourceBudget struct {
AccountId string `json:"account_id,omitempty"`
BudgetConfigurationId string `json:"budget_configuration_id,omitempty"`
CreateTime int `json:"create_time,omitempty"`
DisplayName string `json:"display_name,omitempty"`
Id string `json:"id,omitempty"`
UpdateTime int `json:"update_time,omitempty"`
AlertConfigurations []ResourceBudgetAlertConfigurations `json:"alert_configurations,omitempty"`
Filter *ResourceBudgetFilter `json:"filter,omitempty"`
}

View File

@ -2,57 +2,6 @@
package schema
type ResourceModelServingAiGatewayGuardrailsInputPii struct {
Behavior string `json:"behavior"`
}
type ResourceModelServingAiGatewayGuardrailsInput struct {
InvalidKeywords []string `json:"invalid_keywords,omitempty"`
Safety bool `json:"safety,omitempty"`
ValidTopics []string `json:"valid_topics,omitempty"`
Pii *ResourceModelServingAiGatewayGuardrailsInputPii `json:"pii,omitempty"`
}
type ResourceModelServingAiGatewayGuardrailsOutputPii struct {
Behavior string `json:"behavior"`
}
type ResourceModelServingAiGatewayGuardrailsOutput struct {
InvalidKeywords []string `json:"invalid_keywords,omitempty"`
Safety bool `json:"safety,omitempty"`
ValidTopics []string `json:"valid_topics,omitempty"`
Pii *ResourceModelServingAiGatewayGuardrailsOutputPii `json:"pii,omitempty"`
}
type ResourceModelServingAiGatewayGuardrails struct {
Input *ResourceModelServingAiGatewayGuardrailsInput `json:"input,omitempty"`
Output *ResourceModelServingAiGatewayGuardrailsOutput `json:"output,omitempty"`
}
type ResourceModelServingAiGatewayInferenceTableConfig struct {
CatalogName string `json:"catalog_name,omitempty"`
Enabled bool `json:"enabled,omitempty"`
SchemaName string `json:"schema_name,omitempty"`
TableNamePrefix string `json:"table_name_prefix,omitempty"`
}
type ResourceModelServingAiGatewayRateLimits struct {
Calls int `json:"calls"`
Key string `json:"key,omitempty"`
RenewalPeriod string `json:"renewal_period"`
}
type ResourceModelServingAiGatewayUsageTrackingConfig struct {
Enabled bool `json:"enabled,omitempty"`
}
type ResourceModelServingAiGateway struct {
Guardrails *ResourceModelServingAiGatewayGuardrails `json:"guardrails,omitempty"`
InferenceTableConfig *ResourceModelServingAiGatewayInferenceTableConfig `json:"inference_table_config,omitempty"`
RateLimits []ResourceModelServingAiGatewayRateLimits `json:"rate_limits,omitempty"`
UsageTrackingConfig *ResourceModelServingAiGatewayUsageTrackingConfig `json:"usage_tracking_config,omitempty"`
}
type ResourceModelServingConfigAutoCaptureConfig struct {
CatalogName string `json:"catalog_name,omitempty"`
Enabled bool `json:"enabled,omitempty"`
@ -190,7 +139,6 @@ type ResourceModelServing struct {
Name string `json:"name"`
RouteOptimized bool `json:"route_optimized,omitempty"`
ServingEndpointId string `json:"serving_endpoint_id,omitempty"`
AiGateway *ResourceModelServingAiGateway `json:"ai_gateway,omitempty"`
Config *ResourceModelServingConfig `json:"config,omitempty"`
RateLimits []ResourceModelServingRateLimits `json:"rate_limits,omitempty"`
Tags []ResourceModelServingTags `json:"tags,omitempty"`

View File

@ -4,7 +4,7 @@ package schema
type ResourcePermissionsAccessControl struct {
GroupName string `json:"group_name,omitempty"`
PermissionLevel string `json:"permission_level,omitempty"`
PermissionLevel string `json:"permission_level"`
ServicePrincipalName string `json:"service_principal_name,omitempty"`
UserName string `json:"user_name,omitempty"`
}

View File

@ -238,7 +238,6 @@ type ResourcePipelineTrigger struct {
type ResourcePipeline struct {
AllowDuplicateNames bool `json:"allow_duplicate_names,omitempty"`
BudgetPolicyId string `json:"budget_policy_id,omitempty"`
Catalog string `json:"catalog,omitempty"`
Cause string `json:"cause,omitempty"`
Channel string `json:"channel,omitempty"`
@ -255,7 +254,6 @@ type ResourcePipeline struct {
Name string `json:"name,omitempty"`
Photon bool `json:"photon,omitempty"`
RunAsUserName string `json:"run_as_user_name,omitempty"`
Schema string `json:"schema,omitempty"`
Serverless bool `json:"serverless,omitempty"`
State string `json:"state,omitempty"`
Storage string `json:"storage,omitempty"`

View File

@ -4,11 +4,9 @@ package schema
type ResourceSqlTableColumn struct {
Comment string `json:"comment,omitempty"`
Identity string `json:"identity,omitempty"`
Name string `json:"name"`
Nullable bool `json:"nullable,omitempty"`
Type string `json:"type,omitempty"`
TypeJson string `json:"type_json,omitempty"`
}
type ResourceSqlTable struct {

View File

@ -10,7 +10,6 @@ type Resources struct {
AzureAdlsGen1Mount map[string]any `json:"databricks_azure_adls_gen1_mount,omitempty"`
AzureAdlsGen2Mount map[string]any `json:"databricks_azure_adls_gen2_mount,omitempty"`
AzureBlobMount map[string]any `json:"databricks_azure_blob_mount,omitempty"`
Budget map[string]any `json:"databricks_budget,omitempty"`
Catalog map[string]any `json:"databricks_catalog,omitempty"`
CatalogWorkspaceBinding map[string]any `json:"databricks_catalog_workspace_binding,omitempty"`
Cluster map[string]any `json:"databricks_cluster,omitempty"`
@ -113,7 +112,6 @@ func NewResources() *Resources {
AzureAdlsGen1Mount: make(map[string]any),
AzureAdlsGen2Mount: make(map[string]any),
AzureBlobMount: make(map[string]any),
Budget: make(map[string]any),
Catalog: make(map[string]any),
CatalogWorkspaceBinding: make(map[string]any),
Cluster: make(map[string]any),

View File

@ -21,7 +21,7 @@ type Root struct {
const ProviderHost = "registry.terraform.io"
const ProviderSource = "databricks/databricks"
const ProviderVersion = "1.53.0"
const ProviderVersion = "1.52.0"
func NewRoot() *Root {
return &Root{

View File

@ -1,110 +0,0 @@
package permissions
import (
"context"
"fmt"
"sort"
"strings"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/dyn"
"github.com/databricks/cli/libs/set"
)
type permissionDiagnostics struct{}
func PermissionDiagnostics() bundle.Mutator {
return &permissionDiagnostics{}
}
func (m *permissionDiagnostics) Name() string {
return "CheckPermissions"
}
func (m *permissionDiagnostics) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
if len(b.Config.Permissions) == 0 {
// Only warn if there is an explicit top-level permissions section
return nil
}
canManageBundle, _ := analyzeBundlePermissions(b)
if canManageBundle {
return nil
}
return diag.Diagnostics{{
Severity: diag.Warning,
Summary: fmt.Sprintf("permissions section should include %s or one of their groups with CAN_MANAGE permissions", b.Config.Workspace.CurrentUser.UserName),
Locations: []dyn.Location{b.Config.GetLocation("permissions")},
ID: diag.PermissionNotIncluded,
}}
}
// analyzeBundlePermissions analyzes the top-level permissions of the bundle.
// This permission set is important since it determines the permissions of the
// target workspace folder.
//
// Returns:
// - isManager: true if the current user is can manage the bundle resources.
// - assistance: advice on who to contact as to manage this project
func analyzeBundlePermissions(b *bundle.Bundle) (bool, string) {
canManageBundle := false
otherManagers := set.NewSet[string]()
if b.Config.RunAs != nil && b.Config.RunAs.UserName != "" && b.Config.RunAs.UserName != b.Config.Workspace.CurrentUser.UserName {
// The run_as user is another human that could be contacted
// about this bundle.
otherManagers.Add(b.Config.RunAs.UserName)
}
currentUser := b.Config.Workspace.CurrentUser.UserName
targetPermissions := b.Config.Permissions
for _, p := range targetPermissions {
if p.Level != CAN_MANAGE {
continue
}
if p.UserName == currentUser || p.ServicePrincipalName == currentUser {
canManageBundle = true
continue
}
if isGroupOfCurrentUser(b, p.GroupName) {
canManageBundle = true
continue
}
// Permission doesn't apply to current user; add to otherManagers
otherManager := p.UserName
if otherManager == "" {
otherManager = p.GroupName
}
if otherManager == "" {
// Skip service principals
continue
}
otherManagers.Add(otherManager)
}
assistance := "For assistance, contact the owners of this project."
if otherManagers.Size() > 0 {
list := otherManagers.Values()
sort.Strings(list)
assistance = fmt.Sprintf(
"For assistance, users or groups with appropriate permissions may include: %s.",
strings.Join(list, ", "),
)
}
return canManageBundle, assistance
}
func isGroupOfCurrentUser(b *bundle.Bundle, groupName string) bool {
currentUserGroups := b.Config.Workspace.CurrentUser.User.Groups
for _, g := range currentUserGroups {
if g.Display == groupName {
return true
}
}
return false
}

View File

@ -1,52 +0,0 @@
package permissions_test
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/bundle/permissions"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/databricks-sdk-go/service/iam"
"github.com/stretchr/testify/require"
)
func TestPermissionDiagnosticsApplySuccess(t *testing.T) {
b := mockBundle([]resources.Permission{
{Level: "CAN_MANAGE", UserName: "testuser@databricks.com"},
})
diags := permissions.PermissionDiagnostics().Apply(context.Background(), b)
require.NoError(t, diags.Error())
}
func TestPermissionDiagnosticsApplyFail(t *testing.T) {
b := mockBundle([]resources.Permission{
{Level: "CAN_VIEW", UserName: "testuser@databricks.com"},
})
diags := permissions.PermissionDiagnostics().Apply(context.Background(), b)
require.Equal(t, diags[0].Severity, diag.Warning)
require.Contains(t, diags[0].Summary, "permissions section should include testuser@databricks.com or one of their groups with CAN_MANAGE permissions")
}
func mockBundle(permissions []resources.Permission) *bundle.Bundle {
return &bundle.Bundle{
Config: config.Root{
Workspace: config.Workspace{
CurrentUser: &config.User{
User: &iam.User{
UserName: "testuser@databricks.com",
DisplayName: "Test User",
Groups: []iam.ComplexValue{
{Display: "testgroup"},
},
},
},
},
Permissions: permissions,
},
}
}

View File

@ -1,52 +0,0 @@
package permissions
import (
"context"
"fmt"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/iamutil"
"github.com/databricks/cli/libs/log"
)
// ReportPossiblePermissionDenied generates a diagnostic message when a permission denied error is encountered.
//
// Note that since the workspace API doesn't always distinguish between permission denied and path errors,
// we must treat this as a "possible permission error". See acquire.go for more about this.
func ReportPossiblePermissionDenied(ctx context.Context, b *bundle.Bundle, path string) diag.Diagnostics {
log.Errorf(ctx, "Failed to update, encountered possible permission error: %v", path)
me := b.Config.Workspace.CurrentUser.User
userName := me.UserName
if iamutil.IsServicePrincipal(me) {
userName = me.DisplayName
}
canManageBundle, assistance := analyzeBundlePermissions(b)
if !canManageBundle {
return diag.Diagnostics{{
Summary: fmt.Sprintf("unable to deploy to %s as %s.\n"+
"Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n"+
"%s\n"+
"They may need to redeploy the bundle to apply the new permissions.\n"+
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.",
path, userName, assistance),
Severity: diag.Error,
ID: diag.PathPermissionDenied,
}}
}
// According databricks.yml, the current user has the right permissions.
// But we're still seeing permission errors. So someone else will need
// to redeploy the bundle with the right set of permissions.
return diag.Diagnostics{{
Summary: fmt.Sprintf("unable to deploy to %s as %s. Cannot apply local deployment permissions.\n"+
"%s\n"+
"They can redeploy the project to apply the latest set of permissions.\n"+
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.",
path, userName, assistance),
Severity: diag.Error,
ID: diag.CannotChangePathPermissions,
}}
}

View File

@ -1,76 +0,0 @@
package permissions_test
import (
"context"
"testing"
"github.com/databricks/cli/bundle/config/resources"
"github.com/databricks/cli/bundle/permissions"
"github.com/stretchr/testify/require"
)
func TestPermissionsReportPermissionDeniedWithGroup(t *testing.T) {
b := mockBundle([]resources.Permission{
{Level: "CAN_MANAGE", GroupName: "testgroup"},
})
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
expected := "EPERM3: unable to deploy to testpath as testuser@databricks.com. Cannot apply local deployment permissions.\n" +
"For assistance, contact the owners of this project.\n" +
"They can redeploy the project to apply the latest set of permissions.\n" +
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions."
require.ErrorContains(t, diags.Error(), expected)
}
func TestPermissionsReportPermissionDeniedWithOtherGroup(t *testing.T) {
b := mockBundle([]resources.Permission{
{Level: "CAN_MANAGE", GroupName: "othergroup"},
})
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" +
"Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" +
"For assistance, users or groups with appropriate permissions may include: othergroup.\n" +
"They may need to redeploy the bundle to apply the new permissions.\n" +
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions."
require.ErrorContains(t, diags.Error(), expected)
}
func TestPermissionsReportPermissionDeniedWithoutPermission(t *testing.T) {
b := mockBundle([]resources.Permission{
{Level: "CAN_VIEW", UserName: "testuser@databricks.com"},
})
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" +
"Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" +
"For assistance, contact the owners of this project.\n" +
"They may need to redeploy the bundle to apply the new permissions.\n" +
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions."
require.ErrorContains(t, diags.Error(), expected)
}
func TestPermissionsReportPermissionDeniedNilPermission(t *testing.T) {
b := mockBundle(nil)
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" +
"Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" +
"For assistance, contact the owners of this project.\n" +
"They may need to redeploy the bundle to apply the new permissions.\n" +
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions"
require.ErrorContains(t, diags.Error(), expected)
}
func TestPermissionsReportFindOtherOwners(t *testing.T) {
b := mockBundle([]resources.Permission{
{Level: "CAN_MANAGE", GroupName: "testgroup"},
{Level: "CAN_MANAGE", UserName: "alice@databricks.com"},
})
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
require.ErrorContains(t, diags.Error(), "EPERM3: unable to deploy to testpath as testuser@databricks.com. Cannot apply local deployment permissions.\n"+
"For assistance, users or groups with appropriate permissions may include: alice@databricks.com.\n"+
"They can redeploy the project to apply the latest set of permissions.\n"+
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.")
}

View File

@ -1,47 +0,0 @@
package permissions
import (
"context"
"fmt"
"regexp"
"strings"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/log"
)
func TryExtendTerraformPermissionError(ctx context.Context, b *bundle.Bundle, err error) diag.Diagnostics {
_, assistance := analyzeBundlePermissions(b)
// In a best-effort attempt to provide actionable error messages, we match
// against a few specific error messages that come from the Jobs and Pipelines API.
// For matching errors we provide a more specific error message that includes
// details on how to resolve the issue.
if !strings.Contains(err.Error(), "cannot update permissions") &&
!strings.Contains(err.Error(), "permissions on pipeline") &&
!strings.Contains(err.Error(), "cannot read permissions") &&
!strings.Contains(err.Error(), "cannot set run_as to user") {
return nil
}
log.Errorf(ctx, "Terraform error during deployment: %v", err.Error())
// Best-effort attempt to extract the resource name from the error message.
re := regexp.MustCompile(`databricks_(\w*)\.(\w*)`)
match := re.FindStringSubmatch(err.Error())
resource := "resource"
if len(match) > 1 {
resource = match[2]
}
return diag.Diagnostics{{
Summary: fmt.Sprintf("permission denied creating or updating %s.\n"+
"%s\n"+
"They can redeploy the project to apply the latest set of permissions.\n"+
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.",
resource, assistance),
Severity: diag.Error,
ID: diag.ResourcePermissionDenied,
}}
}

View File

@ -1,97 +0,0 @@
package permissions_test
import (
"context"
"errors"
"testing"
"github.com/databricks/cli/bundle/config/resources"
"github.com/databricks/cli/bundle/permissions"
"github.com/databricks/databricks-sdk-go/service/jobs"
"github.com/stretchr/testify/require"
)
func TestTryExtendTerraformPermissionError1(t *testing.T) {
ctx := context.Background()
b := mockBundle([]resources.Permission{
{Level: "CAN_MANAGE", UserName: "alice@databricks.com"},
})
err := permissions.TryExtendTerraformPermissionError(ctx, b, errors.New("Error: terraform apply: exit status 1\n"+
"\n"+
"Error: cannot update permissions: ...\n"+
"\n"+
" with databricks_pipeline.my_project_pipeline,\n"+
" on bundle.tf.json line 39, in resource.databricks_pipeline.my_project_pipeline:\n"+
" 39: }")).Error()
expected := "EPERM2: permission denied creating or updating my_project_pipeline.\n" +
"For assistance, users or groups with appropriate permissions may include: alice@databricks.com.\n" +
"They can redeploy the project to apply the latest set of permissions.\n" +
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions"
require.ErrorContains(t, err, expected)
}
func TestTryExtendTerraformPermissionError2(t *testing.T) {
ctx := context.Background()
b := mockBundle([]resources.Permission{
{Level: "CAN_MANAGE", UserName: "alice@databricks.com"},
{Level: "CAN_MANAGE", UserName: "bob@databricks.com"},
})
err := permissions.TryExtendTerraformPermissionError(ctx, b, errors.New("Error: terraform apply: exit status 1\n"+
"\n"+
"Error: cannot read pipeline: User xyz does not have View permissions on pipeline 4521dbb6-42aa-418c-b94d-b5f4859a3454.\n"+
"\n"+
" with databricks_pipeline.my_project_pipeline,\n"+
" on bundle.tf.json line 39, in resource.databricks_pipeline.my_project_pipeline:\n"+
" 39: }")).Error()
expected := "EPERM2: permission denied creating or updating my_project_pipeline.\n" +
"For assistance, users or groups with appropriate permissions may include: alice@databricks.com, bob@databricks.com.\n" +
"They can redeploy the project to apply the latest set of permissions.\n" +
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions."
require.ErrorContains(t, err, expected)
}
func TestTryExtendTerraformPermissionError3(t *testing.T) {
ctx := context.Background()
b := mockBundle([]resources.Permission{
{Level: "CAN_MANAGE", UserName: "testuser@databricks.com"},
})
err := permissions.TryExtendTerraformPermissionError(ctx, b, errors.New("Error: terraform apply: exit status 1\n"+
"\n"+
"Error: cannot read permissions: 1706906c-c0a2-4c25-9f57-3a7aa3cb8b90 does not have Owner permissions on Job with ID: ElasticJobId(28263044278868). Please contact the owner or an administrator for access.\n"+
"\n"+
" with databricks_pipeline.my_project_pipeline,\n"+
" on bundle.tf.json line 39, in resource.databricks_pipeline.my_project_pipeline:\n"+
" 39: }")).Error()
expected := "EPERM2: permission denied creating or updating my_project_pipeline.\n" +
"For assistance, contact the owners of this project.\n" +
"They can redeploy the project to apply the latest set of permissions.\n" +
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions."
require.ErrorContains(t, err, expected)
}
func TestTryExtendTerraformPermissionErrorNotOwner(t *testing.T) {
ctx := context.Background()
b := mockBundle([]resources.Permission{
{Level: "CAN_MANAGE", GroupName: "data_team@databricks.com"},
})
b.Config.RunAs = &jobs.JobRunAs{
UserName: "testuser@databricks.com",
}
err := permissions.TryExtendTerraformPermissionError(ctx, b, errors.New("Error: terraform apply: exit status 1\n"+
"\n"+
"Error: cannot read pipeline: User xyz does not have View permissions on pipeline 4521dbb6-42aa-418c-b94d-b5f4859a3454.\n"+
"\n"+
" with databricks_pipeline.my_project_pipeline,\n"+
" on bundle.tf.json line 39, in resource.databricks_pipeline.my_project_pipeline:\n"+
" 39: }")).Error()
expected := "EPERM2: permission denied creating or updating my_project_pipeline.\n" +
"For assistance, users or groups with appropriate permissions may include: data_team@databricks.com.\n" +
"They can redeploy the project to apply the latest set of permissions.\n" +
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions."
require.ErrorContains(t, err, expected)
}

View File

@ -62,8 +62,6 @@ func Initialize() bundle.Mutator {
"workspace",
"variables",
),
// Provide permission config errors & warnings after initializing all variables
permissions.PermissionDiagnostics(),
mutator.SetRunAs(),
mutator.OverrideCompute(),
mutator.ProcessTargetMode(),

View File

@ -8,7 +8,6 @@ import (
"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"
@ -29,6 +28,48 @@ var renderFuncMap = template.FuncMap{
},
}
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 }}
@ -112,7 +153,22 @@ func renderSummaryTemplate(out io.Writer, b *bundle.Bundle, diags diag.Diagnosti
}
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
@ -127,9 +183,15 @@ func renderDiagnostics(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics)
}
}
}
// Render the diagnostic with the appropriate template.
err := t.Execute(out, d)
if err != nil {
return fmt.Errorf("failed to render template: %w", err)
}
}
return cmdio.RenderDiagnostics(out, diags)
return nil
}
// RenderOptions contains options for rendering diagnostics.

View File

@ -39,7 +39,7 @@ func TestJsonSchema(t *testing.T) {
// Assert job fields have their descriptions loaded.
resourceJob := walk(s.Definitions, "github.com", "databricks", "cli", "bundle", "config", "resources.Job")
fields := []string{"name", "continuous", "tasks", "trigger"}
fields := []string{"name", "continuous", "deployment", "tasks", "trigger"}
for _, field := range fields {
assert.NotEmpty(t, resourceJob.AnyOf[0].Properties[field].Description)
}
@ -53,7 +53,7 @@ func TestJsonSchema(t *testing.T) {
// Assert descriptions are loaded for pipelines
pipeline := walk(s.Definitions, "github.com", "databricks", "cli", "bundle", "config", "resources.Pipeline")
fields = []string{"name", "catalog", "clusters", "channel", "continuous", "development"}
fields = []string{"name", "catalog", "clusters", "channel", "continuous", "deployment", "development"}
for _, field := range fields {
assert.NotEmpty(t, pipeline.AnyOf[0].Properties[field].Description)
}

View File

@ -213,10 +213,18 @@
"description": "An optional continuous property for this job. The continuous property will ensure that there is always one run executing. Only one of `schedule` and `continuous` can be used.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.Continuous"
},
"deployment": {
"description": "Deployment information for jobs managed by external sources.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.JobDeployment"
},
"description": {
"description": "An optional description for the job. The maximum length is 27700 characters in UTF-8 encoding.",
"$ref": "#/$defs/string"
},
"edit_mode": {
"description": "Edit mode of the job.\n\n* `UI_LOCKED`: The job is in a locked UI state and cannot be modified.\n* `EDITABLE`: The job is in an editable state and can be modified.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.JobEditMode"
},
"email_notifications": {
"description": "An optional set of email addresses that is notified when runs of this job begin or complete as well as when this job is deleted.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.JobEmailNotifications"
@ -225,6 +233,10 @@
"description": "A list of task execution environment specifications that can be referenced by serverless tasks of this job.\nAn environment is required to be present for serverless tasks.\nFor serverless notebook tasks, the environment is accessible in the notebook environment panel.\nFor other serverless tasks, the task environment is required to be specified using environment_key in the task settings.",
"$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/jobs.JobEnvironment"
},
"format": {
"description": "Used to tell what is the format of the job. This field is ignored in Create/Update/Reset calls. When using the Jobs API 2.1 this value is always set to `\"MULTI_TASK\"`.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.Format"
},
"git_source": {
"description": "An optional specification for a remote Git repository containing the source code used by tasks. Version-controlled source code is supported by notebook, dbt, Python script, and SQL File tasks.\n\nIf `git_source` is set, these tasks retrieve the file from the remote repository by default. However, this behavior can be overridden by setting `source` to `WORKSPACE` on the task.\n\nNote: dbt and SQL File tasks support only version-controlled sources. If dbt or SQL File tasks are used, `git_source` must be defined on the job.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.GitSource"
@ -390,10 +402,6 @@
{
"type": "object",
"properties": {
"ai_gateway": {
"description": "The AI Gateway configuration for the serving endpoint. NOTE: only external model endpoints are supported as of now.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayConfig"
},
"config": {
"description": "The core config of the serving endpoint.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.EndpointCoreConfigInput"
@ -464,10 +472,6 @@
{
"type": "object",
"properties": {
"budget_policy_id": {
"description": "Budget policy of this pipeline.",
"$ref": "#/$defs/string"
},
"catalog": {
"description": "A catalog in Unity Catalog to publish data from this pipeline to. If `target` is specified, tables in this pipeline are published to a `target` schema inside `catalog` (for example, `catalog`.`target`.`table`). If `target` is not specified, no data is published to Unity Catalog.",
"$ref": "#/$defs/string"
@ -535,10 +539,6 @@
"description": "Whether Photon is enabled for this pipeline.",
"$ref": "#/$defs/bool"
},
"schema": {
"description": "The default schema (database) where tables are read from or published to. The presence of this field implies that the pipeline is in direct publishing mode.",
"$ref": "#/$defs/string"
},
"serverless": {
"description": "Whether serverless compute is enabled for this pipeline.",
"$ref": "#/$defs/bool"
@ -1206,9 +1206,6 @@
"profile": {
"$ref": "#/$defs/string"
},
"resource_path": {
"$ref": "#/$defs/string"
},
"root_path": {
"$ref": "#/$defs/string"
},
@ -2535,6 +2532,9 @@
"description": "Unique identifier of the service used to host the Git repository. The value is case insensitive.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.GitProvider"
},
"git_snapshot": {
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.GitSnapshot"
},
"git_tag": {
"description": "Name of the tag to be checked out and used by this job. This field cannot be specified in conjunction with git_branch or git_commit.",
"$ref": "#/$defs/string"
@ -2542,6 +2542,10 @@
"git_url": {
"description": "URL of the repository to be cloned by this job.",
"$ref": "#/$defs/string"
},
"job_source": {
"description": "The source of the job specification in the remote repository when the job is source controlled.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.JobSource"
}
},
"additionalProperties": false,
@ -2628,7 +2632,7 @@
"type": "object",
"properties": {
"no_alert_for_skipped_runs": {
"description": "If true, do not send email to recipients specified in `on_failure` if the run is skipped.\nThis field is `deprecated`. Please use the `notification_settings.no_alert_for_skipped_runs` field.",
"description": "If true, do not send email to recipients specified in `on_failure` if the run is skipped.",
"$ref": "#/$defs/bool"
},
"on_duration_warning_threshold_exceeded": {
@ -3069,7 +3073,6 @@
"$ref": "#/$defs/map/string"
},
"pipeline_params": {
"description": "Controls whether the pipeline should perform a full refresh",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/jobs.PipelineParams"
},
"python_named_params": {
@ -3544,7 +3547,7 @@
"type": "object",
"properties": {
"no_alert_for_skipped_runs": {
"description": "If true, do not send email to recipients specified in `on_failure` if the run is skipped.\nThis field is `deprecated`. Please use the `notification_settings.no_alert_for_skipped_runs` field.",
"description": "If true, do not send email to recipients specified in `on_failure` if the run is skipped.",
"$ref": "#/$defs/bool"
},
"on_duration_warning_threshold_exceeded": {
@ -4362,207 +4365,6 @@
}
]
},
"serving.AiGatewayConfig": {
"anyOf": [
{
"type": "object",
"properties": {
"guardrails": {
"description": "Configuration for AI Guardrails to prevent unwanted data and unsafe data in requests and responses.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayGuardrails"
},
"inference_table_config": {
"description": "Configuration for payload logging using inference tables. Use these tables to monitor and audit data being sent to and received from model APIs and to improve model quality.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayInferenceTableConfig"
},
"rate_limits": {
"description": "Configuration for rate limits which can be set to limit endpoint traffic.",
"$ref": "#/$defs/slice/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayRateLimit"
},
"usage_tracking_config": {
"description": "Configuration to enable usage tracking using system tables. These tables allow you to monitor operational usage on endpoints and their associated costs.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayUsageTrackingConfig"
}
},
"additionalProperties": false
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
}
]
},
"serving.AiGatewayGuardrailParameters": {
"anyOf": [
{
"type": "object",
"properties": {
"invalid_keywords": {
"description": "List of invalid keywords. AI guardrail uses keyword or string matching to decide if the keyword exists in the request or response content.",
"$ref": "#/$defs/slice/string"
},
"pii": {
"description": "Configuration for guardrail PII filter.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayGuardrailPiiBehavior"
},
"safety": {
"description": "Indicates whether the safety filter is enabled.",
"$ref": "#/$defs/bool"
},
"valid_topics": {
"description": "The list of allowed topics. Given a chat request, this guardrail flags the request if its topic is not in the allowed topics.",
"$ref": "#/$defs/slice/string"
}
},
"additionalProperties": false
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
}
]
},
"serving.AiGatewayGuardrailPiiBehavior": {
"anyOf": [
{
"type": "object",
"properties": {
"behavior": {
"description": "Behavior for PII filter. Currently only 'BLOCK' is supported. If 'BLOCK' is set for the input guardrail and the request contains PII, the request is not sent to the model server and 400 status code is returned; if 'BLOCK' is set for the output guardrail and the model response contains PII, the PII info in the response is redacted and 400 status code is returned.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayGuardrailPiiBehaviorBehavior",
"enum": [
"NONE",
"BLOCK"
]
}
},
"additionalProperties": false,
"required": [
"behavior"
]
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
}
]
},
"serving.AiGatewayGuardrailPiiBehaviorBehavior": {
"type": "string"
},
"serving.AiGatewayGuardrails": {
"anyOf": [
{
"type": "object",
"properties": {
"input": {
"description": "Configuration for input guardrail filters.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayGuardrailParameters"
},
"output": {
"description": "Configuration for output guardrail filters.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayGuardrailParameters"
}
},
"additionalProperties": false
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
}
]
},
"serving.AiGatewayInferenceTableConfig": {
"anyOf": [
{
"type": "object",
"properties": {
"catalog_name": {
"description": "The name of the catalog in Unity Catalog. Required when enabling inference tables. NOTE: On update, you have to disable inference table first in order to change the catalog name.",
"$ref": "#/$defs/string"
},
"enabled": {
"description": "Indicates whether the inference table is enabled.",
"$ref": "#/$defs/bool"
},
"schema_name": {
"description": "The name of the schema in Unity Catalog. Required when enabling inference tables. NOTE: On update, you have to disable inference table first in order to change the schema name.",
"$ref": "#/$defs/string"
},
"table_name_prefix": {
"description": "The prefix of the table in Unity Catalog. NOTE: On update, you have to disable inference table first in order to change the prefix name.",
"$ref": "#/$defs/string"
}
},
"additionalProperties": false
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
}
]
},
"serving.AiGatewayRateLimit": {
"anyOf": [
{
"type": "object",
"properties": {
"calls": {
"description": "Used to specify how many calls are allowed for a key within the renewal_period.",
"$ref": "#/$defs/int"
},
"key": {
"description": "Key field for a rate limit. Currently, only 'user' and 'endpoint' are supported, with 'endpoint' being the default if not specified.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayRateLimitKey",
"enum": [
"user",
"endpoint"
]
},
"renewal_period": {
"description": "Renewal period field for a rate limit. Currently, only 'minute' is supported.",
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayRateLimitRenewalPeriod",
"enum": [
"minute"
]
}
},
"additionalProperties": false,
"required": [
"calls",
"renewal_period"
]
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
}
]
},
"serving.AiGatewayRateLimitKey": {
"type": "string"
},
"serving.AiGatewayRateLimitRenewalPeriod": {
"type": "string"
},
"serving.AiGatewayUsageTrackingConfig": {
"anyOf": [
{
"type": "object",
"properties": {
"enabled": {
"description": "Whether to enable usage tracking.",
"$ref": "#/$defs/bool"
}
},
"additionalProperties": false
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
}
]
},
"serving.AmazonBedrockConfig": {
"anyOf": [
{
@ -5767,20 +5569,6 @@
}
]
},
"serving.AiGatewayRateLimit": {
"anyOf": [
{
"type": "array",
"items": {
"$ref": "#/$defs/github.com/databricks/databricks-sdk-go/service/serving.AiGatewayRateLimit"
}
},
{
"type": "string",
"pattern": "\\$\\{(var(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)+)\\}"
}
]
},
"serving.EndpointTag": {
"anyOf": [
{

View File

@ -3,6 +3,7 @@ package config_tests
import (
"context"
"fmt"
"path/filepath"
"testing"
"github.com/databricks/cli/bundle"
@ -112,9 +113,8 @@ func TestRunAsErrorForPipelines(t *testing.T) {
diags := bundle.Apply(ctx, b, mutator.SetRunAs())
err := diags.Error()
assert.ErrorContains(t, err, "pipelines do not support a setting a run_as user that is different from the owner.\n"+
"Current identity: jane@doe.com. Run as identity: my_service_principal.\n"+
"See https://docs")
configPath := filepath.FromSlash("run_as/not_allowed/pipelines/databricks.yml")
assert.EqualError(t, err, fmt.Sprintf("pipelines are not supported when the current deployment user is different from the bundle's run_as identity. Please deploy as the run_as identity. Please refer to the documentation at https://docs.databricks.com/dev-tools/bundles/run-as.html for more details. Location of the unsupported resource: %s:14:5. Current identity: jane@doe.com. Run as identity: my_service_principal", configPath))
}
func TestRunAsNoErrorForPipelines(t *testing.T) {
@ -152,9 +152,8 @@ func TestRunAsErrorForModelServing(t *testing.T) {
diags := bundle.Apply(ctx, b, mutator.SetRunAs())
err := diags.Error()
assert.ErrorContains(t, err, "model_serving_endpoints do not support a setting a run_as user that is different from the owner.\n"+
"Current identity: jane@doe.com. Run as identity: my_service_principal.\n"+
"See https://docs")
configPath := filepath.FromSlash("run_as/not_allowed/model_serving/databricks.yml")
assert.EqualError(t, err, fmt.Sprintf("model_serving_endpoints are not supported when the current deployment user is different from the bundle's run_as identity. Please deploy as the run_as identity. Please refer to the documentation at https://docs.databricks.com/dev-tools/bundles/run-as.html for more details. Location of the unsupported resource: %s:14:5. Current identity: jane@doe.com. Run as identity: my_service_principal", configPath))
}
func TestRunAsNoErrorForModelServingEndpoints(t *testing.T) {
@ -192,7 +191,8 @@ func TestRunAsErrorWhenBothUserAndSpSpecified(t *testing.T) {
diags := bundle.Apply(ctx, b, mutator.SetRunAs())
err := diags.Error()
assert.ErrorContains(t, err, "run_as section cannot specify both user_name and service_principal_name")
configPath := filepath.FromSlash("run_as/not_allowed/both_sp_and_user/databricks.yml")
assert.EqualError(t, err, fmt.Sprintf("run_as section must specify exactly one identity. A service_principal_name \"my_service_principal\" is specified at %s:6:27. A user_name \"my_user_name\" is defined at %s:7:14", configPath, configPath))
}
func TestRunAsErrorNeitherUserOrSpSpecified(t *testing.T) {
@ -202,19 +202,19 @@ func TestRunAsErrorNeitherUserOrSpSpecified(t *testing.T) {
}{
{
name: "empty_run_as",
err: "run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified",
err: fmt.Sprintf("run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified at %s:4:8", filepath.FromSlash("run_as/not_allowed/neither_sp_nor_user/empty_run_as/databricks.yml")),
},
{
name: "empty_sp",
err: "run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified",
err: fmt.Sprintf("run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified at %s:5:3", filepath.FromSlash("run_as/not_allowed/neither_sp_nor_user/empty_sp/databricks.yml")),
},
{
name: "empty_user",
err: "run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified",
err: fmt.Sprintf("run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified at %s:5:3", filepath.FromSlash("run_as/not_allowed/neither_sp_nor_user/empty_user/databricks.yml")),
},
{
name: "empty_user_and_sp",
err: "run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified",
err: fmt.Sprintf("run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified at %s:5:3", filepath.FromSlash("run_as/not_allowed/neither_sp_nor_user/empty_user_and_sp/databricks.yml")),
},
}
@ -257,7 +257,8 @@ func TestRunAsErrorNeitherUserOrSpSpecifiedAtTargetOverride(t *testing.T) {
diags := bundle.Apply(ctx, b, mutator.SetRunAs())
err := diags.Error()
assert.EqualError(t, err, "run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified")
configPath := filepath.FromSlash("run_as/not_allowed/neither_sp_nor_user/override/override.yml")
assert.EqualError(t, err, fmt.Sprintf("run_as section must specify exactly one identity. Neither service_principal_name nor user_name is specified at %s:4:12", configPath))
}
func TestLegacyRunAs(t *testing.T) {

View File

@ -205,15 +205,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -78,15 +78,9 @@ 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)
if err != nil {
return err
}
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,15 +316,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -90,15 +90,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -129,15 +129,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -88,15 +88,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
@ -326,15 +320,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
updateReq.IntegrationId = args[0]

View File

@ -185,15 +185,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -107,15 +107,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -127,15 +127,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -97,15 +97,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
@ -364,15 +358,9 @@ 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)
if err != nil {
return err
}
err = patchJson.Unmarshal(&patchReq)
if err != nil {
return err
}
}
if len(args) == 0 {
@ -458,15 +446,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -132,15 +132,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -417,15 +411,9 @@ 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)
if err != nil {
return err
}
err = replaceJson.Unmarshal(&replaceReq)
if err != nil {
return err
}
}
replaceReq.IpAccessListId = args[0]
@ -517,15 +505,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -162,15 +162,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
@ -375,15 +369,9 @@ 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)
if err != nil {
return err
}
err = patchStatusJson.Unmarshal(&patchStatusReq)
if err != nil {
return err
}
}
patchStatusReq.LogDeliveryConfigurationId = args[0]

View File

@ -85,15 +85,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
_, err = fmt.Sscan(args[0], &createReq.WorkspaceId)
@ -349,15 +343,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)

View File

@ -80,15 +80,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
@ -310,15 +304,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
updateReq.MetastoreId = args[0]

View File

@ -96,15 +96,9 @@ 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)
if err != nil {
return err
}
err = createNetworkConnectivityConfigurationJson.Unmarshal(&createNetworkConnectivityConfigurationReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -193,15 +187,9 @@ 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)
if err != nil {
return err
}
err = createPrivateEndpointRuleJson.Unmarshal(&createPrivateEndpointRuleReq)
if err != nil {
return err
}
}
createPrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0]

View File

@ -97,15 +97,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {

View File

@ -189,15 +189,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -109,15 +109,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -417,15 +411,9 @@ 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)
if err != nil {
return err
}
err = replaceJson.Unmarshal(&replaceReq)
if err != nil {
return err
}
}
replaceReq.PrivateAccessSettingsId = args[0]

View File

@ -85,15 +85,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
@ -321,15 +315,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
updateReq.IntegrationId = args[0]

View File

@ -95,15 +95,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
@ -364,15 +358,9 @@ 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)
if err != nil {
return err
}
err = patchJson.Unmarshal(&patchReq)
if err != nil {
return err
}
}
if len(args) == 0 {
@ -460,15 +448,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -88,15 +88,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
createReq.MetastoreId = args[0]
@ -346,15 +340,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
updateReq.MetastoreId = args[0]

View File

@ -87,15 +87,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -80,15 +80,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}

View File

@ -103,15 +103,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
@ -380,15 +374,9 @@ 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)
if err != nil {
return err
}
err = patchJson.Unmarshal(&patchReq)
if err != nil {
return err
}
}
if len(args) == 0 {
@ -477,15 +465,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -104,15 +104,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {

View File

@ -273,15 +273,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)

View File

@ -133,15 +133,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -557,15 +551,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -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{}

View File

@ -93,15 +93,9 @@ 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)
if err != nil {
return err
}
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,15 +357,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -85,15 +85,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
@ -360,15 +354,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
updateReq.Id = args[0]

View File

@ -81,7 +81,6 @@ func newCreate() *cobra.Command {
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
cmd.Flags().StringVar(&createReq.Description, "description", createReq.Description, `The description of the app.`)
// TODO: array: resources
cmd.Use = "create NAME"
cmd.Short = `Create an app.`
@ -113,15 +112,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -273,15 +266,9 @@ 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)
if err != nil {
return err
}
err = deployJson.Unmarshal(&deployReq)
if err != nil {
return err
}
}
deployReq.AppName = args[0]
@ -714,15 +701,9 @@ 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)
if err != nil {
return err
}
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil {
return err
}
}
setPermissionsReq.AppName = args[0]
@ -929,7 +910,6 @@ func newUpdate() *cobra.Command {
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
cmd.Flags().StringVar(&updateReq.Description, "description", updateReq.Description, `The description of the app.`)
// TODO: array: resources
cmd.Use = "update NAME"
cmd.Short = `Update an app.`
@ -954,15 +934,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
updateReq.Name = args[0]
@ -1029,15 +1003,9 @@ 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)
if err != nil {
return err
}
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil {
return err
}
}
updatePermissionsReq.AppName = args[0]

View File

@ -145,15 +145,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -127,15 +127,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -105,15 +105,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -369,15 +363,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
updateReq.Name = args[0]

View File

@ -85,15 +85,9 @@ 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)
if err != nil {
return err
}
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,15 +344,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
updateReq.Name = args[0]

View File

@ -113,15 +113,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
@ -191,15 +185,9 @@ 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)
if err != nil {
return err
}
err = deleteJson.Unmarshal(&deleteReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -296,15 +284,9 @@ 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)
if err != nil {
return err
}
err = editJson.Unmarshal(&editReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -648,15 +630,9 @@ 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)
if err != nil {
return err
}
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil {
return err
}
}
if len(args) == 0 {
@ -735,15 +711,9 @@ 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)
if err != nil {
return err
}
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -134,15 +134,9 @@ 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)
if err != nil {
return err
}
err = changeOwnerJson.Unmarshal(&changeOwnerReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -274,15 +268,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -374,15 +362,9 @@ 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)
if err != nil {
return err
}
err = deleteJson.Unmarshal(&deleteReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -537,15 +519,9 @@ 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)
if err != nil {
return err
}
err = editJson.Unmarshal(&editReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -641,15 +617,9 @@ 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)
if err != nil {
return err
}
err = eventsJson.Unmarshal(&eventsReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -1099,15 +1069,9 @@ 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)
if err != nil {
return err
}
err = permanentDeleteJson.Unmarshal(&permanentDeleteReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -1197,15 +1161,9 @@ 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)
if err != nil {
return err
}
err = pinJson.Unmarshal(&pinReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -1302,15 +1260,9 @@ 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)
if err != nil {
return err
}
err = resizeJson.Unmarshal(&resizeReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -1418,15 +1370,9 @@ 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)
if err != nil {
return err
}
err = restartJson.Unmarshal(&restartReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -1518,15 +1464,9 @@ 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)
if err != nil {
return err
}
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil {
return err
}
}
if len(args) == 0 {
@ -1668,15 +1608,9 @@ 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)
if err != nil {
return err
}
err = startJson.Unmarshal(&startReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -1778,15 +1712,9 @@ 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)
if err != nil {
return err
}
err = unpinJson.Unmarshal(&unpinReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -1896,15 +1824,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -1983,15 +1905,9 @@ 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)
if err != nil {
return err
}
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -130,15 +130,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -92,15 +92,9 @@ 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)
if err != nil {
return err
}
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,15 +355,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -86,15 +86,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
createReq.ListingId = args[0]
@ -325,15 +319,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -85,15 +85,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -75,15 +75,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -75,15 +75,9 @@ 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)
if err != nil {
return err
}
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,15 +196,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -78,15 +78,9 @@ 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)
if err != nil {
return err
}
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,15 +405,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -199,15 +199,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -187,15 +187,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -132,15 +132,9 @@ 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)
if err != nil {
return err
}
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")

View File

@ -130,15 +130,9 @@ 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)
if err != nil {
return err
}
err = createExperimentJson.Unmarshal(&createExperimentReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -209,15 +203,9 @@ 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)
if err != nil {
return err
}
err = createRunJson.Unmarshal(&createRunReq)
if err != nil {
return err
}
}
@ -289,15 +277,9 @@ 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)
if err != nil {
return err
}
err = deleteExperimentJson.Unmarshal(&deleteExperimentReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -370,15 +352,9 @@ 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)
if err != nil {
return err
}
err = deleteRunJson.Unmarshal(&deleteRunReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -459,15 +435,9 @@ 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)
if err != nil {
return err
}
err = deleteRunsJson.Unmarshal(&deleteRunsReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -548,15 +518,9 @@ 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)
if err != nil {
return err
}
err = deleteTagJson.Unmarshal(&deleteTagReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -1144,15 +1108,9 @@ 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)
if err != nil {
return err
}
err = logBatchJson.Unmarshal(&logBatchReq)
if err != nil {
return err
}
}
@ -1216,15 +1174,9 @@ 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)
if err != nil {
return err
}
err = logInputsJson.Unmarshal(&logInputsReq)
if err != nil {
return err
}
}
@ -1302,15 +1254,9 @@ 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)
if err != nil {
return err
}
err = logMetricJson.Unmarshal(&logMetricReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -1389,15 +1335,9 @@ 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)
if err != nil {
return err
}
err = logModelJson.Unmarshal(&logModelReq)
if err != nil {
return err
}
}
@ -1474,15 +1414,9 @@ 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)
if err != nil {
return err
}
err = logParamJson.Unmarshal(&logParamReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -1563,15 +1497,9 @@ 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)
if err != nil {
return err
}
err = restoreExperimentJson.Unmarshal(&restoreExperimentReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -1644,15 +1572,9 @@ 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)
if err != nil {
return err
}
err = restoreRunJson.Unmarshal(&restoreRunReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -1733,15 +1655,9 @@ 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)
if err != nil {
return err
}
err = restoreRunsJson.Unmarshal(&restoreRunsReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -1816,15 +1732,9 @@ 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)
if err != nil {
return err
}
err = searchExperimentsJson.Unmarshal(&searchExperimentsReq)
if err != nil {
return err
}
}
@ -1890,15 +1800,9 @@ 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)
if err != nil {
return err
}
err = searchRunsJson.Unmarshal(&searchRunsReq)
if err != nil {
return err
}
}
@ -1970,15 +1874,9 @@ 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)
if err != nil {
return err
}
err = setExperimentTagJson.Unmarshal(&setExperimentTagReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -2053,15 +1951,9 @@ 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)
if err != nil {
return err
}
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil {
return err
}
}
setPermissionsReq.ExperimentId = args[0]
@ -2140,15 +2032,9 @@ 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)
if err != nil {
return err
}
err = setTagJson.Unmarshal(&setTagReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -2226,15 +2112,9 @@ 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)
if err != nil {
return err
}
err = updateExperimentJson.Unmarshal(&updateExperimentReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -2303,15 +2183,9 @@ 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)
if err != nil {
return err
}
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil {
return err
}
}
updatePermissionsReq.ExperimentId = args[0]
@ -2377,15 +2251,9 @@ 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)
if err != nil {
return err
}
err = updateRunJson.Unmarshal(&updateRunReq)
if err != nil {
return err
}
}

View File

@ -112,15 +112,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -387,15 +381,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
updateReq.Name = args[0]

View File

@ -85,15 +85,9 @@ 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)
if err != nil {
return err
}
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,15 +381,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -105,15 +105,9 @@ 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)
if err != nil {
return err
}
err = createMessageJson.Unmarshal(&createMessageReq)
if err != nil {
return err
}
}
createMessageReq.SpaceId = args[0]
@ -398,15 +392,9 @@ 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)
if err != nil {
return err
}
err = startConversationJson.Unmarshal(&startConversationReq)
if err != nil {
return err
}
}
startConversationReq.SpaceId = args[0]

View File

@ -53,13 +53,13 @@ func New() *cobra.Command {
// Functions can be added from the `init()` function in manually curated files in this directory.
var createOverrides []func(
*cobra.Command,
*workspace.CreateCredentialsRequest,
*workspace.CreateCredentials,
)
func newCreate() *cobra.Command {
cmd := &cobra.Command{}
var createReq workspace.CreateCredentialsRequest
var createReq workspace.CreateCredentials
var createJson flags.JsonFlag
// TODO: short flags
@ -79,9 +79,8 @@ func newCreate() *cobra.Command {
Arguments:
GIT_PROVIDER: Git provider. This field is case-insensitive. The available Git providers
are gitHub, bitbucketCloud, gitLab, azureDevOpsServices,
gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and
awsCodeCommit.`
are gitHub, bitbucketCloud, gitLab, azureDevOpsServices, gitHubEnterprise,
bitbucketServer, gitLabEnterpriseEdition and awsCodeCommit.`
cmd.Annotations = make(map[string]string)
@ -103,15 +102,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -143,13 +136,13 @@ func newCreate() *cobra.Command {
// Functions can be added from the `init()` function in manually curated files in this directory.
var deleteOverrides []func(
*cobra.Command,
*workspace.DeleteCredentialsRequest,
*workspace.DeleteGitCredentialRequest,
)
func newDelete() *cobra.Command {
cmd := &cobra.Command{}
var deleteReq workspace.DeleteCredentialsRequest
var deleteReq workspace.DeleteGitCredentialRequest
// TODO: short flags
@ -216,13 +209,13 @@ func newDelete() *cobra.Command {
// Functions can be added from the `init()` function in manually curated files in this directory.
var getOverrides []func(
*cobra.Command,
*workspace.GetCredentialsRequest,
*workspace.GetGitCredentialRequest,
)
func newGet() *cobra.Command {
cmd := &cobra.Command{}
var getReq workspace.GetCredentialsRequest
var getReq workspace.GetGitCredentialRequest
// TODO: short flags
@ -329,72 +322,65 @@ func newList() *cobra.Command {
// Functions can be added from the `init()` function in manually curated files in this directory.
var updateOverrides []func(
*cobra.Command,
*workspace.UpdateCredentialsRequest,
*workspace.UpdateCredentials,
)
func newUpdate() *cobra.Command {
cmd := &cobra.Command{}
var updateReq workspace.UpdateCredentialsRequest
var updateReq workspace.UpdateCredentials
var updateJson flags.JsonFlag
// TODO: short flags
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
cmd.Flags().StringVar(&updateReq.GitProvider, "git-provider", updateReq.GitProvider, `Git provider.`)
cmd.Flags().StringVar(&updateReq.GitUsername, "git-username", updateReq.GitUsername, `The username or email provided with your Git provider account, depending on which provider you are using.`)
cmd.Flags().StringVar(&updateReq.PersonalAccessToken, "personal-access-token", updateReq.PersonalAccessToken, `The personal access token used to authenticate to the corresponding Git provider.`)
cmd.Use = "update CREDENTIAL_ID GIT_PROVIDER"
cmd.Use = "update CREDENTIAL_ID"
cmd.Short = `Update a credential.`
cmd.Long = `Update a credential.
Updates the specified Git credential.
Arguments:
CREDENTIAL_ID: The ID for the corresponding credential to access.
GIT_PROVIDER: Git provider. This field is case-insensitive. The available Git providers
are gitHub, bitbucketCloud, gitLab, azureDevOpsServices,
gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and
awsCodeCommit.`
CREDENTIAL_ID: The ID for the corresponding credential to access.`
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("json") {
err := root.ExactArgs(1)(cmd, args)
if err != nil {
return fmt.Errorf("when --json flag is specified, provide only CREDENTIAL_ID as positional arguments. Provide 'git_provider' in your JSON input")
}
return nil
}
check := root.ExactArgs(2)
return check(cmd, args)
}
cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No CREDENTIAL_ID argument specified. Loading names for Git Credentials drop-down."
names, err := w.GitCredentials.CredentialInfoGitProviderToCredentialIdMap(ctx)
close(promptSpinner)
if err != nil {
return fmt.Errorf("failed to load names for Git Credentials drop-down. Please manually specify required arguments. Original error: %w", err)
}
id, err := cmdio.Select(ctx, names, "The ID for the corresponding credential to access")
if err != nil {
return err
}
args = append(args, id)
}
if len(args) != 1 {
return fmt.Errorf("expected to have the id for the corresponding credential to access")
}
_, err = fmt.Sscan(args[0], &updateReq.CredentialId)
if err != nil {
return fmt.Errorf("invalid CREDENTIAL_ID: %s", args[0])
}
if !cmd.Flags().Changed("json") {
updateReq.GitProvider = args[1]
}
err = w.GitCredentials.Update(ctx, updateReq)
if err != nil {

View File

@ -101,15 +101,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -373,15 +367,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
updateReq.ScriptId = args[0]

View File

@ -223,15 +223,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
_, err = fmt.Sscan(args[0], &updateReq.SecurableType)

View File

@ -97,15 +97,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
@ -364,15 +358,9 @@ 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)
if err != nil {
return err
}
err = patchJson.Unmarshal(&patchReq)
if err != nil {
return err
}
}
if len(args) == 0 {
@ -458,15 +446,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -128,15 +128,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -212,15 +206,9 @@ 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)
if err != nil {
return err
}
err = deleteJson.Unmarshal(&deleteReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -321,15 +309,9 @@ 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)
if err != nil {
return err
}
err = editJson.Unmarshal(&editReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -649,15 +631,9 @@ 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)
if err != nil {
return err
}
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil {
return err
}
}
if len(args) == 0 {
@ -736,15 +712,9 @@ 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)
if err != nil {
return err
}
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -99,15 +99,9 @@ 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)
if err != nil {
return err
}
err = addJson.Unmarshal(&addReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -198,15 +192,9 @@ 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)
if err != nil {
return err
}
err = editJson.Unmarshal(&editReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -323,15 +311,9 @@ 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)
if err != nil {
return err
}
err = removeJson.Unmarshal(&removeReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {

View File

@ -133,15 +133,9 @@ 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)
if err != nil {
return err
}
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
}
}
if !cmd.Flags().Changed("json") {
@ -420,15 +414,9 @@ 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)
if err != nil {
return err
}
err = replaceJson.Unmarshal(&replaceReq)
if err != nil {
return err
}
}
replaceReq.IpAccessListId = args[0]
@ -522,15 +510,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
}
if len(args) == 0 {

View File

@ -116,15 +116,9 @@ 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)
if err != nil {
return err
}
err = cancelAllRunsJson.Unmarshal(&cancelAllRunsReq)
if err != nil {
return err
}
}
@ -199,15 +193,9 @@ 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)
if err != nil {
return err
}
err = cancelRunJson.Unmarshal(&cancelRunReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -303,15 +291,9 @@ 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)
if err != nil {
return err
}
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,15 +364,9 @@ 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)
if err != nil {
return err
}
err = deleteJson.Unmarshal(&deleteReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -481,15 +457,9 @@ 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)
if err != nil {
return err
}
err = deleteRunJson.Unmarshal(&deleteRunReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -1173,15 +1143,9 @@ 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)
if err != nil {
return err
}
err = repairRunJson.Unmarshal(&repairRunReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -1278,15 +1242,9 @@ 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)
if err != nil {
return err
}
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,15 +1332,9 @@ 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)
if err != nil {
return err
}
err = runNowJson.Unmarshal(&runNowReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -1484,15 +1436,9 @@ 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)
if err != nil {
return err
}
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil {
return err
}
}
if len(args) == 0 {
@ -1592,15 +1538,9 @@ 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)
if err != nil {
return err
}
err = submitJson.Unmarshal(&submitReq)
if err != nil {
return err
}
}
@ -1692,15 +1632,9 @@ 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)
if err != nil {
return err
}
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
}
} else {
if len(args) == 0 {
@ -1783,15 +1717,9 @@ 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)
if err != nil {
return err
}
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil {
return err
}
}
if len(args) == 0 {

Some files were not shown because too many files have changed in this diff Show More