Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lint errors
Browse files Browse the repository at this point in the history
codebien committed Jan 31, 2025
1 parent 91b2afa commit 91710b9
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions internal/cmd/config.go
Original file line number Diff line number Diff line change
@@ -210,15 +210,17 @@ func readEnvConfig(envMap map[string]string) (Config, error) {
// TODO: accumulate all errors and differentiate between the layers?
func getConsolidatedConfig(gs *state.GlobalState, cliConf Config, runnerOpts lib.Options) (conf Config, err error) {
fileConf, err := readLegacyDiskConfig(gs)
if errors.Is(err, fs.ErrNotExist) {
if errors.Is(err, fs.ErrNotExist) { //nolint:gocritic
fileConf, err = readDiskConfig(gs)
if err != nil {
return conf, errext.WithExitCodeIfNone(err, exitcodes.InvalidConfig)
}
} else if err != nil {
return conf, errext.WithExitCodeIfNone(err, exitcodes.InvalidConfig)
} else {
gs.Logger.Warn("The configuration file has been found on the old path. Please, run again `k6 cloud login` or `k6 login` commands to migrate to the new path. If you already migrated it manually, then remove the file from the old path.\n\n")
gs.Logger.Warn("The configuration file has been found on the old path. " +
"Please, run again `k6 cloud login` or `k6 login` commands to migrate to the new path. " +
"If you already migrated it manually, then remove the file from the old path.\n\n")
}

envConf, err := readEnvConfig(gs.Env)
4 changes: 3 additions & 1 deletion internal/cmd/config_test.go
Original file line number Diff line number Diff line change
@@ -409,11 +409,12 @@ func TestWriteDiskConfigNoJSONContentError(t *testing.T) {
}

func TestMigrateLegacyConfigFileIfAny(t *testing.T) {
t.Parallel()
memfs := fsext.NewMemMapFs()

conf := []byte(`{"iterations":1028,"cloud":{"field1":"testvalue"}}`)
legacyConfigPath := ".config/loadimpact/k6/config.json"
fsext.WriteFile(memfs, legacyConfigPath, conf, 0o644)
require.NoError(t, fsext.WriteFile(memfs, legacyConfigPath, conf, 0o644))

logger := logrus.New()
logger.SetOutput(io.Discard)
@@ -439,6 +440,7 @@ func TestMigrateLegacyConfigFileIfAny(t *testing.T) {
}

func TestMigrateLegacyConfigFileIfAnyWhenFileDoesNotExist(t *testing.T) {
t.Parallel()
memfs := fsext.NewMemMapFs()

defaultFlags := state.GetDefaultFlags(".config")

0 comments on commit 91710b9

Please sign in to comment.