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

View File

@ -8,6 +8,7 @@ import (
"text/template"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/databricks-sdk-go/service/iam"
"github.com/fatih/color"
@ -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 -}}
Name: {{ .Name | bold }}
{{- 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 {
errorT := template.Must(template.New("error").Funcs(renderFuncMap).Parse(errorTemplate))
warningT := template.Must(template.New("warning").Funcs(renderFuncMap).Parse(warningTemplate))
recommendationT := template.Must(template.New("recommendation").Funcs(renderFuncMap).Parse(recommendationTemplate))
// Print errors and warnings.
for _, d := range diags {
var t *template.Template
switch d.Severity {
case diag.Error:
t = errorT
case diag.Warning:
t = warningT
case diag.Recommendation:
t = recommendationT
}
for i := range d.Locations {
if b == nil {
break
@ -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.

View File

@ -205,9 +205,15 @@ func newUpdateRuleSet() *cobra.Command {
a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") {
err = updateRuleSetJson.Unmarshal(&updateRuleSetReq)
if err != nil {
return err
diags := updateRuleSetJson.Unmarshal(&updateRuleSetReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
updateReq.IntegrationId = args[0]

View File

@ -185,9 +185,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
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)
if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq)
if err != nil {
return err
diags := patchJson.Unmarshal(&patchReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {
@ -446,9 +458,15 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -130,9 +130,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
createReq.ListingId = args[0]
@ -319,9 +325,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = exchangeTokenJson.Unmarshal(&exchangeTokenReq)
if err != nil {
return err
diags := exchangeTokenJson.Unmarshal(&exchangeTokenReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {

View File

@ -199,9 +199,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createExperimentJson.Unmarshal(&createExperimentReq)
if err != nil {
return err
diags := createExperimentJson.Unmarshal(&createExperimentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -203,9 +209,15 @@ func newCreateRun() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = createRunJson.Unmarshal(&createRunReq)
if err != nil {
return err
diags := createRunJson.Unmarshal(&createRunReq)
if diags.HasError() {
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)
if cmd.Flags().Changed("json") {
err = deleteExperimentJson.Unmarshal(&deleteExperimentReq)
if err != nil {
return err
diags := deleteExperimentJson.Unmarshal(&deleteExperimentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -352,9 +370,15 @@ func newDeleteRun() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = deleteRunJson.Unmarshal(&deleteRunReq)
if err != nil {
return err
diags := deleteRunJson.Unmarshal(&deleteRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -435,9 +459,15 @@ func newDeleteRuns() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = deleteRunsJson.Unmarshal(&deleteRunsReq)
if err != nil {
return err
diags := deleteRunsJson.Unmarshal(&deleteRunsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -518,9 +548,15 @@ func newDeleteTag() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = deleteTagJson.Unmarshal(&deleteTagReq)
if err != nil {
return err
diags := deleteTagJson.Unmarshal(&deleteTagReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -1108,9 +1144,15 @@ func newLogBatch() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = logBatchJson.Unmarshal(&logBatchReq)
if err != nil {
return err
diags := logBatchJson.Unmarshal(&logBatchReq)
if diags.HasError() {
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)
if cmd.Flags().Changed("json") {
err = logInputsJson.Unmarshal(&logInputsReq)
if err != nil {
return err
diags := logInputsJson.Unmarshal(&logInputsReq)
if diags.HasError() {
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)
if cmd.Flags().Changed("json") {
err = logMetricJson.Unmarshal(&logMetricReq)
if err != nil {
return err
diags := logMetricJson.Unmarshal(&logMetricReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -1335,9 +1389,15 @@ func newLogModel() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = logModelJson.Unmarshal(&logModelReq)
if err != nil {
return err
diags := logModelJson.Unmarshal(&logModelReq)
if diags.HasError() {
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)
if cmd.Flags().Changed("json") {
err = logParamJson.Unmarshal(&logParamReq)
if err != nil {
return err
diags := logParamJson.Unmarshal(&logParamReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -1497,9 +1563,15 @@ func newRestoreExperiment() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = restoreExperimentJson.Unmarshal(&restoreExperimentReq)
if err != nil {
return err
diags := restoreExperimentJson.Unmarshal(&restoreExperimentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -1572,9 +1644,15 @@ func newRestoreRun() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = restoreRunJson.Unmarshal(&restoreRunReq)
if err != nil {
return err
diags := restoreRunJson.Unmarshal(&restoreRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -1655,9 +1733,15 @@ func newRestoreRuns() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = restoreRunsJson.Unmarshal(&restoreRunsReq)
if err != nil {
return err
diags := restoreRunsJson.Unmarshal(&restoreRunsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -1732,9 +1816,15 @@ func newSearchExperiments() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = searchExperimentsJson.Unmarshal(&searchExperimentsReq)
if err != nil {
return err
diags := searchExperimentsJson.Unmarshal(&searchExperimentsReq)
if diags.HasError() {
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)
if cmd.Flags().Changed("json") {
err = searchRunsJson.Unmarshal(&searchRunsReq)
if err != nil {
return err
diags := searchRunsJson.Unmarshal(&searchRunsReq)
if diags.HasError() {
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)
if cmd.Flags().Changed("json") {
err = setExperimentTagJson.Unmarshal(&setExperimentTagReq)
if err != nil {
return err
diags := setExperimentTagJson.Unmarshal(&setExperimentTagReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -1951,9 +2053,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil {
return err
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
setPermissionsReq.ExperimentId = args[0]
@ -2032,9 +2140,15 @@ func newSetTag() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = setTagJson.Unmarshal(&setTagReq)
if err != nil {
return err
diags := setTagJson.Unmarshal(&setTagReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -2112,9 +2226,15 @@ func newUpdateExperiment() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateExperimentJson.Unmarshal(&updateExperimentReq)
if err != nil {
return err
diags := updateExperimentJson.Unmarshal(&updateExperimentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -2183,9 +2303,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil {
return err
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
updatePermissionsReq.ExperimentId = args[0]
@ -2251,9 +2377,15 @@ func newUpdateRun() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateRunJson.Unmarshal(&updateRunReq)
if err != nil {
return err
diags := updateRunJson.Unmarshal(&updateRunReq)
if diags.HasError() {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -381,9 +387,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
updateReq.Name = args[0]

View File

@ -85,9 +85,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -116,9 +116,15 @@ func newCancelAllRuns() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = cancelAllRunsJson.Unmarshal(&cancelAllRunsReq)
if err != nil {
return err
diags := cancelAllRunsJson.Unmarshal(&cancelAllRunsReq)
if diags.HasError() {
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)
if cmd.Flags().Changed("json") {
err = cancelRunJson.Unmarshal(&cancelRunReq)
if err != nil {
return err
diags := cancelRunJson.Unmarshal(&cancelRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
if len(args) == 0 {
@ -291,9 +303,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = deleteJson.Unmarshal(&deleteReq)
if err != nil {
return err
diags := deleteJson.Unmarshal(&deleteReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
if len(args) == 0 {
@ -457,9 +481,15 @@ func newDeleteRun() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = deleteRunJson.Unmarshal(&deleteRunReq)
if err != nil {
return err
diags := deleteRunJson.Unmarshal(&deleteRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
if len(args) == 0 {
@ -1143,9 +1173,15 @@ func newRepairRun() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = repairRunJson.Unmarshal(&repairRunReq)
if err != nil {
return err
diags := repairRunJson.Unmarshal(&repairRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
if len(args) == 0 {
@ -1242,9 +1278,15 @@ func newReset() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = resetJson.Unmarshal(&resetReq)
if err != nil {
return err
diags := resetJson.Unmarshal(&resetReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = runNowJson.Unmarshal(&runNowReq)
if err != nil {
return err
diags := runNowJson.Unmarshal(&runNowReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
if len(args) == 0 {
@ -1436,9 +1484,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil {
return err
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {
@ -1538,9 +1592,15 @@ func newSubmit() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = submitJson.Unmarshal(&submitReq)
if err != nil {
return err
diags := submitJson.Unmarshal(&submitReq)
if diags.HasError() {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
if len(args) == 0 {
@ -1717,9 +1783,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil {
return err
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {

View File

@ -108,9 +108,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -180,9 +186,15 @@ func newCreateSchedule() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = createScheduleJson.Unmarshal(&createScheduleReq)
if err != nil {
return err
diags := createScheduleJson.Unmarshal(&createScheduleReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createSubscriptionJson.Unmarshal(&createSubscriptionReq)
if err != nil {
return err
diags := createSubscriptionJson.Unmarshal(&createSubscriptionReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = migrateJson.Unmarshal(&migrateReq)
if err != nil {
return err
diags := migrateJson.Unmarshal(&migrateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -941,9 +965,15 @@ func newPublish() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = publishJson.Unmarshal(&publishReq)
if err != nil {
return err
diags := publishJson.Unmarshal(&publishReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
publishReq.DashboardId = args[0]
@ -1128,9 +1158,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
updateReq.DashboardId = args[0]
@ -1200,9 +1236,15 @@ func newUpdateSchedule() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateScheduleJson.Unmarshal(&updateScheduleReq)
if err != nil {
return err
diags := updateScheduleJson.Unmarshal(&updateScheduleReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = installJson.Unmarshal(&installReq)
if err != nil {
return err
diags := installJson.Unmarshal(&installReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = uninstallJson.Unmarshal(&uninstallReq)
if err != nil {
return err
diags := uninstallJson.Unmarshal(&uninstallReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = assignJson.Unmarshal(&assignReq)
if err != nil {
return err
diags := assignJson.Unmarshal(&assignReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
_, err = fmt.Sscan(args[0], &assignReq.WorkspaceId)
@ -201,9 +207,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -606,9 +618,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {
@ -690,9 +708,15 @@ func newUpdateAssignment() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateAssignmentJson.Unmarshal(&updateAssignmentReq)
if err != nil {
return err
diags := updateAssignmentJson.Unmarshal(&updateAssignmentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -98,9 +98,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil {
return err
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {
@ -788,9 +800,15 @@ func newStartUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = startUpdateJson.Unmarshal(&startUpdateReq)
if err != nil {
return err
diags := startUpdateJson.Unmarshal(&startUpdateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {
@ -977,9 +995,15 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {
@ -1058,9 +1082,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil {
return err
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {

View File

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

View File

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

View File

@ -73,9 +73,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = addListingToExchangeJson.Unmarshal(&addListingToExchangeReq)
if err != nil {
return err
diags := addListingToExchangeJson.Unmarshal(&addListingToExchangeReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if !cmd.Flags().Changed("json") {
@ -154,9 +160,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = listJson.Unmarshal(&listReq)
if err != nil {
return err
diags := listJson.Unmarshal(&listReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
updateReq.ListingId = args[0]

View File

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

View File

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

View File

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

View File

@ -96,9 +96,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
if err != nil {
return err
diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
if len(args) == 0 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -169,9 +169,15 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq)
if err != nil {
return err
diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
} else {
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)
if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq)
if err != nil {
return err
diags := patchJson.Unmarshal(&patchReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
patchReq.Name = args[0]
@ -777,9 +789,15 @@ func newPut() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = putJson.Unmarshal(&putReq)
if err != nil {
return err
diags := putJson.Unmarshal(&putReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
putReq.Name = args[0]
@ -850,9 +868,15 @@ func newPutAiGateway() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = putAiGatewayJson.Unmarshal(&putAiGatewayReq)
if err != nil {
return err
diags := putAiGatewayJson.Unmarshal(&putAiGatewayReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
putAiGatewayReq.Name = args[0]
@ -928,9 +952,15 @@ func newQuery() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = queryJson.Unmarshal(&queryReq)
if err != nil {
return err
diags := queryJson.Unmarshal(&queryReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
queryReq.Name = args[0]
@ -997,9 +1027,15 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq)
if err != nil {
return err
diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
setPermissionsReq.ServingEndpointId = args[0]
@ -1076,9 +1112,15 @@ func newUpdateConfig() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updateConfigJson.Unmarshal(&updateConfigReq)
if err != nil {
return err
diags := updateConfigJson.Unmarshal(&updateConfigReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
updateConfigReq.Name = args[0]
@ -1158,9 +1200,15 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if err != nil {
return err
diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil {
return err
}
}
}
updatePermissionsReq.ServingEndpointId = args[0]

View File

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

View File

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

View File

@ -94,9 +94,15 @@ func newGenerateTemporaryTableCredentials() *cobra.Command {
w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") {
err = generateTemporaryTableCredentialsJson.Unmarshal(&generateTemporaryTableCredentialsReq)
if err != nil {
return err
diags := generateTemporaryTableCredentialsJson.Unmarshal(&generateTemporaryTableCredentialsReq)
if diags.HasError() {
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