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,15 +16,23 @@ 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())
return Deploy(cmd, b)
},
}
func Deploy(cmd *cobra.Command, b *bundle.Bundle) error {
// If `--force` is specified, force acquisition of the deployment lock. // If `--force` is specified, force acquisition of the deployment lock.
b.Config.Bundle.Lock.Force = force b.Config.Bundle.Lock.Force = force
if computeID == "" {
computeID = os.Getenv("DATABRICKS_COMPUTE")
}
return bundle.Apply(cmd.Context(), b, bundle.Seq( return bundle.Apply(cmd.Context(), b, bundle.Seq(
phases.Initialize(""), phases.Initialize(computeID),
phases.Build(), phases.Build(),
phases.Deploy(), phases.Deploy(),
)) ))
},
} }
var force bool var force bool

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
} }