@@ -203,6 +203,71 @@ var _ = Describe("Generate CoreDNS patches", func() {
203203 },
204204 },
205205 },
206+ {
207+ patchTest : capitest.PatchTestDef {
208+ Name : "error if cannot find default CoreDNS version" ,
209+ RequestItem : request .NewKubeadmControlPlaneTemplateRequestItem ("" ),
210+ ExpectedFailure : true ,
211+ },
212+ cluster : clusterv1.Cluster {
213+ ObjectMeta : metav1.ObjectMeta {
214+ Name : "test-cluster" ,
215+ Namespace : request .Namespace ,
216+ Labels : map [string ]string {
217+ clusterv1 .ProviderNameLabel : "nutanix" ,
218+ },
219+ },
220+ Spec : clusterv1.ClusterSpec {
221+ Topology : & clusterv1.Topology {
222+ Version : "1.100.100" ,
223+ },
224+ },
225+ },
226+ },
227+ {
228+ patchTest : capitest.PatchTestDef {
229+ Name : "no error if cannot find default CoreDNS version but variable is set" ,
230+ Vars : []runtimehooksv1.Variable {
231+ capitest .VariableWithValue (
232+ v1alpha1 .ClusterConfigVariableName ,
233+ v1alpha1.CoreDNS {
234+ Image : & v1alpha1.Image {
235+ Repository : "my-registry.io/my-org/my-repo" ,
236+ Tag : "v1.11.3_custom.0" ,
237+ },
238+ },
239+ v1alpha1 .DNSVariableName ,
240+ VariableName ,
241+ ),
242+ },
243+ RequestItem : request .NewKubeadmControlPlaneTemplateRequestItem ("" ),
244+ ExpectedPatchMatchers : []capitest.JSONPatchMatcher {{
245+ Operation : "add" ,
246+ Path : "/spec/template/spec/kubeadmConfigSpec/clusterConfiguration" ,
247+ ValueMatcher : gomega .HaveKeyWithValue (
248+ "dns" ,
249+ map [string ]interface {}{
250+ "imageRepository" : "my-registry.io/my-org/my-repo" ,
251+ "imageTag" : "v1.11.3_custom.0" ,
252+ },
253+ ),
254+ }},
255+ },
256+ cluster : clusterv1.Cluster {
257+ ObjectMeta : metav1.ObjectMeta {
258+ Name : "test-cluster" ,
259+ Namespace : request .Namespace ,
260+ Labels : map [string ]string {
261+ clusterv1 .ProviderNameLabel : "nutanix" ,
262+ },
263+ },
264+ Spec : clusterv1.ClusterSpec {
265+ Topology : & clusterv1.Topology {
266+ Version : "1.100.100" ,
267+ },
268+ },
269+ },
270+ },
206271 }
207272
208273 // create test node for each case
0 commit comments