@@ -56,6 +56,18 @@ var _ = Describe("reconcile seed image", func() {
5656 Name : "test-name" ,
5757 Namespace : "default" ,
5858 },
59+ Status : elementalv1.MachineRegistrationStatus {
60+ RegistrationURL : "https://example.com/token" ,
61+ RegistrationToken : "token" ,
62+ Conditions : []metav1.Condition {
63+ {
64+ Type : elementalv1 .ReadyCondition ,
65+ Reason : elementalv1 .SuccessfullyCreatedReason ,
66+ Status : metav1 .ConditionTrue ,
67+ LastTransitionTime : metav1 .Now (),
68+ },
69+ },
70+ },
5971 }
6072
6173 seedImg = & elementalv1.SeedImage {
@@ -93,9 +105,15 @@ var _ = Describe("reconcile seed image", func() {
93105 },
94106 }
95107
108+ statusCopy := mRegistration .Status .DeepCopy ()
109+
96110 Expect (cl .Create (ctx , mRegistration )).To (Succeed ())
97111 Expect (cl .Create (ctx , seedImg )).To (Succeed ())
98112 Expect (cl .Create (ctx , setting )).To (Succeed ())
113+
114+ patchBase := client .MergeFrom (mRegistration .DeepCopy ())
115+ mRegistration .Status = * statusCopy
116+ Expect (cl .Status ().Patch (ctx , mRegistration , patchBase )).To (Succeed ())
99117 })
100118
101119 AfterEach (func () {
@@ -160,6 +178,7 @@ var _ = Describe("reconcile seed image", func() {
160178
161179var _ = Describe ("reconcileBuildImagePod" , func () {
162180 var r * SeedImageReconciler
181+ var setting * managementv3.Setting
163182 var mRegistration * elementalv1.MachineRegistration
164183 var seedImg * elementalv1.SeedImage
165184 var pod * corev1.Pod
@@ -177,6 +196,18 @@ var _ = Describe("reconcileBuildImagePod", func() {
177196 Name : "test-name" ,
178197 Namespace : "default" ,
179198 },
199+ Status : elementalv1.MachineRegistrationStatus {
200+ RegistrationURL : "https://example.com/token" ,
201+ RegistrationToken : "token" ,
202+ Conditions : []metav1.Condition {
203+ {
204+ Type : elementalv1 .ReadyCondition ,
205+ Reason : elementalv1 .SuccessfullyCreatedReason ,
206+ Status : metav1 .ConditionTrue ,
207+ LastTransitionTime : metav1 .Now (),
208+ },
209+ },
210+ },
180211 }
181212
182213 seedImg = & elementalv1.SeedImage {
@@ -207,12 +238,26 @@ var _ = Describe("reconcileBuildImagePod", func() {
207238 },
208239 }
209240
241+ setting = & managementv3.Setting {
242+ ObjectMeta : metav1.ObjectMeta {
243+ Name : "server-url" ,
244+ },
245+ Value : "https://example.com" ,
246+ }
247+
248+ statusCopy := mRegistration .Status .DeepCopy ()
249+
210250 Expect (cl .Create (ctx , mRegistration )).To (Succeed ())
211251 Expect (cl .Create (ctx , seedImg )).To (Succeed ())
252+ Expect (cl .Create (ctx , setting )).To (Succeed ())
253+
254+ patchBase := client .MergeFrom (mRegistration .DeepCopy ())
255+ mRegistration .Status = * statusCopy
256+ Expect (cl .Status ().Patch (ctx , mRegistration , patchBase )).To (Succeed ())
212257 })
213258
214259 AfterEach (func () {
215- Expect (test .CleanupAndWait (ctx , cl , mRegistration , seedImg , pod , svc )).To (Succeed ())
260+ Expect (test .CleanupAndWait (ctx , cl , mRegistration , setting , seedImg , pod , svc )).To (Succeed ())
216261 })
217262
218263 It ("should return error when a pod with the same name but different owner is there" , func () {
@@ -225,7 +270,7 @@ var _ = Describe("reconcileBuildImagePod", func() {
225270
226271 Expect (cl .Create (ctx , pod )).To (Succeed ())
227272
228- err := r .reconcileBuildImagePod (ctx , seedImg , & elementalv1. MachineRegistration {} )
273+ err := r .reconcileBuildImagePod (ctx , seedImg , mRegistration )
229274
230275 // Pod already there and not owned by the SeedImage obj
231276 Expect (err ).To (HaveOccurred ())
@@ -276,7 +321,8 @@ var _ = Describe("reconcileBuildImagePod", func() {
276321 Expect (foundPod .Annotations ["elemental.cattle.io/base-image" ]).To (Equal (seedImg .Spec .BaseImage ))
277322
278323 seedImg .Spec .BaseImage = "https://example.com/new-base.iso"
279- err = r .reconcileBuildImagePod (ctx , seedImg , & elementalv1.MachineRegistration {})
324+
325+ err = r .reconcileBuildImagePod (ctx , seedImg , mRegistration )
280326 Expect (err ).ToNot (HaveOccurred ())
281327 Expect (cl .Get (ctx , client.ObjectKey {
282328 Name : seedImg .Name ,
@@ -309,7 +355,7 @@ var _ = Describe("reconcileBuildImagePod", func() {
309355 "write_files" : {},
310356 }
311357
312- err = r .reconcileBuildImagePod (ctx , seedImg , & elementalv1. MachineRegistration {} )
358+ err = r .reconcileBuildImagePod (ctx , seedImg , mRegistration )
313359 Expect (err ).ToNot (HaveOccurred ())
314360 Expect (cl .Get (ctx , client.ObjectKey {
315361 Name : seedImg .Name ,
@@ -320,6 +366,7 @@ var _ = Describe("reconcileBuildImagePod", func() {
320366
321367var _ = Describe ("createConfigMapObject" , func () {
322368 var r * SeedImageReconciler
369+ var setting * managementv3.Setting
323370 var mRegistration * elementalv1.MachineRegistration
324371 var seedImg * elementalv1.SeedImage
325372 var configMap * corev1.ConfigMap
@@ -338,6 +385,18 @@ var _ = Describe("createConfigMapObject", func() {
338385 Name : "test-name" ,
339386 Namespace : "default" ,
340387 },
388+ Status : elementalv1.MachineRegistrationStatus {
389+ RegistrationURL : "https://example.com/token" ,
390+ RegistrationToken : "token" ,
391+ Conditions : []metav1.Condition {
392+ {
393+ Type : elementalv1 .ReadyCondition ,
394+ Reason : elementalv1 .SuccessfullyCreatedReason ,
395+ Status : metav1 .ConditionTrue ,
396+ LastTransitionTime : metav1 .Now (),
397+ },
398+ },
399+ },
341400 }
342401
343402 seedImg = & elementalv1.SeedImage {
@@ -373,12 +432,26 @@ var _ = Describe("createConfigMapObject", func() {
373432 },
374433 }
375434
435+ setting = & managementv3.Setting {
436+ ObjectMeta : metav1.ObjectMeta {
437+ Name : "server-url" ,
438+ },
439+ Value : "https://example.com" ,
440+ }
441+
442+ statusCopy := mRegistration .Status .DeepCopy ()
443+
376444 Expect (cl .Create (ctx , mRegistration )).To (Succeed ())
377445 Expect (cl .Create (ctx , seedImg )).To (Succeed ())
446+ Expect (cl .Create (ctx , setting )).To (Succeed ())
447+
448+ patchBase := client .MergeFrom (mRegistration .DeepCopy ())
449+ mRegistration .Status = * statusCopy
450+ Expect (cl .Status ().Patch (ctx , mRegistration , patchBase )).To (Succeed ())
378451 })
379452
380453 AfterEach (func () {
381- Expect (test .CleanupAndWait (ctx , cl , mRegistration , seedImg , configMap , pod , svc )).To (Succeed ())
454+ Expect (test .CleanupAndWait (ctx , cl , mRegistration , seedImg , setting , configMap , pod , svc )).To (Succeed ())
382455 })
383456
384457 It ("should create a configmap with empty cloud-config data" , func () {
0 commit comments