Added JSON input validation for CLI commands (#1771)

## Changes
Added JSON input validation for CLI commands. Now when invalid JSON
passed as a payload to CLI commands, CLI performs input normalisation
and detects if there are any mismatches such as incorrect types, unknown
fields and etc.

This diagnostic information is printed in standard error output and does
not block command execution, so the change is backward compatible.

Fixes #1769 #1764 #1625 #1560


## Tests
Added unit tests

```
andrew.nester@HFW9Y94129 ~ % databricks jobs create --json '{"seeti}'
Error: error decoding JSON at (inline):1:2: unexpected EOF


andrew.nester@HFW9Y94129 ~ % databricks jobs create --json '{"seeti": true}'
Warning: unknown field: seeti
  in (inline):1:9

Error: Job settings must be specified.
```

---------

Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
This commit is contained in:
Andrew Nester 2024-10-11 16:39:53 +02:00 committed by GitHub
parent 08a0d083c3
commit f0e2981596
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
118 changed files with 3378 additions and 1042 deletions

View File

@ -5,6 +5,7 @@ package {{(.TrimPrefix "account").SnakeName}}
import ( import (
"github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/flags"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/cmd/root" "github.com/databricks/cli/cmd/root"
"github.com/databricks/databricks-sdk-go/service/{{.Package.Name}}" "github.com/databricks/databricks-sdk-go/service/{{.Package.Name}}"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -231,9 +232,15 @@ func new{{.PascalName}}() *cobra.Command {
{{- if .Request }} {{- if .Request }}
{{ if .CanUseJson }} {{ if .CanUseJson }}
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req) diags := {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
}{{end}}{{ if .MustUseJson }}else { }{{end}}{{ if .MustUseJson }}else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -8,6 +8,7 @@ import (
"text/template" "text/template"
"github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/diag"
"github.com/databricks/databricks-sdk-go/service/iam" "github.com/databricks/databricks-sdk-go/service/iam"
"github.com/fatih/color" "github.com/fatih/color"
@ -28,48 +29,6 @@ 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 -}} const summaryTemplate = `{{- if .Name -}}
Name: {{ .Name | bold }} Name: {{ .Name | bold }}
{{- if .Target }} {{- if .Target }}
@ -153,22 +112,7 @@ func renderSummaryTemplate(out io.Writer, b *bundle.Bundle, diags diag.Diagnosti
} }
func renderDiagnostics(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics) error { func renderDiagnostics(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics) error {
errorT := template.Must(template.New("error").Funcs(renderFuncMap).Parse(errorTemplate))
warningT := template.Must(template.New("warning").Funcs(renderFuncMap).Parse(warningTemplate))
recommendationT := template.Must(template.New("recommendation").Funcs(renderFuncMap).Parse(recommendationTemplate))
// Print errors and warnings.
for _, d := range diags { for _, d := range diags {
var t *template.Template
switch d.Severity {
case diag.Error:
t = errorT
case diag.Warning:
t = warningT
case diag.Recommendation:
t = recommendationT
}
for i := range d.Locations { for i := range d.Locations {
if b == nil { if b == nil {
break break
@ -183,15 +127,9 @@ func renderDiagnostics(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics)
} }
} }
} }
// Render the diagnostic with the appropriate template.
err := t.Execute(out, d)
if err != nil {
return fmt.Errorf("failed to render template: %w", err)
}
} }
return nil return cmdio.RenderDiagnostics(out, diags)
} }
// RenderOptions contains options for rendering diagnostics. // RenderOptions contains options for rendering diagnostics.

View File

@ -205,9 +205,15 @@ func newUpdateRuleSet() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateRuleSetJson.Unmarshal(&updateRuleSetReq) diags := updateRuleSetJson.Unmarshal(&updateRuleSetReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -78,9 +78,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -316,9 +322,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -90,9 +90,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -129,9 +129,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -88,9 +88,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -320,9 +326,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.IntegrationId = args[0] updateReq.IntegrationId = args[0]

View File

@ -185,9 +185,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -107,9 +107,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -127,9 +127,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -97,9 +97,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -358,9 +364,15 @@ func newPatch() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -446,9 +458,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -132,9 +132,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -411,9 +417,15 @@ func newReplace() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = replaceJson.Unmarshal(&replaceReq) diags := replaceJson.Unmarshal(&replaceReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
replaceReq.IpAccessListId = args[0] replaceReq.IpAccessListId = args[0]
@ -505,9 +517,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -162,9 +162,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -369,9 +375,15 @@ func newPatchStatus() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchStatusJson.Unmarshal(&patchStatusReq) diags := patchStatusJson.Unmarshal(&patchStatusReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
patchStatusReq.LogDeliveryConfigurationId = args[0] patchStatusReq.LogDeliveryConfigurationId = args[0]

View File

@ -85,9 +85,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
_, err = fmt.Sscan(args[0], &createReq.WorkspaceId) _, err = fmt.Sscan(args[0], &createReq.WorkspaceId)
@ -343,9 +349,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId) _, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)

View File

@ -80,9 +80,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -304,9 +310,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.MetastoreId = args[0] updateReq.MetastoreId = args[0]

View File

@ -96,9 +96,15 @@ func newCreateNetworkConnectivityConfiguration() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createNetworkConnectivityConfigurationJson.Unmarshal(&createNetworkConnectivityConfigurationReq) diags := createNetworkConnectivityConfigurationJson.Unmarshal(&createNetworkConnectivityConfigurationReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -187,9 +193,15 @@ func newCreatePrivateEndpointRule() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createPrivateEndpointRuleJson.Unmarshal(&createPrivateEndpointRuleReq) diags := createPrivateEndpointRuleJson.Unmarshal(&createPrivateEndpointRuleReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
createPrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0] createPrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0]

View File

@ -97,9 +97,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {

View File

@ -189,9 +189,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -109,9 +109,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -411,9 +417,15 @@ func newReplace() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = replaceJson.Unmarshal(&replaceReq) diags := replaceJson.Unmarshal(&replaceReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
replaceReq.PrivateAccessSettingsId = args[0] replaceReq.PrivateAccessSettingsId = args[0]

View File

@ -85,9 +85,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -315,9 +321,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.IntegrationId = args[0] updateReq.IntegrationId = args[0]

View File

@ -95,9 +95,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -358,9 +364,15 @@ func newPatch() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -448,9 +460,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -88,9 +88,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
createReq.MetastoreId = args[0] createReq.MetastoreId = args[0]
@ -340,9 +346,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.MetastoreId = args[0] updateReq.MetastoreId = args[0]

View File

@ -87,9 +87,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -80,9 +80,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }

View File

@ -103,9 +103,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -374,9 +380,15 @@ func newPatch() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -465,9 +477,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -104,9 +104,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {

View File

@ -273,9 +273,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId) _, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)

View File

@ -133,9 +133,15 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -551,9 +557,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -42,9 +42,9 @@ func makeCommand(method string) *cobra.Command {
var path = args[0] var path = args[0]
var request any var request any
err := payload.Unmarshal(&request) diags := payload.Unmarshal(&request)
if err != nil { if diags.HasError() {
return err return diags.Error()
} }
cfg := &config.Config{} cfg := &config.Config{}

View File

@ -93,9 +93,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -357,9 +363,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -85,9 +85,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -354,9 +360,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.Id = args[0] updateReq.Id = args[0]

View File

@ -113,9 +113,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -267,9 +273,15 @@ func newDeploy() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deployJson.Unmarshal(&deployReq) diags := deployJson.Unmarshal(&deployReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
deployReq.AppName = args[0] deployReq.AppName = args[0]
@ -702,9 +714,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
setPermissionsReq.AppName = args[0] setPermissionsReq.AppName = args[0]
@ -936,9 +954,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.Name = args[0] updateReq.Name = args[0]
@ -1005,9 +1029,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updatePermissionsReq.AppName = args[0] updatePermissionsReq.AppName = args[0]

View File

@ -145,9 +145,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -127,9 +127,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -105,9 +105,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -363,9 +369,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.Name = args[0] updateReq.Name = args[0]

View File

@ -85,9 +85,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -344,9 +350,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.Name = args[0] updateReq.Name = args[0]

View File

@ -113,9 +113,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -185,9 +191,15 @@ func newDelete() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteJson.Unmarshal(&deleteReq) diags := deleteJson.Unmarshal(&deleteReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -284,9 +296,15 @@ func newEdit() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = editJson.Unmarshal(&editReq) diags := editJson.Unmarshal(&editReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -630,9 +648,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -711,9 +735,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -134,9 +134,15 @@ func newChangeOwner() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = changeOwnerJson.Unmarshal(&changeOwnerReq) diags := changeOwnerJson.Unmarshal(&changeOwnerReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -268,9 +274,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -362,9 +374,15 @@ func newDelete() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteJson.Unmarshal(&deleteReq) diags := deleteJson.Unmarshal(&deleteReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -519,9 +537,15 @@ func newEdit() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = editJson.Unmarshal(&editReq) diags := editJson.Unmarshal(&editReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -617,9 +641,15 @@ func newEvents() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = eventsJson.Unmarshal(&eventsReq) diags := eventsJson.Unmarshal(&eventsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -1069,9 +1099,15 @@ func newPermanentDelete() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = permanentDeleteJson.Unmarshal(&permanentDeleteReq) diags := permanentDeleteJson.Unmarshal(&permanentDeleteReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -1161,9 +1197,15 @@ func newPin() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = pinJson.Unmarshal(&pinReq) diags := pinJson.Unmarshal(&pinReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -1260,9 +1302,15 @@ func newResize() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = resizeJson.Unmarshal(&resizeReq) diags := resizeJson.Unmarshal(&resizeReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -1370,9 +1418,15 @@ func newRestart() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = restartJson.Unmarshal(&restartReq) diags := restartJson.Unmarshal(&restartReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -1464,9 +1518,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -1608,9 +1668,15 @@ func newStart() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = startJson.Unmarshal(&startReq) diags := startJson.Unmarshal(&startReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -1712,9 +1778,15 @@ func newUnpin() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = unpinJson.Unmarshal(&unpinReq) diags := unpinJson.Unmarshal(&unpinReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -1824,9 +1896,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1905,9 +1983,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -130,9 +130,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -92,9 +92,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -355,9 +361,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -86,9 +86,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
createReq.ListingId = args[0] createReq.ListingId = args[0]
@ -319,9 +325,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -85,9 +85,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -75,9 +75,15 @@ func newExchangeToken() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = exchangeTokenJson.Unmarshal(&exchangeTokenReq) diags := exchangeTokenJson.Unmarshal(&exchangeTokenReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -75,9 +75,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -196,9 +202,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -78,9 +78,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -405,9 +411,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -199,9 +199,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -187,9 +187,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -132,9 +132,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -130,9 +130,15 @@ func newCreateExperiment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createExperimentJson.Unmarshal(&createExperimentReq) diags := createExperimentJson.Unmarshal(&createExperimentReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -203,9 +209,15 @@ func newCreateRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createRunJson.Unmarshal(&createRunReq) diags := createRunJson.Unmarshal(&createRunReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -277,9 +289,15 @@ func newDeleteExperiment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteExperimentJson.Unmarshal(&deleteExperimentReq) diags := deleteExperimentJson.Unmarshal(&deleteExperimentReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -352,9 +370,15 @@ func newDeleteRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteRunJson.Unmarshal(&deleteRunReq) diags := deleteRunJson.Unmarshal(&deleteRunReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -435,9 +459,15 @@ func newDeleteRuns() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteRunsJson.Unmarshal(&deleteRunsReq) diags := deleteRunsJson.Unmarshal(&deleteRunsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -518,9 +548,15 @@ func newDeleteTag() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteTagJson.Unmarshal(&deleteTagReq) diags := deleteTagJson.Unmarshal(&deleteTagReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1108,9 +1144,15 @@ func newLogBatch() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = logBatchJson.Unmarshal(&logBatchReq) diags := logBatchJson.Unmarshal(&logBatchReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -1174,9 +1216,15 @@ func newLogInputs() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = logInputsJson.Unmarshal(&logInputsReq) diags := logInputsJson.Unmarshal(&logInputsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -1254,9 +1302,15 @@ func newLogMetric() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = logMetricJson.Unmarshal(&logMetricReq) diags := logMetricJson.Unmarshal(&logMetricReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1335,9 +1389,15 @@ func newLogModel() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = logModelJson.Unmarshal(&logModelReq) diags := logModelJson.Unmarshal(&logModelReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -1414,9 +1474,15 @@ func newLogParam() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = logParamJson.Unmarshal(&logParamReq) diags := logParamJson.Unmarshal(&logParamReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1497,9 +1563,15 @@ func newRestoreExperiment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = restoreExperimentJson.Unmarshal(&restoreExperimentReq) diags := restoreExperimentJson.Unmarshal(&restoreExperimentReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1572,9 +1644,15 @@ func newRestoreRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = restoreRunJson.Unmarshal(&restoreRunReq) diags := restoreRunJson.Unmarshal(&restoreRunReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1655,9 +1733,15 @@ func newRestoreRuns() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = restoreRunsJson.Unmarshal(&restoreRunsReq) diags := restoreRunsJson.Unmarshal(&restoreRunsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1732,9 +1816,15 @@ func newSearchExperiments() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = searchExperimentsJson.Unmarshal(&searchExperimentsReq) diags := searchExperimentsJson.Unmarshal(&searchExperimentsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -1800,9 +1890,15 @@ func newSearchRuns() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = searchRunsJson.Unmarshal(&searchRunsReq) diags := searchRunsJson.Unmarshal(&searchRunsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -1874,9 +1970,15 @@ func newSetExperimentTag() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setExperimentTagJson.Unmarshal(&setExperimentTagReq) diags := setExperimentTagJson.Unmarshal(&setExperimentTagReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1951,9 +2053,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
setPermissionsReq.ExperimentId = args[0] setPermissionsReq.ExperimentId = args[0]
@ -2032,9 +2140,15 @@ func newSetTag() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setTagJson.Unmarshal(&setTagReq) diags := setTagJson.Unmarshal(&setTagReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -2112,9 +2226,15 @@ func newUpdateExperiment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateExperimentJson.Unmarshal(&updateExperimentReq) diags := updateExperimentJson.Unmarshal(&updateExperimentReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -2183,9 +2303,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updatePermissionsReq.ExperimentId = args[0] updatePermissionsReq.ExperimentId = args[0]
@ -2251,9 +2377,15 @@ func newUpdateRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateRunJson.Unmarshal(&updateRunReq) diags := updateRunJson.Unmarshal(&updateRunReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }

View File

@ -112,9 +112,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -381,9 +387,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.Name = args[0] updateReq.Name = args[0]

View File

@ -85,9 +85,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -381,9 +387,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -105,9 +105,15 @@ func newCreateMessage() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createMessageJson.Unmarshal(&createMessageReq) diags := createMessageJson.Unmarshal(&createMessageReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
createMessageReq.SpaceId = args[0] createMessageReq.SpaceId = args[0]
@ -392,9 +398,15 @@ func newStartConversation() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = startConversationJson.Unmarshal(&startConversationReq) diags := startConversationJson.Unmarshal(&startConversationReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
startConversationReq.SpaceId = args[0] startConversationReq.SpaceId = args[0]

View File

@ -103,9 +103,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -371,9 +377,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
_, err = fmt.Sscan(args[0], &updateReq.CredentialId) _, err = fmt.Sscan(args[0], &updateReq.CredentialId)

View File

@ -101,9 +101,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -367,9 +373,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.ScriptId = args[0] updateReq.ScriptId = args[0]

View File

@ -223,9 +223,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
_, err = fmt.Sscan(args[0], &updateReq.SecurableType) _, err = fmt.Sscan(args[0], &updateReq.SecurableType)

View File

@ -97,9 +97,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -358,9 +364,15 @@ func newPatch() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -446,9 +458,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -128,9 +128,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -206,9 +212,15 @@ func newDelete() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteJson.Unmarshal(&deleteReq) diags := deleteJson.Unmarshal(&deleteReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -309,9 +321,15 @@ func newEdit() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = editJson.Unmarshal(&editReq) diags := editJson.Unmarshal(&editReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -631,9 +649,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -712,9 +736,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -99,9 +99,15 @@ func newAdd() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = addJson.Unmarshal(&addReq) diags := addJson.Unmarshal(&addReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -192,9 +198,15 @@ func newEdit() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = editJson.Unmarshal(&editReq) diags := editJson.Unmarshal(&editReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -311,9 +323,15 @@ func newRemove() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = removeJson.Unmarshal(&removeReq) diags := removeJson.Unmarshal(&removeReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {

View File

@ -133,9 +133,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -414,9 +420,15 @@ func newReplace() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = replaceJson.Unmarshal(&replaceReq) diags := replaceJson.Unmarshal(&replaceReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
replaceReq.IpAccessListId = args[0] replaceReq.IpAccessListId = args[0]
@ -510,9 +522,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -116,9 +116,15 @@ func newCancelAllRuns() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = cancelAllRunsJson.Unmarshal(&cancelAllRunsReq) diags := cancelAllRunsJson.Unmarshal(&cancelAllRunsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -193,9 +199,15 @@ func newCancelRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = cancelRunJson.Unmarshal(&cancelRunReq) diags := cancelRunJson.Unmarshal(&cancelRunReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -291,9 +303,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -364,9 +382,15 @@ func newDelete() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteJson.Unmarshal(&deleteReq) diags := deleteJson.Unmarshal(&deleteReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -457,9 +481,15 @@ func newDeleteRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteRunJson.Unmarshal(&deleteRunReq) diags := deleteRunJson.Unmarshal(&deleteRunReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -1143,9 +1173,15 @@ func newRepairRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = repairRunJson.Unmarshal(&repairRunReq) diags := repairRunJson.Unmarshal(&repairRunReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -1242,9 +1278,15 @@ func newReset() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = resetJson.Unmarshal(&resetReq) diags := resetJson.Unmarshal(&resetReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -1332,9 +1374,15 @@ func newRunNow() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = runNowJson.Unmarshal(&runNowReq) diags := runNowJson.Unmarshal(&runNowReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -1436,9 +1484,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -1538,9 +1592,15 @@ func newSubmit() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = submitJson.Unmarshal(&submitReq) diags := submitJson.Unmarshal(&submitReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -1632,9 +1692,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
if len(args) == 0 { if len(args) == 0 {
@ -1717,9 +1783,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -108,9 +108,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -180,9 +186,15 @@ func newCreateSchedule() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createScheduleJson.Unmarshal(&createScheduleReq) diags := createScheduleJson.Unmarshal(&createScheduleReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -250,9 +262,15 @@ func newCreateSubscription() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createSubscriptionJson.Unmarshal(&createSubscriptionReq) diags := createSubscriptionJson.Unmarshal(&createSubscriptionReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -870,9 +888,15 @@ func newMigrate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = migrateJson.Unmarshal(&migrateReq) diags := migrateJson.Unmarshal(&migrateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -941,9 +965,15 @@ func newPublish() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = publishJson.Unmarshal(&publishReq) diags := publishJson.Unmarshal(&publishReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
publishReq.DashboardId = args[0] publishReq.DashboardId = args[0]
@ -1128,9 +1158,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.DashboardId = args[0] updateReq.DashboardId = args[0]
@ -1200,9 +1236,15 @@ func newUpdateSchedule() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateScheduleJson.Unmarshal(&updateScheduleReq) diags := updateScheduleJson.Unmarshal(&updateScheduleReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -190,9 +190,15 @@ func newInstall() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = installJson.Unmarshal(&installReq) diags := installJson.Unmarshal(&installReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -251,9 +257,15 @@ func newUninstall() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = uninstallJson.Unmarshal(&uninstallReq) diags := uninstallJson.Unmarshal(&uninstallReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -112,9 +112,15 @@ func newAssign() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = assignJson.Unmarshal(&assignReq) diags := assignJson.Unmarshal(&assignReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
_, err = fmt.Sscan(args[0], &assignReq.WorkspaceId) _, err = fmt.Sscan(args[0], &assignReq.WorkspaceId)
@ -201,9 +207,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -606,9 +618,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -690,9 +708,15 @@ func newUpdateAssignment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateAssignmentJson.Unmarshal(&updateAssignmentReq) diags := updateAssignmentJson.Unmarshal(&updateAssignmentReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -141,9 +141,15 @@ func newApproveTransitionRequest() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = approveTransitionRequestJson.Unmarshal(&approveTransitionRequestReq) diags := approveTransitionRequestJson.Unmarshal(&approveTransitionRequestReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -235,9 +241,15 @@ func newCreateComment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createCommentJson.Unmarshal(&createCommentReq) diags := createCommentJson.Unmarshal(&createCommentReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -322,9 +334,15 @@ func newCreateModel() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createModelJson.Unmarshal(&createModelReq) diags := createModelJson.Unmarshal(&createModelReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -403,9 +421,15 @@ func newCreateModelVersion() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createModelVersionJson.Unmarshal(&createModelVersionReq) diags := createModelVersionJson.Unmarshal(&createModelVersionReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -493,9 +517,15 @@ func newCreateTransitionRequest() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createTransitionRequestJson.Unmarshal(&createTransitionRequestReq) diags := createTransitionRequestJson.Unmarshal(&createTransitionRequestReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -570,9 +600,15 @@ func newCreateWebhook() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createWebhookJson.Unmarshal(&createWebhookReq) diags := createWebhookJson.Unmarshal(&createWebhookReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -1079,9 +1115,15 @@ func newGetLatestVersions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = getLatestVersionsJson.Unmarshal(&getLatestVersionsReq) diags := getLatestVersionsJson.Unmarshal(&getLatestVersionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1629,9 +1671,15 @@ func newRejectTransitionRequest() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = rejectTransitionRequestJson.Unmarshal(&rejectTransitionRequestReq) diags := rejectTransitionRequestJson.Unmarshal(&rejectTransitionRequestReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1715,9 +1763,15 @@ func newRenameModel() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = renameModelJson.Unmarshal(&renameModelReq) diags := renameModelJson.Unmarshal(&renameModelReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1907,9 +1961,15 @@ func newSetModelTag() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setModelTagJson.Unmarshal(&setModelTagReq) diags := setModelTagJson.Unmarshal(&setModelTagReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -1996,9 +2056,15 @@ func newSetModelVersionTag() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setModelVersionTagJson.Unmarshal(&setModelVersionTagReq) diags := setModelVersionTagJson.Unmarshal(&setModelVersionTagReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -2076,9 +2142,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
setPermissionsReq.RegisteredModelId = args[0] setPermissionsReq.RegisteredModelId = args[0]
@ -2166,9 +2238,15 @@ func newTestRegistryWebhook() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = testRegistryWebhookJson.Unmarshal(&testRegistryWebhookReq) diags := testRegistryWebhookJson.Unmarshal(&testRegistryWebhookReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -2259,9 +2337,15 @@ func newTransitionStage() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = transitionStageJson.Unmarshal(&transitionStageReq) diags := transitionStageJson.Unmarshal(&transitionStageReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -2350,9 +2434,15 @@ func newUpdateComment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateCommentJson.Unmarshal(&updateCommentReq) diags := updateCommentJson.Unmarshal(&updateCommentReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -2430,9 +2520,15 @@ func newUpdateModel() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateModelJson.Unmarshal(&updateModelReq) diags := updateModelJson.Unmarshal(&updateModelReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -2508,9 +2604,15 @@ func newUpdateModelVersion() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateModelVersionJson.Unmarshal(&updateModelVersionReq) diags := updateModelVersionJson.Unmarshal(&updateModelVersionReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -2582,9 +2684,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updatePermissionsReq.RegisteredModelId = args[0] updatePermissionsReq.RegisteredModelId = args[0]
@ -2663,9 +2771,15 @@ func newUpdateWebhook() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateWebhookJson.Unmarshal(&updateWebhookReq) diags := updateWebhookJson.Unmarshal(&updateWebhookReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {

View File

@ -377,9 +377,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.FullName = args[0] updateReq.FullName = args[0]

View File

@ -84,9 +84,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -313,9 +319,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.Id = args[0] updateReq.Id = args[0]

View File

@ -79,9 +79,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }

View File

@ -92,9 +92,15 @@ func newMigratePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = migratePermissionsJson.Unmarshal(&migratePermissionsReq) diags := migratePermissionsJson.Unmarshal(&migratePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {

View File

@ -265,9 +265,15 @@ func newSet() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setJson.Unmarshal(&setReq) diags := setJson.Unmarshal(&setReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
setReq.RequestObjectType = args[0] setReq.RequestObjectType = args[0]
@ -340,9 +346,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.RequestObjectType = args[0] updateReq.RequestObjectType = args[0]

View File

@ -98,9 +98,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -699,9 +705,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -788,9 +800,15 @@ func newStartUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = startUpdateJson.Unmarshal(&startUpdateReq) diags := startUpdateJson.Unmarshal(&startUpdateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -977,9 +995,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -1058,9 +1082,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -110,9 +110,15 @@ func newEnforceCompliance() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = enforceComplianceJson.Unmarshal(&enforceComplianceReq) diags := enforceComplianceJson.Unmarshal(&enforceComplianceReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {

View File

@ -104,9 +104,15 @@ func newEnforceCompliance() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = enforceComplianceJson.Unmarshal(&enforceComplianceReq) diags := enforceComplianceJson.Unmarshal(&enforceComplianceReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {

View File

@ -73,9 +73,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -259,9 +265,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -91,9 +91,15 @@ func newAddListingToExchange() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = addListingToExchangeJson.Unmarshal(&addListingToExchangeReq) diags := addListingToExchangeJson.Unmarshal(&addListingToExchangeReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -154,9 +160,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -546,9 +558,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -77,9 +77,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -273,9 +279,15 @@ func newList() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = listJson.Unmarshal(&listReq) diags := listJson.Unmarshal(&listReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -75,9 +75,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -326,9 +332,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -142,9 +142,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.ListingId = args[0] updateReq.ListingId = args[0]

View File

@ -208,9 +208,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.Id = args[0] updateReq.Id = args[0]

View File

@ -74,9 +74,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -325,9 +331,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -97,9 +97,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -446,9 +452,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -196,9 +196,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
createReq.TableName = args[0] createReq.TableName = args[0]
@ -559,9 +565,15 @@ func newRegenerateDashboard() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = regenerateDashboardJson.Unmarshal(&regenerateDashboardReq) diags := regenerateDashboardJson.Unmarshal(&regenerateDashboardReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
regenerateDashboardReq.TableName = args[0] regenerateDashboardReq.TableName = args[0]
@ -724,9 +736,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.TableName = args[0] updateReq.TableName = args[0]

View File

@ -96,9 +96,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -454,9 +460,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -85,9 +85,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -425,9 +431,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.Id = args[0] updateReq.Id = args[0]

View File

@ -87,9 +87,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -222,9 +228,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -84,9 +84,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -217,9 +223,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.Id = args[0] updateReq.Id = args[0]

View File

@ -118,9 +118,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -404,9 +410,15 @@ func newRotateToken() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = rotateTokenJson.Unmarshal(&rotateTokenReq) diags := rotateTokenJson.Unmarshal(&rotateTokenReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
rotateTokenReq.Name = args[0] rotateTokenReq.Name = args[0]
@ -554,9 +566,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -135,9 +135,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -509,9 +515,15 @@ func newSetAlias() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setAliasJson.Unmarshal(&setAliasReq) diags := setAliasJson.Unmarshal(&setAliasReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
setAliasReq.FullName = args[0] setAliasReq.FullName = args[0]
@ -589,9 +601,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -7,6 +7,7 @@ import (
"github.com/databricks/cli/cmd/root" "github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/flags"
"github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/service/workspace" "github.com/databricks/databricks-sdk-go/service/workspace"
@ -35,9 +36,15 @@ func createOverride(createCmd *cobra.Command, createReq *workspace.CreateRepoReq
ctx := cmd.Context() ctx := cmd.Context()
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(createReq) diags := createJson.Unmarshal(createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
createReq.Url = args[0] createReq.Url = args[0]
@ -101,11 +108,18 @@ func updateOverride(updateCmd *cobra.Command, updateReq *workspace.UpdateRepoReq
updateJson := updateCmd.Flag("json").Value.(*flags.JsonFlag) updateJson := updateCmd.Flag("json").Value.(*flags.JsonFlag)
updateCmd.RunE = func(cmd *cobra.Command, args []string) (err error) { updateCmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context() ctx := cmd.Context()
var diags diag.Diagnostics
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags = updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
updateReq.RepoId, err = repoArgumentToRepoID(ctx, w, args) updateReq.RepoId, err = repoArgumentToRepoID(ctx, w, args)

View File

@ -111,9 +111,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -521,9 +527,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -604,9 +616,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -688,9 +706,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -197,9 +197,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -100,9 +100,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -386,9 +392,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -8,6 +8,7 @@ import (
"github.com/databricks/cli/cmd/root" "github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/flags"
"github.com/databricks/databricks-sdk-go/service/workspace" "github.com/databricks/databricks-sdk-go/service/workspace"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -60,6 +61,7 @@ func newPutSecret() *cobra.Command {
cmd.PreRunE = root.MustWorkspaceClient cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context() ctx := cmd.Context()
var diags diag.Diagnostics
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
bytesValueChanged := cmd.Flags().Changed("bytes-value") bytesValueChanged := cmd.Flags().Changed("bytes-value")
@ -69,9 +71,15 @@ func newPutSecret() *cobra.Command {
} }
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = putSecretJson.Unmarshal(&putSecretReq) diags = putSecretJson.Unmarshal(&putSecretReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
putSecretReq.Scope = args[0] putSecretReq.Scope = args[0]

View File

@ -110,9 +110,15 @@ func newCreateScope() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createScopeJson.Unmarshal(&createScopeReq) diags := createScopeJson.Unmarshal(&createScopeReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -191,9 +197,15 @@ func newDeleteAcl() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteAclJson.Unmarshal(&deleteAclReq) diags := deleteAclJson.Unmarshal(&deleteAclReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -273,9 +285,15 @@ func newDeleteScope() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteScopeJson.Unmarshal(&deleteScopeReq) diags := deleteScopeJson.Unmarshal(&deleteScopeReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -354,9 +372,15 @@ func newDeleteSecret() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteSecretJson.Unmarshal(&deleteSecretReq) diags := deleteSecretJson.Unmarshal(&deleteSecretReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -759,9 +783,15 @@ func newPutAcl() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = putAclJson.Unmarshal(&putAclReq) diags := putAclJson.Unmarshal(&putAclReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {

View File

@ -95,9 +95,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
@ -358,9 +364,15 @@ func newPatch() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -448,9 +460,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -169,9 +169,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
@ -706,9 +712,15 @@ func newPatch() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
patchReq.Name = args[0] patchReq.Name = args[0]
@ -777,9 +789,15 @@ func newPut() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = putJson.Unmarshal(&putReq) diags := putJson.Unmarshal(&putReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
putReq.Name = args[0] putReq.Name = args[0]
@ -850,9 +868,15 @@ func newPutAiGateway() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = putAiGatewayJson.Unmarshal(&putAiGatewayReq) diags := putAiGatewayJson.Unmarshal(&putAiGatewayReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
putAiGatewayReq.Name = args[0] putAiGatewayReq.Name = args[0]
@ -928,9 +952,15 @@ func newQuery() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = queryJson.Unmarshal(&queryReq) diags := queryJson.Unmarshal(&queryReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
queryReq.Name = args[0] queryReq.Name = args[0]
@ -997,9 +1027,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
setPermissionsReq.ServingEndpointId = args[0] setPermissionsReq.ServingEndpointId = args[0]
@ -1076,9 +1112,15 @@ func newUpdateConfig() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateConfigJson.Unmarshal(&updateConfigReq) diags := updateConfigJson.Unmarshal(&updateConfigReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateConfigReq.Name = args[0] updateConfigReq.Name = args[0]
@ -1158,9 +1200,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updatePermissionsReq.ServingEndpointId = args[0] updatePermissionsReq.ServingEndpointId = args[0]

View File

@ -100,9 +100,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -427,9 +433,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updateReq.Name = args[0] updateReq.Name = args[0]
@ -501,9 +513,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
updatePermissionsReq.Name = args[0] updatePermissionsReq.Name = args[0]

View File

@ -111,9 +111,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -377,9 +383,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {
@ -478,9 +490,15 @@ func newValidate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = validateJson.Unmarshal(&validateReq) diags := validateJson.Unmarshal(&validateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }

View File

@ -92,9 +92,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} else { } else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")

View File

@ -479,9 +479,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }
if len(args) == 0 { if len(args) == 0 {

View File

@ -94,9 +94,15 @@ func newGenerateTemporaryTableCredentials() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = generateTemporaryTableCredentialsJson.Unmarshal(&generateTemporaryTableCredentialsReq) diags := generateTemporaryTableCredentialsJson.Unmarshal(&generateTemporaryTableCredentialsReq)
if err != nil { if diags.HasError() {
return err return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
} }
} }

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