diff --git a/cmd/bundle/deploy.go b/cmd/bundle/deploy.go index f1179634c..02b95a35b 100644 --- a/cmd/bundle/deploy.go +++ b/cmd/bundle/deploy.go @@ -1,6 +1,8 @@ package bundle import ( + "os" + "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/phases" "github.com/spf13/cobra" @@ -14,17 +16,25 @@ var deployCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) error { b := bundle.Get(cmd.Context()) - // If `--force` is specified, force acquisition of the deployment lock. - b.Config.Bundle.Lock.Force = force - - return bundle.Apply(cmd.Context(), b, bundle.Seq( - phases.Initialize(""), - phases.Build(), - phases.Deploy(), - )) + return Deploy(cmd, b) }, } +func Deploy(cmd *cobra.Command, b *bundle.Bundle) error { + // If `--force` is specified, force acquisition of the deployment lock. + b.Config.Bundle.Lock.Force = force + + if computeID == "" { + computeID = os.Getenv("DATABRICKS_COMPUTE") + } + + return bundle.Apply(cmd.Context(), b, bundle.Seq( + phases.Initialize(computeID), + phases.Build(), + phases.Deploy(), + )) +} + var force bool var computeID string diff --git a/cmd/bundle/run.go b/cmd/bundle/run.go index 65e17f3d4..c80c04b07 100644 --- a/cmd/bundle/run.go +++ b/cmd/bundle/run.go @@ -27,12 +27,7 @@ var runCmd = &cobra.Command{ b := bundle.Get(cmd.Context()) if deploy { - b.Config.Bundle.Lock.Force = force - err := bundle.Apply(cmd.Context(), b, bundle.Seq( - phases.Initialize(computeID), - phases.Build(), - phases.Deploy(), - )) + err := Deploy(cmd, b) if err != nil { return err }