@@ -33,11 +33,13 @@ const (
33
33
opmImage = "opm-image"
34
34
utilImage = "util-image"
35
35
bundlePath = "bundle-path"
36
+ digestPath = "bundle-path@sha256:54d626e08c1c802b305dad30b7e54a82f102390cc92c7d4db112048935236e9c"
36
37
runAsUser = 1001
37
38
)
38
39
39
40
func TestConfigMapUnpacker (t * testing.T ) {
40
41
pathHash := hash (bundlePath )
42
+ digestHash := hash (digestPath )
41
43
start := metav1 .Now ()
42
44
now := func () metav1.Time {
43
45
return start
@@ -398,18 +400,18 @@ func TestConfigMapUnpacker(t *testing.T) {
398
400
},
399
401
},
400
402
{
401
- description : "CatalogSourcePresent/ConfigMapPresent/JobPresent/Unpacked" ,
403
+ description : "CatalogSourcePresent/ConfigMapPresent/JobPresent/DigestImage/ Unpacked" ,
402
404
fields : fields {
403
405
objs : []runtime.Object {
404
406
& batchv1.Job {
405
407
ObjectMeta : metav1.ObjectMeta {
406
- Name : pathHash ,
408
+ Name : digestHash ,
407
409
Namespace : "ns-a" ,
408
410
OwnerReferences : []metav1.OwnerReference {
409
411
{
410
412
APIVersion : "v1" ,
411
413
Kind : "ConfigMap" ,
412
- Name : pathHash ,
414
+ Name : digestHash ,
413
415
Controller : & blockOwnerDeletion ,
414
416
BlockOwnerDeletion : & blockOwnerDeletion ,
415
417
},
@@ -420,7 +422,7 @@ func TestConfigMapUnpacker(t *testing.T) {
420
422
BackoffLimit : & backoffLimit ,
421
423
Template : corev1.PodTemplateSpec {
422
424
ObjectMeta : metav1.ObjectMeta {
423
- Name : pathHash ,
425
+ Name : digestHash ,
424
426
},
425
427
Spec : corev1.PodSpec {
426
428
RestartPolicy : corev1 .RestartPolicyNever ,
@@ -435,11 +437,11 @@ func TestConfigMapUnpacker(t *testing.T) {
435
437
{
436
438
Name : "extract" ,
437
439
Image : opmImage ,
438
- Command : []string {"opm" , "alpha" , "bundle" , "extract" , "-m" , "/bundle/" , "-n" , "ns-a" , "-c" , pathHash , "-z" },
440
+ Command : []string {"opm" , "alpha" , "bundle" , "extract" , "-m" , "/bundle/" , "-n" , "ns-a" , "-c" , digestHash , "-z" },
439
441
Env : []corev1.EnvVar {
440
442
{
441
443
Name : configmap .EnvContainerImage ,
442
- Value : bundlePath ,
444
+ Value : digestPath ,
443
445
},
444
446
},
445
447
VolumeMounts : []corev1.VolumeMount {
@@ -488,8 +490,8 @@ func TestConfigMapUnpacker(t *testing.T) {
488
490
},
489
491
{
490
492
Name : "pull" ,
491
- Image : bundlePath ,
492
- ImagePullPolicy : "Always " ,
493
+ Image : digestPath ,
494
+ ImagePullPolicy : "IfNotPresent " ,
493
495
Command : []string {"/util/cpb" , "/bundle" }, // Copy bundle content to its mount
494
496
VolumeMounts : []corev1.VolumeMount {
495
497
{
@@ -548,7 +550,7 @@ func TestConfigMapUnpacker(t *testing.T) {
548
550
},
549
551
& corev1.ConfigMap {
550
552
ObjectMeta : metav1.ObjectMeta {
551
- Name : pathHash ,
553
+ Name : digestHash ,
552
554
Namespace : "ns-a" ,
553
555
OwnerReferences : []metav1.OwnerReference {
554
556
{
@@ -580,7 +582,7 @@ func TestConfigMapUnpacker(t *testing.T) {
580
582
args : args {
581
583
annotationTimeout : - 1 * time .Minute ,
582
584
lookup : & operatorsv1alpha1.BundleLookup {
583
- Path : bundlePath ,
585
+ Path : digestPath ,
584
586
Replaces : "" ,
585
587
CatalogSourceRef : & corev1.ObjectReference {
586
588
Namespace : "ns-a" ,
@@ -600,14 +602,14 @@ func TestConfigMapUnpacker(t *testing.T) {
600
602
expected : expected {
601
603
res : & BundleUnpackResult {
602
604
BundleLookup : & operatorsv1alpha1.BundleLookup {
603
- Path : bundlePath ,
605
+ Path : digestPath ,
604
606
Replaces : "" ,
605
607
CatalogSourceRef : & corev1.ObjectReference {
606
608
Namespace : "ns-a" ,
607
609
Name : "src-a" ,
608
610
},
609
611
},
610
- name : pathHash ,
612
+ name : digestHash ,
611
613
bundle : & api.Bundle {
612
614
CsvName : "etcdoperator.v0.9.2" ,
613
615
CsvJson : csvJSON + "\n " ,
@@ -622,7 +624,7 @@ func TestConfigMapUnpacker(t *testing.T) {
622
624
configMaps : []* corev1.ConfigMap {
623
625
{
624
626
ObjectMeta : metav1.ObjectMeta {
625
- Name : pathHash ,
627
+ Name : digestHash ,
626
628
Namespace : "ns-a" ,
627
629
Labels : map [string ]string {install .OLMManagedLabelKey : install .OLMManagedLabelValue },
628
630
OwnerReferences : []metav1.OwnerReference {
@@ -646,13 +648,13 @@ func TestConfigMapUnpacker(t *testing.T) {
646
648
jobs : []* batchv1.Job {
647
649
{
648
650
ObjectMeta : metav1.ObjectMeta {
649
- Name : pathHash ,
651
+ Name : digestHash ,
650
652
Namespace : "ns-a" ,
651
653
OwnerReferences : []metav1.OwnerReference {
652
654
{
653
655
APIVersion : "v1" ,
654
656
Kind : "ConfigMap" ,
655
- Name : pathHash ,
657
+ Name : digestHash ,
656
658
Controller : & blockOwnerDeletion ,
657
659
BlockOwnerDeletion : & blockOwnerDeletion ,
658
660
},
@@ -663,7 +665,7 @@ func TestConfigMapUnpacker(t *testing.T) {
663
665
BackoffLimit : & backoffLimit ,
664
666
Template : corev1.PodTemplateSpec {
665
667
ObjectMeta : metav1.ObjectMeta {
666
- Name : pathHash ,
668
+ Name : digestHash ,
667
669
},
668
670
Spec : corev1.PodSpec {
669
671
RestartPolicy : corev1 .RestartPolicyNever ,
@@ -678,11 +680,11 @@ func TestConfigMapUnpacker(t *testing.T) {
678
680
{
679
681
Name : "extract" ,
680
682
Image : opmImage ,
681
- Command : []string {"opm" , "alpha" , "bundle" , "extract" , "-m" , "/bundle/" , "-n" , "ns-a" , "-c" , pathHash , "-z" },
683
+ Command : []string {"opm" , "alpha" , "bundle" , "extract" , "-m" , "/bundle/" , "-n" , "ns-a" , "-c" , digestHash , "-z" },
682
684
Env : []corev1.EnvVar {
683
685
{
684
686
Name : configmap .EnvContainerImage ,
685
- Value : bundlePath ,
687
+ Value : digestPath ,
686
688
},
687
689
},
688
690
VolumeMounts : []corev1.VolumeMount {
@@ -731,8 +733,8 @@ func TestConfigMapUnpacker(t *testing.T) {
731
733
},
732
734
{
733
735
Name : "pull" ,
734
- Image : bundlePath ,
735
- ImagePullPolicy : "Always " ,
736
+ Image : digestPath ,
737
+ ImagePullPolicy : "IfNotPresent " ,
736
738
Command : []string {"/util/cpb" , "/bundle" }, // Copy bundle content to its mount
737
739
VolumeMounts : []corev1.VolumeMount {
738
740
{
@@ -793,13 +795,13 @@ func TestConfigMapUnpacker(t *testing.T) {
793
795
roles : []* rbacv1.Role {
794
796
{
795
797
ObjectMeta : metav1.ObjectMeta {
796
- Name : pathHash ,
798
+ Name : digestHash ,
797
799
Namespace : "ns-a" ,
798
800
OwnerReferences : []metav1.OwnerReference {
799
801
{
800
802
APIVersion : "v1" ,
801
803
Kind : "ConfigMap" ,
802
- Name : pathHash ,
804
+ Name : digestHash ,
803
805
Controller : & blockOwnerDeletion ,
804
806
BlockOwnerDeletion : & blockOwnerDeletion ,
805
807
},
@@ -817,7 +819,7 @@ func TestConfigMapUnpacker(t *testing.T) {
817
819
"configmaps" ,
818
820
},
819
821
ResourceNames : []string {
820
- pathHash ,
822
+ digestHash ,
821
823
},
822
824
},
823
825
},
@@ -826,13 +828,13 @@ func TestConfigMapUnpacker(t *testing.T) {
826
828
roleBindings : []* rbacv1.RoleBinding {
827
829
{
828
830
ObjectMeta : metav1.ObjectMeta {
829
- Name : pathHash ,
831
+ Name : digestHash ,
830
832
Namespace : "ns-a" ,
831
833
OwnerReferences : []metav1.OwnerReference {
832
834
{
833
835
APIVersion : "v1" ,
834
836
Kind : "ConfigMap" ,
835
- Name : pathHash ,
837
+ Name : digestHash ,
836
838
Controller : & blockOwnerDeletion ,
837
839
BlockOwnerDeletion : & blockOwnerDeletion ,
838
840
},
@@ -849,7 +851,7 @@ func TestConfigMapUnpacker(t *testing.T) {
849
851
RoleRef : rbacv1.RoleRef {
850
852
APIGroup : "rbac.authorization.k8s.io" ,
851
853
Kind : "Role" ,
852
- Name : pathHash ,
854
+ Name : digestHash ,
853
855
},
854
856
},
855
857
},
@@ -1506,6 +1508,7 @@ func TestConfigMapUnpacker(t *testing.T) {
1506
1508
if tt .expected .res .bundle == nil {
1507
1509
require .Nil (t , res .bundle )
1508
1510
} else {
1511
+ require .NotNil (t , res .bundle )
1509
1512
require .Equal (t , tt .expected .res .bundle .CsvJson , res .bundle .CsvJson )
1510
1513
require .Equal (t , tt .expected .res .bundle .CsvName , res .bundle .CsvName )
1511
1514
require .Equal (t , tt .expected .res .bundle .Version , res .bundle .Version )
0 commit comments