diff --git a/cmd/cloud.go b/cmd/cloud.go index eef83c5e19b..53b7139d76d 100644 --- a/cmd/cloud.go +++ b/cmd/cloud.go @@ -111,7 +111,7 @@ func (c *cmdCloud) run(cmd *cobra.Command, args []string) error { } // Cloud config - cloudConfig, _, err := cloudapi.GetConsolidatedConfig( + cloudConfig, warn, err := cloudapi.GetConsolidatedConfig( test.derivedConfig.Collectors["cloud"], c.gs.Env, "", arc.Options.Cloud, arc.Options.External) if err != nil { return err @@ -120,6 +120,11 @@ func (c *cmdCloud) run(cmd *cobra.Command, args []string) error { return errors.New("Not logged in, please use `k6 login cloud`.") //nolint:golint,revive,stylecheck } + // Display config warning if needed + if warn != "" { + modifyAndPrintBar(c.gs, progressBar, pb.WithConstProgress(0, "Warning: "+warn)) + } + if cloudConfig.Token.Valid { tmpCloudConfig["token"] = cloudConfig.Token } diff --git a/cmd/login_cloud.go b/cmd/login_cloud.go index f39293c4643..d71e214e9e9 100644 --- a/cmd/login_cloud.go +++ b/cmd/login_cloud.go @@ -55,12 +55,16 @@ 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 addresses, so users can overwrite them with env vars. - consolidatedCurrentConfig, _, err := cloudapi.GetConsolidatedConfig( + consolidatedCurrentConfig, warn, err := cloudapi.GetConsolidatedConfig( currentJSONConfigRaw, gs.Env, "", nil, nil) if err != nil { return err } + if warn != "" { + gs.Logger.Warn(warn) + } + // But we don't want to save them back to the JSON file, we only // want to save what already existed there and the login details. newCloudConf := currentJSONConfig diff --git a/output/cloud/output.go b/output/cloud/output.go index 1a5f67a3f4f..fefba95d0d3 100644 --- a/output/cloud/output.go +++ b/output/cloud/output.go @@ -78,7 +78,7 @@ func New(params output.Params) (output.Output, error) { // New creates a new cloud output. func newOutput(params output.Params) (*Output, error) { - conf, _, err := cloudapi.GetConsolidatedConfig( + conf, warn, err := cloudapi.GetConsolidatedConfig( params.JSONConfig, params.Environment, params.ConfigArgument, @@ -89,6 +89,10 @@ func newOutput(params output.Params) (*Output, error) { return nil, err } + if warn != "" { + params.Logger.Warn(warn) + } + if err := validateRequiredSystemTags(params.ScriptOptions.SystemTags); err != nil { return nil, err } @@ -99,7 +103,7 @@ func newOutput(params output.Params) (*Output, error) { scriptPath := params.ScriptPath.String() if scriptPath == "" { // Script from stdin without a name, likely from stdin - return nil, errors.New("script name not set, please specify K6_CLOUD_NAME or options.ext.loadimpact.name") + return nil, errors.New("script name not set, please specify K6_CLOUD_NAME or options.cloud.name") } conf.Name = null.StringFrom(filepath.Base(scriptPath))