Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone committed May 27, 2020
1 parent abae9a9 commit 198bece
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
28 changes: 14 additions & 14 deletions internal/namespaces/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,24 +284,24 @@ func initCommand() *core.Command {
}
}

profile := &scw.Profile{
AccessKey: &accessKey,
SecretKey: &args.SecretKey,
DefaultZone: scw.StringPtr(args.Zone.String()),
DefaultRegion: scw.StringPtr(args.Region.String()),
DefaultOrganizationID: &args.OrganizationID,
}
// Save the profile as default or as a named profile
profileName := core.ExtractProfileName(ctx)
_, err = config.GetProfile(profileName)
if profileName != "" && err != nil {
config.Profiles[profileName] = &scw.Profile{
AccessKey: &accessKey,
SecretKey: &args.SecretKey,
DefaultZone: scw.StringPtr(args.Zone.String()),
DefaultRegion: scw.StringPtr(args.Region.String()),
DefaultOrganizationID: &args.OrganizationID,
}
} else {
if profileName == "" || err == nil {
// Default configuration
config.AccessKey = &accessKey
config.SecretKey = &args.SecretKey
config.DefaultZone = scw.StringPtr(args.Zone.String())
config.DefaultRegion = scw.StringPtr(args.Region.String())
config.DefaultOrganizationID = &args.OrganizationID
config.Profile = *profile
} else {
if config.Profiles == nil {
config.Profiles = make(map[string]*scw.Profile)
}
config.Profiles[profileName] = profile
}

// Persist configuration on disk
Expand Down
1 change: 1 addition & 0 deletions internal/namespaces/init/init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package init

0 comments on commit 198bece

Please sign in to comment.