2022-11-21 14:39:53 +00:00
|
|
|
package bundle
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
const envName = "DATABRICKS_BUNDLE_ENV"
|
|
|
|
|
|
|
|
// getEnvironment returns the name of the environment to operate in.
|
|
|
|
func getEnvironment(cmd *cobra.Command) (value string) {
|
|
|
|
// The command line flag takes precedence.
|
|
|
|
flag := cmd.Flag("environment")
|
|
|
|
if flag != nil {
|
|
|
|
value = flag.Value.String()
|
|
|
|
if value != "" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If it's not set, use the environment variable.
|
2022-12-15 20:28:14 +00:00
|
|
|
return os.Getenv(envName)
|
2022-11-21 14:39:53 +00:00
|
|
|
}
|