Skip to content

Commit

Permalink
Restore cloud test name overwriting from the CLI argument
Browse files Browse the repository at this point in the history
  • Loading branch information
na-- committed Feb 25, 2021
1 parent ac4a3f9 commit 626694d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions cloudapi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func MergeFromExternal(external map[string]json.RawMessage, conf *Config) error

// GetConsolidatedConfig combines the default config values with the JSON config
// values and environment variables and returns the final result.
func GetConsolidatedConfig(jsonRawConf json.RawMessage, env map[string]string) (Config, error) {
func GetConsolidatedConfig(jsonRawConf json.RawMessage, env map[string]string, configArg string) (Config, error) {
result := NewConfig()
if jsonRawConf != nil {
jsonConf := Config{}
Expand All @@ -282,6 +282,11 @@ func GetConsolidatedConfig(jsonRawConf json.RawMessage, env map[string]string) (
// TODO: get rid of envconfig and actually use the env parameter...
return result, err
}
result = result.Apply(envConfig)

return result.Apply(envConfig), nil
if configArg != "" {
result.Name = null.StringFrom(configArg)
}

return result, nil
}
2 changes: 1 addition & 1 deletion cmd/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ This will execute the test on the k6 cloud service. Use "k6 login cloud" to auth
}

// Cloud config
cloudConfig, err := cloudapi.GetConsolidatedConfig(derivedConf.Collectors["cloud"], osEnvironment)
cloudConfig, err := cloudapi.GetConsolidatedConfig(derivedConf.Collectors["cloud"], osEnvironment, "")
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/login_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ This will set the default token used when just "k6 run -o cloud" is passed.`,
}

// We want to use this fully consolidated config for things like
// host addrseses, so users can overwrite them with env vars.
consolidatedCurrentConfig, err := cloudapi.GetConsolidatedConfig(currentJSONConfigRaw, buildEnvMap(os.Environ()))
// host addresses, so users can overwrite them with env vars.
consolidatedCurrentConfig, err := cloudapi.GetConsolidatedConfig(currentJSONConfigRaw, buildEnvMap(os.Environ()), "")
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func getAllOutputConstructors() (map[string]func(output.Params) (output.Output,
return newCollectorAdapter(params, influxc)
},
"cloud": func(params output.Params) (output.Output, error) {
conf, err := cloudapi.GetConsolidatedConfig(params.JSONConfig, params.Environment)
conf, err := cloudapi.GetConsolidatedConfig(params.JSONConfig, params.Environment, params.ConfigArgument)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 626694d

Please sign in to comment.