Introduce DATABRICKS_COMPUTE environment variable

This commit is contained in:
Lennart Kats 2023-06-18 17:37:16 +02:00
parent 48d6df3dfa
commit 27b2b77bff
2 changed files with 19 additions and 14 deletions

View File

@ -1,6 +1,8 @@
package bundle package bundle
import ( import (
"os"
"github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/phases" "github.com/databricks/cli/bundle/phases"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -14,17 +16,25 @@ var deployCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
b := bundle.Get(cmd.Context()) b := bundle.Get(cmd.Context())
// If `--force` is specified, force acquisition of the deployment lock. return Deploy(cmd, b)
b.Config.Bundle.Lock.Force = force
return bundle.Apply(cmd.Context(), b, bundle.Seq(
phases.Initialize(""),
phases.Build(),
phases.Deploy(),
))
}, },
} }
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 force bool
var computeID string var computeID string

View File

@ -27,12 +27,7 @@ var runCmd = &cobra.Command{
b := bundle.Get(cmd.Context()) b := bundle.Get(cmd.Context())
if deploy { if deploy {
b.Config.Bundle.Lock.Force = force err := Deploy(cmd, b)
err := bundle.Apply(cmd.Context(), b, bundle.Seq(
phases.Initialize(computeID),
phases.Build(),
phases.Deploy(),
))
if err != nil { if err != nil {
return err return err
} }