fix: Rename to --var-file

This commit is contained in:
Ilya Kuznetsov 2025-01-17 11:40:35 +01:00
parent 3f0b5f848e
commit a75c6afd6b
No known key found for this signature in database
GPG Key ID: 91F3DDCF5D21CDDF
4 changed files with 5 additions and 5 deletions

View File

@ -1,5 +1,5 @@
# variable file # variable file
$CLI bundle validate -o json --vars-file-path=vars.json | jq .resources.jobs.job1.job_clusters[0] $CLI bundle validate -o json --var-file=vars.json | jq .resources.jobs.job1.job_clusters[0]
# variable flag # variable flag
$CLI bundle validate -o json --var="cluster_key=mlops_stacks-cluster" | jq .resources.jobs.job1.job_clusters[0].job_cluster_key $CLI bundle validate -o json --var="cluster_key=mlops_stacks-cluster" | jq .resources.jobs.job1.job_clusters[0].job_cluster_key

View File

@ -38,7 +38,7 @@ type Variable struct {
// //
// 1. Command line flag, one of these is used // 1. Command line flag, one of these is used
// a. Variable value obtained from arguments, example: `--var="foo=bar"` // a. Variable value obtained from arguments, example: `--var="foo=bar"`
// b. Variable value obtained from the file, example: `--vars-file-path="/path/to/file"` // b. Variable value obtained from the file, example: `--var-file="/path/to/file"`
// 2. Environment variable. eg: BUNDLE_VAR_foo=bar // 2. Environment variable. eg: BUNDLE_VAR_foo=bar
// 3. Default value as defined in the applicable targets block // 3. Default value as defined in the applicable targets block
// 4. Default value defined in variable definition // 4. Default value defined in variable definition

View File

@ -54,13 +54,13 @@ func ConfigureBundleWithVariables(cmd *cobra.Command) (*bundle.Bundle, diag.Diag
if err != nil { if err != nil {
return b, diag.FromErr(err) return b, diag.FromErr(err)
} }
variableFilePath, err := cmd.Flags().GetString("vars-file-path") variableFilePath, err := cmd.Flags().GetString("var-file")
if err != nil { if err != nil {
return b, diag.FromErr(err) return b, diag.FromErr(err)
} }
if len(variables) > 0 && variableFilePath != "" { if len(variables) > 0 && variableFilePath != "" {
return b, diag.Errorf("cannot specify both --var and --vars-file-path flags") return b, diag.Errorf("cannot specify both --var and --var-file flags")
} else if len(variables) > 0 { } else if len(variables) > 0 {
// Initialize variables by assigning them values passed as command line flags // Initialize variables by assigning them values passed as command line flags
diags = diags.Extend(configureVariables(cmd, b, variables)) diags = diags.Extend(configureVariables(cmd, b, variables))

View File

@ -6,5 +6,5 @@ import (
func initVariableFlag(cmd *cobra.Command) { func initVariableFlag(cmd *cobra.Command) {
cmd.PersistentFlags().StringSlice("var", []string{}, `set values for variables defined in bundle config. Example: --var="foo=bar"`) cmd.PersistentFlags().StringSlice("var", []string{}, `set values for variables defined in bundle config. Example: --var="foo=bar"`)
cmd.PersistentFlags().String("vars-file-path", "", `file path to a JSON file containing variables. Example: --vars-file-path="/path/to/vars.json"`) cmd.PersistentFlags().String("var-file", "", `file path to a JSON file containing variables. Example: --var-file="/path/to/vars.json"`)
} }