diff --git a/cloudapi/config.go b/cloudapi/config.go index 5a370597836..e113ff59645 100644 --- a/cloudapi/config.go +++ b/cloudapi/config.go @@ -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{} @@ -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 } diff --git a/cmd/cloud.go b/cmd/cloud.go index e2d27b989f1..680168a746e 100644 --- a/cmd/cloud.go +++ b/cmd/cloud.go @@ -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 } diff --git a/cmd/login_cloud.go b/cmd/login_cloud.go index daf1b4f8982..a22e81e40d7 100644 --- a/cmd/login_cloud.go +++ b/cmd/login_cloud.go @@ -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 } diff --git a/cmd/outputs.go b/cmd/outputs.go index 21dda8859b3..46f740a89fa 100644 --- a/cmd/outputs.go +++ b/cmd/outputs.go @@ -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 }