@@ -265,6 +265,26 @@ func ds(namespace, name string, containerImages ...string) kapisext.DaemonSet {
265
265
}
266
266
}
267
267
268
+ func deploymentList (deployments ... kapisext.Deployment ) kapisext.DeploymentList {
269
+ return kapisext.DeploymentList {
270
+ Items : deployments ,
271
+ }
272
+ }
273
+
274
+ func deployment (namespace , name string , containerImages ... string ) kapisext.Deployment {
275
+ return kapisext.Deployment {
276
+ ObjectMeta : metav1.ObjectMeta {
277
+ Namespace : namespace ,
278
+ Name : name ,
279
+ },
280
+ Spec : kapisext.DeploymentSpec {
281
+ Template : kapi.PodTemplateSpec {
282
+ Spec : podSpec (containerImages ... ),
283
+ },
284
+ },
285
+ }
286
+ }
287
+
268
288
func dcList (dcs ... deployapi.DeploymentConfig ) deployapi.DeploymentConfigList {
269
289
return deployapi.DeploymentConfigList {
270
290
Items : dcs ,
@@ -501,6 +521,7 @@ func TestImagePruning(t *testing.T) {
501
521
bcs buildapi.BuildConfigList
502
522
builds buildapi.BuildList
503
523
dss kapisext.DaemonSetList
524
+ deployments kapisext.DeploymentList
504
525
dcs deployapi.DeploymentConfigList
505
526
limits map [string ][]* kapi.LimitRange
506
527
expectedImageDeletions []string
@@ -665,6 +686,15 @@ func TestImagePruning(t *testing.T) {
665
686
expectedImageDeletions : []string {"sha256:0000000000000000000000000000000000000000000000000000000000000001" },
666
687
},
667
688
689
+ "referenced by upstream deployment - don't prune" : {
690
+ images : imageList (
691
+ image ("sha256:0000000000000000000000000000000000000000000000000000000000000000" , registryHost + "/foo/bar@sha256:0000000000000000000000000000000000000000000000000000000000000000" ),
692
+ image ("sha256:0000000000000000000000000000000000000000000000000000000000000001" , registryHost + "/foo/bar@sha256:0000000000000000000000000000000000000000000000000000000000000001" ),
693
+ ),
694
+ deployments : deploymentList (deployment ("foo" , "rc1" , registryHost + "/foo/bar@sha256:0000000000000000000000000000000000000000000000000000000000000000" )),
695
+ expectedImageDeletions : []string {"sha256:0000000000000000000000000000000000000000000000000000000000000001" },
696
+ },
697
+
668
698
"referenced by bc - sti - ImageStreamImage - don't prune" : {
669
699
images : imageList (image ("sha256:0000000000000000000000000000000000000000000000000000000000000000" , registryHost + "/foo/bar@sha256:0000000000000000000000000000000000000000000000000000000000000000" )),
670
700
bcs : bcList (bc ("foo" , "bc1" , "source" , "ImageStreamImage" , "foo" , "bar@sha256:0000000000000000000000000000000000000000000000000000000000000000" )),
@@ -1175,6 +1205,7 @@ func TestImagePruning(t *testing.T) {
1175
1205
BCs : & test .bcs ,
1176
1206
Builds : & test .builds ,
1177
1207
DSs : & test .dss ,
1208
+ Deployments : & test .deployments ,
1178
1209
DCs : & test .dcs ,
1179
1210
LimitRanges : test .limits ,
1180
1211
RegistryURL : & url.URL {Scheme : "https" , Host : registryHost },
@@ -1422,6 +1453,7 @@ func TestRegistryPruning(t *testing.T) {
1422
1453
BCs : & buildapi.BuildConfigList {},
1423
1454
Builds : & buildapi.BuildList {},
1424
1455
DSs : & kapisext.DaemonSetList {},
1456
+ Deployments : & kapisext.DeploymentList {},
1425
1457
DCs : & deployapi.DeploymentConfigList {},
1426
1458
RegistryURL : & url.URL {Scheme : "https" , Host : "registry1.io" },
1427
1459
}
@@ -1481,17 +1513,19 @@ func TestImageWithStrongAndWeakRefsIsNotPruned(t *testing.T) {
1481
1513
bcs := bcList ()
1482
1514
builds := buildList ()
1483
1515
dss := dsList ()
1516
+ deployments := deploymentList ()
1484
1517
dcs := dcList ()
1485
1518
1486
1519
options := PrunerOptions {
1487
- Images : & images ,
1488
- Streams : & streams ,
1489
- Pods : & pods ,
1490
- RCs : & rcs ,
1491
- BCs : & bcs ,
1492
- Builds : & builds ,
1493
- DSs : & dss ,
1494
- DCs : & dcs ,
1520
+ Images : & images ,
1521
+ Streams : & streams ,
1522
+ Pods : & pods ,
1523
+ RCs : & rcs ,
1524
+ BCs : & bcs ,
1525
+ Builds : & builds ,
1526
+ DSs : & dss ,
1527
+ Deployments : & deployments ,
1528
+ DCs : & dcs ,
1495
1529
}
1496
1530
keepYoungerThan := 24 * time .Hour
1497
1531
keepTagRevisions := 2
0 commit comments