Skip to content

Commit

Permalink
Sort apiResources
Browse files Browse the repository at this point in the history
Signed-off-by: pigletfly <[email protected]>
  • Loading branch information
pigletfly committed Jan 22, 2022
1 parent e5aeb26 commit abfac96
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/controllers/status/cluster_status_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"sort"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -364,14 +365,15 @@ func getAPIEnablements(clusterClient *util.ClusterClient) ([]clusterv1alpha1.API
if strings.Contains(resource.Name, "/") {
continue
}

apiResource := clusterv1alpha1.APIResource{
Name: resource.Name,
Kind: resource.Kind,
}

apiResources = append(apiResources, apiResource)
}
sort.SliceStable(apiResources, func(i, j int) bool {
return apiResources[i].Name < apiResources[j].Name
})
apiEnablements = append(apiEnablements, clusterv1alpha1.APIEnablement{GroupVersion: list.GroupVersion, Resources: apiResources})
}

Expand Down

0 comments on commit abfac96

Please sign in to comment.