Skip to content

Commit

Permalink
sort profiles by profile name
Browse files Browse the repository at this point in the history
  • Loading branch information
shwethaumashanker committed Aug 12, 2024
1 parent 276781c commit 9f37f97
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions awscfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ func Merge(opts MergeOpts) error {
opts.SectionNameTemplate = "{{ .AccountName }}/{{ .RoleName }}"
}

// Sort profiles by CombinedName (AccountName/RoleName)
sort.SliceStable(opts.Profiles, func(i, j int) bool {
profileNameI := opts.Prefix + opts.Profiles[i].RoleName
profileNameJ := opts.Prefix + opts.Profiles[j].RoleName
return profileNameI < profileNameJ
combinedNameI := opts.Profiles[i].AccountName + "/" + opts.Profiles[i].RoleName
combinedNameJ := opts.Profiles[j].AccountName + "/" + opts.Profiles[j].RoleName
return combinedNameI < combinedNameJ
})

funcMap := sprig.TxtFuncMap()
Expand Down

0 comments on commit 9f37f97

Please sign in to comment.