@@ -30,6 +30,7 @@ import (
30
30
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31
31
"k8s.io/apimachinery/pkg/types"
32
32
33
+ "github.com/coderanger/migrations-operator/api/stubs/argoproj"
33
34
migrationsv1beta1 "github.com/coderanger/migrations-operator/api/v1beta1"
34
35
)
35
36
@@ -258,4 +259,51 @@ var _ = Describe("Migrations component", func() {
258
259
Expect (job .Spec .Template .ObjectMeta .Labels ).To (HaveKeyWithValue ("key1" , "value1" ))
259
260
Expect (job .Spec .Template .ObjectMeta .Labels ).To (HaveKeyWithValue ("migrations" , "testing" ))
260
261
})
262
+
263
+ It ("follows owner references for an argoproj.io rollout" , func () {
264
+ truep := true
265
+ rollout := & argoproj.Rollout {
266
+ ObjectMeta : metav1.ObjectMeta {Name : "testing" },
267
+ Spec : argoproj.RolloutSpec {
268
+ Template : corev1.PodTemplateSpec {
269
+ Spec : corev1.PodSpec {
270
+ Containers : []corev1.Container {
271
+ {
272
+ Name : "main" ,
273
+ Image : "myapp:v1" ,
274
+ },
275
+ },
276
+ },
277
+ },
278
+ },
279
+ }
280
+ helper .TestClient .Create (rollout )
281
+ rs := & appsv1.ReplicaSet {
282
+ ObjectMeta : metav1.ObjectMeta {
283
+ Name : "testing-1234" ,
284
+ OwnerReferences : []metav1.OwnerReference {
285
+ {
286
+ APIVersion : "argoproj.io/v1alpha1" ,
287
+ Kind : "Rollout" ,
288
+ Name : "testing" ,
289
+ Controller : & truep ,
290
+ },
291
+ },
292
+ },
293
+ }
294
+ helper .TestClient .Create (rs )
295
+ pod .OwnerReferences = []metav1.OwnerReference {
296
+ {
297
+ APIVersion : "apps/v1" ,
298
+ Kind : "ReplicaSet" ,
299
+ Name : "testing-1234" ,
300
+ Controller : & truep ,
301
+ },
302
+ }
303
+ helper .TestClient .Create (pod )
304
+
305
+ helper .MustReconcile ()
306
+ helper .TestClient .GetName ("testing-migrations" , job )
307
+ Expect (job .Spec .Template .Spec .Containers [0 ].Image ).To (Equal ("myapp:v1" ))
308
+ })
261
309
})
0 commit comments