From abfac96fd86d28c4ee78bd29733cbb9751e633cb Mon Sep 17 00:00:00 2001 From: pigletfly Date: Fri, 21 Jan 2022 15:34:03 +0800 Subject: [PATCH] Sort apiResources Signed-off-by: pigletfly --- pkg/controllers/status/cluster_status_controller.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/controllers/status/cluster_status_controller.go b/pkg/controllers/status/cluster_status_controller.go index 92ffdc194297..a3aa194cfd99 100644 --- a/pkg/controllers/status/cluster_status_controller.go +++ b/pkg/controllers/status/cluster_status_controller.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net/http" + "sort" "strings" "sync" "time" @@ -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}) }