2022-12-15 14:12:47 +00:00
|
|
|
package bundle
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/databricks/bricks/bundle"
|
|
|
|
"github.com/databricks/bricks/bundle/deploy/terraform"
|
|
|
|
"github.com/databricks/bricks/bundle/phases"
|
|
|
|
"github.com/databricks/bricks/bundle/run"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2022-12-23 14:17:16 +00:00
|
|
|
var runOptions run.Options
|
|
|
|
|
2022-12-15 14:12:47 +00:00
|
|
|
var runCmd = &cobra.Command{
|
2022-12-22 15:19:38 +00:00
|
|
|
Use: "run [flags] KEY",
|
2022-12-15 14:12:47 +00:00
|
|
|
Short: "Run a workload (e.g. a job or a pipeline)",
|
|
|
|
|
2022-12-22 15:19:38 +00:00
|
|
|
Args: cobra.ExactArgs(1),
|
2022-12-15 14:12:47 +00:00
|
|
|
PreRunE: ConfigureBundle,
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
b := bundle.Get(cmd.Context())
|
|
|
|
err := bundle.Apply(cmd.Context(), b, []bundle.Mutator{
|
|
|
|
phases.Initialize(),
|
|
|
|
terraform.Initialize(),
|
|
|
|
terraform.Load(),
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-12-22 15:19:38 +00:00
|
|
|
runner, err := run.Find(b, args[0])
|
2022-12-15 14:12:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-12-23 14:17:16 +00:00
|
|
|
err = runner.Run(cmd.Context(), &runOptions)
|
2022-12-22 15:19:38 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2022-12-15 14:12:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2022-12-23 14:17:16 +00:00
|
|
|
runOptions.Define(runCmd.Flags())
|
2022-12-15 14:12:47 +00:00
|
|
|
rootCmd.AddCommand(runCmd)
|
|
|
|
}
|