2022-12-12 11:49:25 +00:00
|
|
|
package bundle
|
|
|
|
|
|
|
|
import (
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle"
|
|
|
|
"github.com/databricks/cli/bundle/phases"
|
2022-12-12 11:49:25 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2023-07-27 10:03:08 +00:00
|
|
|
func newDeployCommand() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "deploy",
|
|
|
|
Short: "Deploy bundle",
|
|
|
|
PreRunE: ConfigureBundleWithVariables,
|
|
|
|
}
|
2022-12-12 11:49:25 +00:00
|
|
|
|
2023-07-30 12:44:33 +00:00
|
|
|
var force bool
|
|
|
|
var forceLock bool
|
2024-02-07 11:17:17 +00:00
|
|
|
var failOnActiveRuns bool
|
2023-07-27 10:03:08 +00:00
|
|
|
var computeID string
|
2023-07-30 12:44:33 +00:00
|
|
|
cmd.Flags().BoolVar(&force, "force", false, "Force-override Git branch validation.")
|
2023-08-15 19:03:43 +00:00
|
|
|
cmd.Flags().BoolVar(&forceLock, "force-lock", false, "Force acquisition of deployment lock.")
|
2024-02-07 11:17:17 +00:00
|
|
|
cmd.Flags().BoolVar(&failOnActiveRuns, "fail-on-active-runs", false, "Fail if there are running jobs or pipelines in the deployment.")
|
2023-07-27 10:03:08 +00:00
|
|
|
cmd.Flags().StringVarP(&computeID, "compute-id", "c", "", "Override compute in the deployment with the given compute ID.")
|
|
|
|
|
|
|
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
2022-12-12 11:49:25 +00:00
|
|
|
b := bundle.Get(cmd.Context())
|
2023-03-22 15:37:26 +00:00
|
|
|
|
2023-07-30 12:44:33 +00:00
|
|
|
b.Config.Bundle.Force = force
|
2024-02-07 11:17:17 +00:00
|
|
|
b.Config.Bundle.Deployment.Lock.Force = forceLock
|
2023-07-12 06:51:54 +00:00
|
|
|
b.Config.Bundle.ComputeID = computeID
|
2023-03-22 15:37:26 +00:00
|
|
|
|
2024-02-07 11:17:17 +00:00
|
|
|
if cmd.Flag("fail-on-active-runs").Changed {
|
|
|
|
b.Config.Bundle.Deployment.FailOnActiveRuns = failOnActiveRuns
|
|
|
|
}
|
|
|
|
|
2023-05-24 12:45:19 +00:00
|
|
|
return bundle.Apply(cmd.Context(), b, bundle.Seq(
|
2022-12-12 11:49:25 +00:00
|
|
|
phases.Initialize(),
|
|
|
|
phases.Build(),
|
|
|
|
phases.Deploy(),
|
2023-05-24 12:45:19 +00:00
|
|
|
))
|
2023-07-27 10:03:08 +00:00
|
|
|
}
|
2023-03-22 15:37:26 +00:00
|
|
|
|
2023-07-27 10:03:08 +00:00
|
|
|
return cmd
|
2022-12-12 11:49:25 +00:00
|
|
|
}
|