sort the aggregatedStatus in rb/crb by the clusterName

Signed-off-by: changzhen <changzhen5@huawei.com>
This commit is contained in:
changzhen 2022-04-26 19:40:14 +08:00
parent cd05ffee6e
commit 86072e1dbd
1 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"reflect" "reflect"
"sort"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -193,6 +194,9 @@ func assembleWorkStatus(works []workv1alpha1.Work, workload *unstructured.Unstru
} }
} }
sort.Slice(statuses, func(i, j int) bool {
return statuses[i].ClusterName < statuses[j].ClusterName
})
return statuses, nil return statuses, nil
} }