Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions acceptance/bundle/override/job_tasks/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
>>> errcode $CLI bundle validate -o json -t development
Error: file ./test1.py not found


Exit code: 1
{
"name": "job",
Expand Down Expand Up @@ -36,6 +37,7 @@ Exit code: 1
>>> errcode $CLI bundle validate -o json -t staging
Error: file ./test1.py not found


Exit code: 1
{
"name": "job",
Expand Down Expand Up @@ -66,3 +68,16 @@ Exit code: 1
}
]
}

>>> errcode $CLI bundle validate -t staging
Error: file ./test1.py not found

Name: override_job_tasks
Target: staging
Workspace:
User: tester@databricks.com
Path: /Workspace/Users/tester@databricks.com/.bundle/override_job_tasks/staging

Found 1 error

Exit code: 1
1 change: 1 addition & 0 deletions acceptance/bundle/override/job_tasks/script
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
trace errcode $CLI bundle validate -o json -t development | jq .resources.jobs.foo
trace errcode $CLI bundle validate -o json -t staging | jq .resources.jobs.foo
trace errcode $CLI bundle validate -t staging
4 changes: 4 additions & 0 deletions acceptance/bundle/override/merge-string-map/output.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

>>> $CLI bundle validate -o json -t dev
Warning: expected map, found string
at resources.clusters.my_cluster
in databricks.yml:6:17

{
"clusters": {
"my_cluster": {
Expand Down
23 changes: 19 additions & 4 deletions cmd/bundle/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ import (
"github.com/databricks/cli/bundle/render"
"github.com/databricks/cli/cmd/bundle/utils"
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/flags"
"github.com/spf13/cobra"
)

func renderJsonOutput(cmd *cobra.Command, b *bundle.Bundle, diags diag.Diagnostics) error {
func renderJsonOutput(cmd *cobra.Command, b *bundle.Bundle) error {
buf, err := json.MarshalIndent(b.Config.Value().AsAny(), "", " ")
if err != nil {
return err
}
_, _ = cmd.OutOrStdout().Write(buf)
return diags.Error()
return nil
}

func newValidateCommand() *cobra.Command {
Expand Down Expand Up @@ -66,7 +65,23 @@ func newValidateCommand() *cobra.Command {

return nil
case flags.OutputJSON:
return renderJsonOutput(cmd, b, diags)
renderOpts := render.RenderOptions{RenderSummaryTable: false}
err1 := render.RenderDiagnostics(cmd.OutOrStderr(), b, diags, renderOpts)
Comment thread
denik marked this conversation as resolved.
Outdated
err2 := renderJsonOutput(cmd, b)

if err2 != nil {
return err2
}

if err1 != nil {
return err1
}

if diags.HasError() {
return root.ErrAlreadyPrinted
}

return nil
default:
return fmt.Errorf("unknown output type %s", root.OutputType(cmd))
}
Expand Down