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
|
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.")
|
|
|
|
cmd.Flags().BoolVar(&forceLock, "force-deploy", false, "Force acquisition of deployment lock.")
|
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
|
|
|
|
b.Config.Bundle.Lock.Force = forceLock
|
2023-07-12 06:51:54 +00:00
|
|
|
b.Config.Bundle.ComputeID = computeID
|
2023-03-22 15:37:26 +00:00
|
|
|
|
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
|
|
|
}
|