mirror of https://github.com/databricks/cli.git
38 lines
715 B
Go
38 lines
715 B
Go
package bundle
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/databricks/cli/bundle"
|
|
"github.com/databricks/cli/bundle/phases"
|
|
"github.com/databricks/cli/cmd/bundle/utils"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func newValidateCommand() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "validate",
|
|
Short: "Validate configuration",
|
|
|
|
PreRunE: utils.ConfigureBundleWithVariables,
|
|
}
|
|
|
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
|
b := bundle.Get(cmd.Context())
|
|
|
|
err := bundle.Apply(cmd.Context(), b, phases.Initialize())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
buf, err := json.MarshalIndent(b.Config, "", " ")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
cmd.OutOrStdout().Write(buf)
|
|
return nil
|
|
}
|
|
|
|
return cmd
|
|
}
|