2023-01-23 14:00:11 +00:00
|
|
|
package bundle
|
|
|
|
|
|
|
|
import (
|
2024-03-12 14:12:34 +00:00
|
|
|
"github.com/databricks/cli/cmd/root"
|
2023-01-23 14:00:11 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2023-07-27 10:03:08 +00:00
|
|
|
func newSchemaCommand() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "schema",
|
|
|
|
Short: "Generate JSON Schema for bundle configuration",
|
2024-03-12 14:12:34 +00:00
|
|
|
Args: root.NoArgs,
|
2023-07-27 10:03:08 +00:00
|
|
|
}
|
2023-01-23 14:00:11 +00:00
|
|
|
|
2023-07-27 10:03:08 +00:00
|
|
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
2024-08-27 11:35:56 +00:00
|
|
|
// os.ReadFile()
|
|
|
|
|
2024-08-27 10:47:49 +00:00
|
|
|
// // Load embedded schema descriptions.
|
|
|
|
// docs, err := schema.LoadBundleDescriptions()
|
|
|
|
// if err != nil {
|
|
|
|
// return err
|
|
|
|
// }
|
|
|
|
|
|
|
|
// // Generate the JSON schema from the bundle configuration struct in Go.
|
|
|
|
// schema, err := schema.New(reflect.TypeOf(config.Root{}), docs)
|
|
|
|
// if err != nil {
|
|
|
|
// return err
|
|
|
|
// }
|
|
|
|
|
|
|
|
// // Target variable value overrides can be primitives, maps or sequences.
|
|
|
|
// // Set an empty schema for them.
|
|
|
|
// err = schema.SetByPath("targets.*.variables.*", jsonschema.Schema{})
|
|
|
|
// if err != nil {
|
|
|
|
// return err
|
|
|
|
// }
|
|
|
|
|
|
|
|
// // Print the JSON schema to stdout.
|
|
|
|
// result, err := json.MarshalIndent(schema, "", " ")
|
|
|
|
// if err != nil {
|
|
|
|
// return err
|
|
|
|
// }
|
|
|
|
// cmd.OutOrStdout().Write(result)
|
2023-01-23 14:00:11 +00:00
|
|
|
return nil
|
2023-07-27 10:03:08 +00:00
|
|
|
}
|
2023-03-15 02:18:51 +00:00
|
|
|
|
2023-07-27 10:03:08 +00:00
|
|
|
return cmd
|
2023-01-23 14:00:11 +00:00
|
|
|
}
|