Skip to content

Commit

Permalink
Check only if Group matches
Browse files Browse the repository at this point in the history
Do not check if version matches.
  • Loading branch information
mgianluc committed Jun 24, 2024
1 parent e2d71f6 commit 702218b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/clusterproxy/cluster_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
Expand Down Expand Up @@ -217,15 +218,16 @@ func GetKubernetesClient(ctx context.Context, c client.Client,

// GetClusterType returns clustertype for a given cluster
func GetClusterType(cluster *corev1.ObjectReference) libsveltosv1beta1.ClusterType {
// TODO: remove this
if cluster.APIVersion != libsveltosv1beta1.GroupVersion.String() &&
cluster.APIVersion != clusterv1.GroupVersion.String() {
gvk := schema.FromAPIVersionAndKind(cluster.APIVersion, cluster.Kind)

if gvk.Group != libsveltosv1beta1.GroupVersion.Group &&
gvk.Group != clusterv1.GroupVersion.Group {

panic(1)
}

clusterType := libsveltosv1beta1.ClusterTypeCapi
if cluster.APIVersion == libsveltosv1beta1.GroupVersion.String() {
if gvk.Group == libsveltosv1beta1.GroupVersion.Group {
clusterType = libsveltosv1beta1.ClusterTypeSveltos
}
return clusterType
Expand Down

0 comments on commit 702218b

Please sign in to comment.