@@ -284,24 +284,24 @@ func initCommand() *core.Command {
284
284
}
285
285
}
286
286
287
+ profile := & scw.Profile {
288
+ AccessKey : & accessKey ,
289
+ SecretKey : & args .SecretKey ,
290
+ DefaultZone : scw .StringPtr (args .Zone .String ()),
291
+ DefaultRegion : scw .StringPtr (args .Region .String ()),
292
+ DefaultOrganizationID : & args .OrganizationID ,
293
+ }
287
294
// Save the profile as default or as a named profile
288
295
profileName := core .ExtractProfileName (ctx )
289
296
_ , err = config .GetProfile (profileName )
290
- if profileName != "" && err != nil {
291
- config .Profiles [profileName ] = & scw.Profile {
292
- AccessKey : & accessKey ,
293
- SecretKey : & args .SecretKey ,
294
- DefaultZone : scw .StringPtr (args .Zone .String ()),
295
- DefaultRegion : scw .StringPtr (args .Region .String ()),
296
- DefaultOrganizationID : & args .OrganizationID ,
297
- }
298
- } else {
297
+ if profileName == "" || err == nil {
299
298
// Default configuration
300
- config .AccessKey = & accessKey
301
- config .SecretKey = & args .SecretKey
302
- config .DefaultZone = scw .StringPtr (args .Zone .String ())
303
- config .DefaultRegion = scw .StringPtr (args .Region .String ())
304
- config .DefaultOrganizationID = & args .OrganizationID
299
+ config .Profile = * profile
300
+ } else {
301
+ if config .Profiles == nil {
302
+ config .Profiles = make (map [string ]* scw.Profile )
303
+ }
304
+ config .Profiles [profileName ] = profile
305
305
}
306
306
307
307
// Persist configuration on disk
0 commit comments