File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ func DetectClusterManager(kc client.Client, mappers ...meta.RESTMapper) kmapi.Cl
237237 if IsOpenClusterHub (mapper ) {
238238 result |= kmapi .ClusterManagerOCMHub
239239 }
240- if IsOpenClusterSpoke (mapper ) {
240+ if IsOpenClusterSpoke (kc ) {
241241 result |= kmapi .ClusterManagerOCMSpoke
242242 }
243243 if IsOpenClusterMulticlusterControlplane (mapper ) {
Original file line number Diff line number Diff line change @@ -17,8 +17,12 @@ limitations under the License.
1717package cluster
1818
1919import (
20+ "context"
21+
2022 "k8s.io/apimachinery/pkg/api/meta"
23+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2124 "k8s.io/apimachinery/pkg/runtime/schema"
25+ "sigs.k8s.io/controller-runtime/pkg/client"
2226)
2327
2428func IsOpenClusterHub (mapper meta.RESTMapper ) bool {
@@ -31,14 +35,12 @@ func IsOpenClusterHub(mapper meta.RESTMapper) bool {
3135 return false
3236}
3337
34- func IsOpenClusterSpoke (mapper meta.RESTMapper ) bool {
35- if _ , err := mapper .RESTMappings (schema.GroupKind {
36- Group : "operator.open-cluster-management.io" ,
37- Kind : "Klusterlet" ,
38- }); err == nil {
39- return true
40- }
41- return false
38+ func IsOpenClusterSpoke (kc client.Client ) bool {
39+ var list unstructured.UnstructuredList
40+ list .SetAPIVersion ("operator.open-cluster-management.io/v1" )
41+ list .SetKind ("Klusterlet" )
42+ err := kc .List (context .TODO (), & list )
43+ return err == nil && len (list .Items ) > 0
4244}
4345
4446func IsOpenClusterMulticlusterControlplane (mapper meta.RESTMapper ) bool {
You can’t perform that action at this time.
0 commit comments