Skip to content

Commit 78eb6ac

Browse files
committed
fix(config): create new scw configuration if not found
1 parent 99dee54 commit 78eb6ac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/namespaces/config/commands.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,12 @@ The only allowed attributes are access_key, secret_key, default_organization_id,
290290
configPath := core.ExtractConfigPath(ctx)
291291
config, err := scw.LoadConfigFromPath(configPath)
292292
if err != nil {
293-
return nil, err
293+
if strings.Contains(err.Error(), "no such file or directory") {
294+
fmt.Fprintln(os.Stdout, "config file not found, will attempt to create it")
295+
config = &scw.Config{}
296+
} else {
297+
return nil, err
298+
}
294299
}
295300

296301
// send_telemetry is the only key that is not in a profile but in the config object directly

0 commit comments

Comments
 (0)