Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions utils/qovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"os"
"sort"
"strconv"
"strings"
"time"
Expand All @@ -26,6 +27,12 @@ func init() {
})
}

func sortNamesCaseInsensitive(names []string) {
sort.Slice(names, func(i, j int) bool {
return strings.ToLower(names[i]) < strings.ToLower(names[j])
})
}

type Organization struct {
ID Id
Name Name
Expand Down Expand Up @@ -155,6 +162,7 @@ func SelectOrganization() (*Organization, error) {
organizationNames = append(organizationNames, org.Name)
orgs[org.Name] = org.Id
}
sortNamesCaseInsensitive(organizationNames)

if len(organizationNames) < 1 {
return nil, errors.New("no organizations found")
Expand Down Expand Up @@ -251,6 +259,7 @@ func SelectProject(organizationID Id) (*Project, error) {
projectsNames = append(projectsNames, proj.Name)
projects[proj.Name] = proj.Id
}
sortNamesCaseInsensitive(projectsNames)

if len(projectsNames) < 1 {
return nil, errors.New("no projects found")
Expand Down Expand Up @@ -347,6 +356,7 @@ func SelectEnvironment(projectID Id) (*Environment, error) {
environmentsNames = append(environmentsNames, env.Name)
environments[env.Name] = env
}
sortNamesCaseInsensitive(environmentsNames)

if len(environmentsNames) < 1 {
return nil, errors.New("no environments found")
Expand Down Expand Up @@ -620,6 +630,8 @@ func SelectService(environment Id) (*Service, error) {
Type: TerraformType,
}
}
sortNamesCaseInsensitive(servicesNames)

if len(servicesNames) < 1 {
return nil, errors.New("no services found")
}
Expand Down
Loading