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
237
237
if IsOpenClusterHub (mapper ) {
238
238
result |= kmapi .ClusterManagerOCMHub
239
239
}
240
- if IsOpenClusterSpoke (mapper ) {
240
+ if IsOpenClusterSpoke (kc ) {
241
241
result |= kmapi .ClusterManagerOCMSpoke
242
242
}
243
243
if IsOpenClusterMulticlusterControlplane (mapper ) {
Original file line number Diff line number Diff line change @@ -17,8 +17,12 @@ limitations under the License.
17
17
package cluster
18
18
19
19
import (
20
+ "context"
21
+
20
22
"k8s.io/apimachinery/pkg/api/meta"
23
+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
21
24
"k8s.io/apimachinery/pkg/runtime/schema"
25
+ "sigs.k8s.io/controller-runtime/pkg/client"
22
26
)
23
27
24
28
func IsOpenClusterHub (mapper meta.RESTMapper ) bool {
@@ -31,14 +35,12 @@ func IsOpenClusterHub(mapper meta.RESTMapper) bool {
31
35
return false
32
36
}
33
37
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
42
44
}
43
45
44
46
func IsOpenClusterMulticlusterControlplane (mapper meta.RESTMapper ) bool {
You can’t perform that action at this time.
0 commit comments