2023-05-15 09:34:05 +00:00
|
|
|
package bundle
|
|
|
|
|
|
|
|
import (
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle"
|
|
|
|
"github.com/databricks/cli/cmd/root"
|
2023-05-15 09:34:05 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ConfigureBundleWithVariables(cmd *cobra.Command, args []string) error {
|
2023-08-17 15:22:32 +00:00
|
|
|
// Load bundle config and apply target
|
2023-05-15 09:34:05 +00:00
|
|
|
err := root.MustConfigureBundle(cmd, args)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-07-27 10:03:08 +00:00
|
|
|
variables, err := cmd.Flags().GetStringSlice("var")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-05-15 09:34:05 +00:00
|
|
|
// Initialize variables by assigning them values passed as command line flags
|
|
|
|
b := bundle.Get(cmd.Context())
|
|
|
|
return b.Config.InitializeVariables(variables)
|
|
|
|
}
|
|
|
|
|
2023-07-27 10:03:08 +00:00
|
|
|
func initVariableFlag(cmd *cobra.Command) {
|
|
|
|
cmd.PersistentFlags().StringSlice("var", []string{}, `set values for variables defined in bundle config. Example: --var="foo=bar"`)
|
2023-05-15 09:34:05 +00:00
|
|
|
}
|