@@ -33,11 +33,13 @@ const (
3333 opmImage = "opm-image"
3434 utilImage = "util-image"
3535 bundlePath = "bundle-path"
36+ digestPath = "bundle-path@sha256:54d626e08c1c802b305dad30b7e54a82f102390cc92c7d4db112048935236e9c"
3637 runAsUser = 1001
3738)
3839
3940func TestConfigMapUnpacker (t * testing.T ) {
4041 pathHash := hash (bundlePath )
42+ digestHash := hash (digestPath )
4143 start := metav1 .Now ()
4244 now := func () metav1.Time {
4345 return start
@@ -398,18 +400,18 @@ func TestConfigMapUnpacker(t *testing.T) {
398400 },
399401 },
400402 {
401- description : "CatalogSourcePresent/ConfigMapPresent/JobPresent/Unpacked" ,
403+ description : "CatalogSourcePresent/ConfigMapPresent/JobPresent/DigestImage/ Unpacked" ,
402404 fields : fields {
403405 objs : []runtime.Object {
404406 & batchv1.Job {
405407 ObjectMeta : metav1.ObjectMeta {
406- Name : pathHash ,
408+ Name : digestHash ,
407409 Namespace : "ns-a" ,
408410 OwnerReferences : []metav1.OwnerReference {
409411 {
410412 APIVersion : "v1" ,
411413 Kind : "ConfigMap" ,
412- Name : pathHash ,
414+ Name : digestHash ,
413415 Controller : & blockOwnerDeletion ,
414416 BlockOwnerDeletion : & blockOwnerDeletion ,
415417 },
@@ -420,7 +422,7 @@ func TestConfigMapUnpacker(t *testing.T) {
420422 BackoffLimit : & backoffLimit ,
421423 Template : corev1.PodTemplateSpec {
422424 ObjectMeta : metav1.ObjectMeta {
423- Name : pathHash ,
425+ Name : digestHash ,
424426 },
425427 Spec : corev1.PodSpec {
426428 RestartPolicy : corev1 .RestartPolicyNever ,
@@ -435,11 +437,11 @@ func TestConfigMapUnpacker(t *testing.T) {
435437 {
436438 Name : "extract" ,
437439 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" },
439441 Env : []corev1.EnvVar {
440442 {
441443 Name : configmap .EnvContainerImage ,
442- Value : bundlePath ,
444+ Value : digestPath ,
443445 },
444446 },
445447 VolumeMounts : []corev1.VolumeMount {
@@ -488,8 +490,8 @@ func TestConfigMapUnpacker(t *testing.T) {
488490 },
489491 {
490492 Name : "pull" ,
491- Image : bundlePath ,
492- ImagePullPolicy : "Always " ,
493+ Image : digestPath ,
494+ ImagePullPolicy : "IfNotPresent " ,
493495 Command : []string {"/util/cpb" , "/bundle" }, // Copy bundle content to its mount
494496 VolumeMounts : []corev1.VolumeMount {
495497 {
@@ -548,7 +550,7 @@ func TestConfigMapUnpacker(t *testing.T) {
548550 },
549551 & corev1.ConfigMap {
550552 ObjectMeta : metav1.ObjectMeta {
551- Name : pathHash ,
553+ Name : digestHash ,
552554 Namespace : "ns-a" ,
553555 OwnerReferences : []metav1.OwnerReference {
554556 {
@@ -580,7 +582,7 @@ func TestConfigMapUnpacker(t *testing.T) {
580582 args : args {
581583 annotationTimeout : - 1 * time .Minute ,
582584 lookup : & operatorsv1alpha1.BundleLookup {
583- Path : bundlePath ,
585+ Path : digestPath ,
584586 Replaces : "" ,
585587 CatalogSourceRef : & corev1.ObjectReference {
586588 Namespace : "ns-a" ,
@@ -600,14 +602,14 @@ func TestConfigMapUnpacker(t *testing.T) {
600602 expected : expected {
601603 res : & BundleUnpackResult {
602604 BundleLookup : & operatorsv1alpha1.BundleLookup {
603- Path : bundlePath ,
605+ Path : digestPath ,
604606 Replaces : "" ,
605607 CatalogSourceRef : & corev1.ObjectReference {
606608 Namespace : "ns-a" ,
607609 Name : "src-a" ,
608610 },
609611 },
610- name : pathHash ,
612+ name : digestHash ,
611613 bundle : & api.Bundle {
612614 CsvName : "etcdoperator.v0.9.2" ,
613615 CsvJson : csvJSON + "\n " ,
@@ -622,7 +624,7 @@ func TestConfigMapUnpacker(t *testing.T) {
622624 configMaps : []* corev1.ConfigMap {
623625 {
624626 ObjectMeta : metav1.ObjectMeta {
625- Name : pathHash ,
627+ Name : digestHash ,
626628 Namespace : "ns-a" ,
627629 Labels : map [string ]string {install .OLMManagedLabelKey : install .OLMManagedLabelValue },
628630 OwnerReferences : []metav1.OwnerReference {
@@ -646,13 +648,13 @@ func TestConfigMapUnpacker(t *testing.T) {
646648 jobs : []* batchv1.Job {
647649 {
648650 ObjectMeta : metav1.ObjectMeta {
649- Name : pathHash ,
651+ Name : digestHash ,
650652 Namespace : "ns-a" ,
651653 OwnerReferences : []metav1.OwnerReference {
652654 {
653655 APIVersion : "v1" ,
654656 Kind : "ConfigMap" ,
655- Name : pathHash ,
657+ Name : digestHash ,
656658 Controller : & blockOwnerDeletion ,
657659 BlockOwnerDeletion : & blockOwnerDeletion ,
658660 },
@@ -663,7 +665,7 @@ func TestConfigMapUnpacker(t *testing.T) {
663665 BackoffLimit : & backoffLimit ,
664666 Template : corev1.PodTemplateSpec {
665667 ObjectMeta : metav1.ObjectMeta {
666- Name : pathHash ,
668+ Name : digestHash ,
667669 },
668670 Spec : corev1.PodSpec {
669671 RestartPolicy : corev1 .RestartPolicyNever ,
@@ -678,11 +680,11 @@ func TestConfigMapUnpacker(t *testing.T) {
678680 {
679681 Name : "extract" ,
680682 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" },
682684 Env : []corev1.EnvVar {
683685 {
684686 Name : configmap .EnvContainerImage ,
685- Value : bundlePath ,
687+ Value : digestPath ,
686688 },
687689 },
688690 VolumeMounts : []corev1.VolumeMount {
@@ -731,8 +733,8 @@ func TestConfigMapUnpacker(t *testing.T) {
731733 },
732734 {
733735 Name : "pull" ,
734- Image : bundlePath ,
735- ImagePullPolicy : "Always " ,
736+ Image : digestPath ,
737+ ImagePullPolicy : "IfNotPresent " ,
736738 Command : []string {"/util/cpb" , "/bundle" }, // Copy bundle content to its mount
737739 VolumeMounts : []corev1.VolumeMount {
738740 {
@@ -793,13 +795,13 @@ func TestConfigMapUnpacker(t *testing.T) {
793795 roles : []* rbacv1.Role {
794796 {
795797 ObjectMeta : metav1.ObjectMeta {
796- Name : pathHash ,
798+ Name : digestHash ,
797799 Namespace : "ns-a" ,
798800 OwnerReferences : []metav1.OwnerReference {
799801 {
800802 APIVersion : "v1" ,
801803 Kind : "ConfigMap" ,
802- Name : pathHash ,
804+ Name : digestHash ,
803805 Controller : & blockOwnerDeletion ,
804806 BlockOwnerDeletion : & blockOwnerDeletion ,
805807 },
@@ -817,7 +819,7 @@ func TestConfigMapUnpacker(t *testing.T) {
817819 "configmaps" ,
818820 },
819821 ResourceNames : []string {
820- pathHash ,
822+ digestHash ,
821823 },
822824 },
823825 },
@@ -826,13 +828,13 @@ func TestConfigMapUnpacker(t *testing.T) {
826828 roleBindings : []* rbacv1.RoleBinding {
827829 {
828830 ObjectMeta : metav1.ObjectMeta {
829- Name : pathHash ,
831+ Name : digestHash ,
830832 Namespace : "ns-a" ,
831833 OwnerReferences : []metav1.OwnerReference {
832834 {
833835 APIVersion : "v1" ,
834836 Kind : "ConfigMap" ,
835- Name : pathHash ,
837+ Name : digestHash ,
836838 Controller : & blockOwnerDeletion ,
837839 BlockOwnerDeletion : & blockOwnerDeletion ,
838840 },
@@ -849,7 +851,7 @@ func TestConfigMapUnpacker(t *testing.T) {
849851 RoleRef : rbacv1.RoleRef {
850852 APIGroup : "rbac.authorization.k8s.io" ,
851853 Kind : "Role" ,
852- Name : pathHash ,
854+ Name : digestHash ,
853855 },
854856 },
855857 },
@@ -1506,6 +1508,7 @@ func TestConfigMapUnpacker(t *testing.T) {
15061508 if tt .expected .res .bundle == nil {
15071509 require .Nil (t , res .bundle )
15081510 } else {
1511+ require .NotNil (t , res .bundle )
15091512 require .Equal (t , tt .expected .res .bundle .CsvJson , res .bundle .CsvJson )
15101513 require .Equal (t , tt .expected .res .bundle .CsvName , res .bundle .CsvName )
15111514 require .Equal (t , tt .expected .res .bundle .Version , res .bundle .Version )
0 commit comments