Skip to content

Commit

Permalink
Support passing optional rest mapper for cluster manager detection (#581
Browse files Browse the repository at this point in the history
)

Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Mar 7, 2024
1 parent ebbb203 commit ef9c67d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cluster/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,29 @@ func getProviderName(kind string) string {
return ""
}

func DetectClusterManager(kc client.Client) kmapi.ClusterManager {
func DetectClusterManager(kc client.Client, mappers ...meta.RESTMapper) kmapi.ClusterManager {
mapper := kc.RESTMapper()
if len(mappers) > 0 {
mapper = mappers[0]
}

var result kmapi.ClusterManager
if IsACEManaged(kc) {
result |= kmapi.ClusterManagerACE
}
if IsOpenClusterHub(kc.RESTMapper()) {
if IsOpenClusterHub(mapper) {
result |= kmapi.ClusterManagerOCMHub
}
if IsOpenClusterSpoke(kc.RESTMapper()) {
if IsOpenClusterSpoke(mapper) {
result |= kmapi.ClusterManagerOCMSpoke
}
if IsOpenClusterMulticlusterControlplane(kc.RESTMapper()) {
if IsOpenClusterMulticlusterControlplane(mapper) {
result |= kmapi.ClusterManagerOCMMulticlusterControlplane
}
if IsRancherManaged(kc.RESTMapper()) {
if IsRancherManaged(mapper) {
result |= kmapi.ClusterManagerRancher
}
if IsOpenShiftManaged(kc.RESTMapper()) {
if IsOpenShiftManaged(mapper) {
result |= kmapi.ClusterManagerOpenShift
}
if MustIsVirtualCluster(kc) {
Expand Down

0 comments on commit ef9c67d

Please sign in to comment.