@@ -13,6 +13,7 @@ import (
1313	apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" 
1414	runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" 
1515
16+ 	eksbootstrapv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/external/sigs.k8s.io/cluster-api-provider-aws/v2/bootstrap/eks/api/v1beta2" 
1617	"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1" 
1718	"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" 
1819	"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" 
@@ -59,7 +60,7 @@ var _ = Describe("Generate taints patches for Worker", func() {
5960			}},
6061		},
6162		{
62- 			Name : "taints for workers set for EKSConfigTemplate " ,
63+ 			Name : "taints for workers set for NodeadmConfigTemplate " ,
6364			Vars : []runtimehooksv1.Variable {
6465				capitest .VariableWithValue (
6566					v1alpha1 .WorkerConfigVariableName ,
@@ -77,15 +78,88 @@ var _ = Describe("Generate taints patches for Worker", func() {
7778					},
7879				),
7980			},
80- 			RequestItem : testutils .NewEKSConfigTemplateRequestItem ("" ),
81+ 			RequestItem : testutils .NewNodeadmConfigTemplateRequestItem ("" ),
8182			ExpectedPatchMatchers : []capitest.JSONPatchMatcher {{
8283				Operation : "add" ,
83- 				Path :      "/spec/template/spec/kubeletExtraArgs " ,
84+ 				Path :      "/spec/template/spec/kubelet " ,
8485				ValueMatcher : gomega .HaveKeyWithValue (
85- 					"register-with-taints" , "key=value:NoExecute" ,
86+ 					"flags" ,
87+ 					gomega .ContainElement ("--register-with-taints=key=value:NoExecute" ),
8688				),
8789			}},
8890		},
91+ 		{
92+ 			Name : "taints for workers set for NodeadmConfigTemplate with existing flags argument" ,
93+ 			Vars : []runtimehooksv1.Variable {
94+ 				capitest .VariableWithValue (
95+ 					v1alpha1 .WorkerConfigVariableName ,
96+ 					[]v1alpha1.Taint {{
97+ 						Key :    "key" ,
98+ 						Effect : v1alpha1 .TaintEffectNoExecute ,
99+ 						Value :  "value" ,
100+ 					}},
101+ 					VariableName ,
102+ 				),
103+ 				capitest .VariableWithValue (
104+ 					"builtin" ,
105+ 					apiextensionsv1.JSON {
106+ 						Raw : []byte (`{"machineDeployment": {"class": "a-worker"}}` ),
107+ 					},
108+ 				),
109+ 			},
110+ 			RequestItem : testutils .NewNodeadmConfigTemplateRequestItem ("" , eksbootstrapv1.NodeadmConfigTemplateSpec {
111+ 				Template : eksbootstrapv1.NodeadmConfigTemplateResource {
112+ 					Spec : eksbootstrapv1.NodeadmConfigSpec {
113+ 						Kubelet : & eksbootstrapv1.KubeletOptions {
114+ 							Flags : []string {
115+ 								"--max-pods=110" ,
116+ 							},
117+ 						},
118+ 					},
119+ 				},
120+ 			}),
121+ 			ExpectedPatchMatchers : []capitest.JSONPatchMatcher {{
122+ 				Operation :    "add" ,
123+ 				Path :         "/spec/template/spec/kubelet/flags/1" ,
124+ 				ValueMatcher : gomega .Equal ("--register-with-taints=key=value:NoExecute" ),
125+ 			}},
126+ 		},
127+ 		{
128+ 			Name : "taints for workers set for NodeadmConfigTemplate with existing flags with register-with-taints " ,
129+ 			Vars : []runtimehooksv1.Variable {
130+ 				capitest .VariableWithValue (
131+ 					v1alpha1 .WorkerConfigVariableName ,
132+ 					[]v1alpha1.Taint {{
133+ 						Key :    "key" ,
134+ 						Effect : v1alpha1 .TaintEffectNoExecute ,
135+ 						Value :  "value" ,
136+ 					}},
137+ 					VariableName ,
138+ 				),
139+ 				capitest .VariableWithValue (
140+ 					"builtin" ,
141+ 					apiextensionsv1.JSON {
142+ 						Raw : []byte (`{"machineDeployment": {"class": "a-worker"}}` ),
143+ 					},
144+ 				),
145+ 			},
146+ 			RequestItem : testutils .NewNodeadmConfigTemplateRequestItem ("" , eksbootstrapv1.NodeadmConfigTemplateSpec {
147+ 				Template : eksbootstrapv1.NodeadmConfigTemplateResource {
148+ 					Spec : eksbootstrapv1.NodeadmConfigSpec {
149+ 						Kubelet : & eksbootstrapv1.KubeletOptions {
150+ 							Flags : []string {
151+ 								"--register-with-taints=key1=value1:NoSchedule" ,
152+ 							},
153+ 						},
154+ 					},
155+ 				},
156+ 			}),
157+ 			ExpectedPatchMatchers : []capitest.JSONPatchMatcher {{
158+ 				Operation :    "add" ,
159+ 				Path :         "/spec/template/spec/kubelet/flags/1" ,
160+ 				ValueMatcher : gomega .Equal ("--register-with-taints=key=value:NoExecute" ),
161+ 			}},
162+ 		},
89163	}
90164
91165	// create test node for each case 
0 commit comments