Skip to content

Commit d770afa

Browse files
committed
Warnings about options.cloud
1 parent 50418f8 commit d770afa

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

cmd/cloud.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (c *cmdCloud) run(cmd *cobra.Command, args []string) error {
111111
}
112112

113113
// Cloud config
114-
cloudConfig, _, err := cloudapi.GetConsolidatedConfig(
114+
cloudConfig, warn, err := cloudapi.GetConsolidatedConfig(
115115
test.derivedConfig.Collectors["cloud"], c.gs.Env, "", arc.Options.Cloud, arc.Options.External)
116116
if err != nil {
117117
return err
@@ -120,6 +120,11 @@ func (c *cmdCloud) run(cmd *cobra.Command, args []string) error {
120120
return errors.New("Not logged in, please use `k6 login cloud`.") //nolint:golint,revive,stylecheck
121121
}
122122

123+
// Display config warning if needed
124+
if warn != "" {
125+
modifyAndPrintBar(c.gs, progressBar, pb.WithConstProgress(0, "Warning: "+warn))
126+
}
127+
123128
if cloudConfig.Token.Valid {
124129
tmpCloudConfig["token"] = cloudConfig.Token
125130
}

cmd/login_cloud.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@ This will set the default token used when just "k6 run -o cloud" is passed.`,
5555

5656
// We want to use this fully consolidated config for things like
5757
// host addresses, so users can overwrite them with env vars.
58-
consolidatedCurrentConfig, _, err := cloudapi.GetConsolidatedConfig(
58+
consolidatedCurrentConfig, warn, err := cloudapi.GetConsolidatedConfig(
5959
currentJSONConfigRaw, gs.Env, "", nil, nil)
6060
if err != nil {
6161
return err
6262
}
6363

64+
if warn != "" {
65+
gs.Logger.Warn(warn)
66+
}
67+
6468
// But we don't want to save them back to the JSON file, we only
6569
// want to save what already existed there and the login details.
6670
newCloudConf := currentJSONConfig

output/cloud/output.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func New(params output.Params) (output.Output, error) {
7878

7979
// New creates a new cloud output.
8080
func newOutput(params output.Params) (*Output, error) {
81-
conf, _, err := cloudapi.GetConsolidatedConfig(
81+
conf, warn, err := cloudapi.GetConsolidatedConfig(
8282
params.JSONConfig,
8383
params.Environment,
8484
params.ConfigArgument,
@@ -89,6 +89,10 @@ func newOutput(params output.Params) (*Output, error) {
8989
return nil, err
9090
}
9191

92+
if warn != "" {
93+
params.Logger.Warn(warn)
94+
}
95+
9296
if err := validateRequiredSystemTags(params.ScriptOptions.SystemTags); err != nil {
9397
return nil, err
9498
}
@@ -99,7 +103,7 @@ func newOutput(params output.Params) (*Output, error) {
99103
scriptPath := params.ScriptPath.String()
100104
if scriptPath == "" {
101105
// Script from stdin without a name, likely from stdin
102-
return nil, errors.New("script name not set, please specify K6_CLOUD_NAME or options.ext.loadimpact.name")
106+
return nil, errors.New("script name not set, please specify K6_CLOUD_NAME or options.cloud.name")
103107
}
104108

105109
conf.Name = null.StringFrom(filepath.Base(scriptPath))

0 commit comments

Comments
 (0)