Skip to content

Commit

Permalink
Add openshift detector
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Oct 1, 2023
1 parent 34f0993 commit f45559b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cluster/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ func DetectClusterManager(kc client.Client) kmapi.ClusterManager {
if IsRancherManaged(kc.RESTMapper()) {
result |= kmapi.ClusterManagerRancher
}
//if IsRancherManaged(kc.RESTMapper()) {
// result |= kmapi.ClusterManagerRancher
//}
if IsOpenShiftManaged(kc.RESTMapper()) {
result |= kmapi.ClusterManagerOpenShift
}
if MustIsVirtualCluster(kc) {
result |= kmapi.ClusterManagerVirtualCluster
}
Expand Down
32 changes: 32 additions & 0 deletions cluster/openshift.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright AppsCode Inc. and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package cluster

import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime/schema"
)

func IsOpenShiftManaged(mapper meta.RESTMapper) bool {
if _, err := mapper.RESTMappings(schema.GroupKind{
Group: "project.openshift.io",
Kind: "Project",
}); err == nil {
return true
}
return false
}

0 comments on commit f45559b

Please sign in to comment.