From 688433d306cc3a1a71f5271e1931071e8fee537f Mon Sep 17 00:00:00 2001 From: Amanuel Engeda Date: Wed, 7 Aug 2024 16:23:11 -0700 Subject: [PATCH] fix nodeclass ref --- pkg/apis/v1/nodeclaim_conversion.go | 11 ++++------- pkg/apis/v1/nodepool_conversion.go | 11 ----------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/pkg/apis/v1/nodeclaim_conversion.go b/pkg/apis/v1/nodeclaim_conversion.go index 8c1f89349d..d724feba15 100644 --- a/pkg/apis/v1/nodeclaim_conversion.go +++ b/pkg/apis/v1/nodeclaim_conversion.go @@ -20,6 +20,7 @@ import ( "context" "encoding/json" "fmt" + "strings" "github.com/samber/lo" v1 "k8s.io/api/core/v1" @@ -140,15 +141,11 @@ func (in *NodeClaimSpec) convertFrom(ctx context.Context, v1beta1nc *v1beta1.Nod } }) - defaultNodeClassGVK := injection.GetNodeClasses(ctx)[0] - nodeclassGroupVersion, err := schema.ParseGroupVersion(v1beta1nc.NodeClassRef.APIVersion) - if err != nil { - return "", err - } + nodeclasses := injection.GetNodeClasses(ctx) in.NodeClassRef = &NodeClassReference{ Name: v1beta1nc.NodeClassRef.Name, - Kind: lo.Ternary(v1beta1nc.NodeClassRef.Kind == "", defaultNodeClassGVK.Kind, v1beta1nc.NodeClassRef.Kind), - Group: lo.Ternary(v1beta1nc.NodeClassRef.APIVersion == "", defaultNodeClassGVK.Group, nodeclassGroupVersion.Group), + Kind: lo.Ternary(v1beta1nc.NodeClassRef.Kind == "", nodeclasses[0].Kind, v1beta1nc.NodeClassRef.Kind), + Group: lo.Ternary(v1beta1nc.NodeClassRef.APIVersion == "", nodeclasses[0].Group, strings.Split(v1beta1nc.NodeClassRef.APIVersion, "/")[0]), } if v1beta1nc.Kubelet != nil { diff --git a/pkg/apis/v1/nodepool_conversion.go b/pkg/apis/v1/nodepool_conversion.go index 3d0bd47161..94c2e6cf19 100644 --- a/pkg/apis/v1/nodepool_conversion.go +++ b/pkg/apis/v1/nodepool_conversion.go @@ -181,17 +181,6 @@ func (in *NodeClaimTemplate) convertFrom(ctx context.Context, v1beta1np *v1beta1 Group: lo.Ternary(v1beta1np.Spec.NodeClassRef.APIVersion == "", nodeclasses[0].Group, strings.Split(v1beta1np.Spec.NodeClassRef.APIVersion, "/")[0]), } - defaultNodeClassGVK := injection.GetNodeClasses(ctx)[0] - nodeclassGroupVersion, err := schema.ParseGroupVersion(v1beta1np.Spec.NodeClassRef.APIVersion) - if err != nil { - return "", err - } - in.Spec.NodeClassRef = &NodeClassReference{ - Name: v1beta1np.Spec.NodeClassRef.Name, - Kind: lo.Ternary(v1beta1np.Spec.NodeClassRef.Kind == "", defaultNodeClassGVK.Kind, v1beta1np.Spec.NodeClassRef.Kind), - Group: lo.Ternary(v1beta1np.Spec.NodeClassRef.APIVersion == "", defaultNodeClassGVK.Group, nodeclassGroupVersion.Group), - } - if v1beta1np.Spec.Kubelet != nil { kubelet, err := json.Marshal(v1beta1np.Spec.Kubelet) if err != nil {