@@ -24,7 +24,6 @@ import (
2424 . "github.com/onsi/gomega"
2525 appsv1 "k8s.io/api/apps/v1"
2626 corev1 "k8s.io/api/core/v1"
27- v1 "k8s.io/api/core/v1"
2827 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2928 "k8s.io/apimachinery/pkg/runtime"
3029 utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -93,10 +92,10 @@ func insertDummyConfig(provider genericprovider.GenericProvider) {
9392 provider .SetSpec (spec )
9493}
9594
96- func dummyConfigMap (ns , name string ) * corev1.ConfigMap {
95+ func dummyConfigMap (ns string ) * corev1.ConfigMap {
9796 return & corev1.ConfigMap {
9897 ObjectMeta : metav1.ObjectMeta {
99- Name : name ,
98+ Name : testCurrentVersion ,
10099 Namespace : ns ,
101100 Labels : map [string ]string {
102101 "test" : "dummy-config" ,
@@ -109,13 +108,15 @@ func dummyConfigMap(ns, name string) *corev1.ConfigMap {
109108 }
110109}
111110
112- func createDummyProviderWithConfigSecret (objs []client.Object , provider genericprovider.GenericProvider , configSecret * v1 .Secret ) ([]client.Object , error ) {
113- cm := dummyConfigMap (provider .GetNamespace (), testCurrentVersion )
111+ func createDummyProviderWithConfigSecret (objs []client.Object , provider genericprovider.GenericProvider , configSecret * corev1 .Secret ) ([]client.Object , error ) {
112+ cm := dummyConfigMap (provider .GetNamespace ())
114113
115114 if err := env .CreateAndWait (ctx , cm ); err != nil {
116115 return objs , err
117116 }
117+
118118 objs = append (objs , cm )
119+
119120 provider .SetSpec (operatorv1.ProviderSpec {
120121 Version : testCurrentVersion ,
121122 ConfigSecret : & operatorv1.SecretReference {
@@ -124,12 +125,16 @@ func createDummyProviderWithConfigSecret(objs []client.Object, provider genericp
124125 },
125126 ManifestPatches : []string {},
126127 })
128+
127129 insertDummyConfig (provider )
130+
128131 err := env .CreateAndWait (ctx , provider )
129132 if err != nil {
130133 return objs , err
131134 }
135+
132136 objs = append (objs , provider )
137+
133138 return objs , nil
134139}
135140
@@ -153,6 +158,7 @@ func testDeploymentLabelValueGetter(deploymentNS, deploymentName string) func()
153158func TestConfigSecretChangesAreAppliedTotheDeployment (t * testing.T ) {
154159 g := NewWithT (t )
155160 objs := []client.Object {}
161+
156162 defer func () {
157163 g .Expect (env .CleanupAndWait (ctx , objs ... )).To (Succeed ())
158164 }()
@@ -277,7 +283,7 @@ func TestReconcilerPreflightConditions(t *testing.T) {
277283 t .Log ("Ensure namespace exists" , tc .namespace )
278284 g .Expect (env .EnsureNamespaceExists (ctx , tc .namespace )).To (Succeed ())
279285
280- g .Expect (env .CreateAndWait (ctx , dummyConfigMap (tc .namespace , testCurrentVersion ))).To (Succeed ())
286+ g .Expect (env .CreateAndWait (ctx , dummyConfigMap (tc .namespace ))).To (Succeed ())
281287
282288 for _ , p := range tc .providers {
283289 insertDummyConfig (p )
@@ -566,6 +572,7 @@ func TestProviderConfigSecretChanges(t *testing.T) {
566572 t .Run (tc .name , func (t * testing.T ) {
567573 g := NewWithT (t )
568574 objs := []client.Object {}
575+
569576 defer func () {
570577 g .Expect (env .CleanupAndWait (ctx , objs ... )).To (Succeed ())
571578 }()
@@ -601,7 +608,7 @@ func TestProviderConfigSecretChanges(t *testing.T) {
601608 t .Log ("Ensure namespace exists" , configNamespace .Name )
602609 g .Expect (err ).ToNot (HaveOccurred ())
603610
604- cm := dummyConfigMap (providerNamespace .Name , testCurrentVersion )
611+ cm := dummyConfigMap (providerNamespace .Name )
605612 g .Expect (env .CreateAndWait (ctx , cm )).To (Succeed ())
606613 objs = append (objs , cm )
607614
@@ -640,16 +647,19 @@ func TestProviderConfigSecretChanges(t *testing.T) {
640647 }).Should (Succeed ())
641648
642649 var updatedDataHash string
650+
643651 if tc .expectSameHash {
644652 g .Eventually (func () string {
645653 updatedDataHash , err = calculateHash (ctx , env .Client , provider )
646654 g .Expect (err ).ToNot (HaveOccurred ())
655+
647656 return updatedDataHash
648657 }, 15 * time .Second ).Should (Equal (initialHash ))
649658 } else {
650659 g .Eventually (func () string {
651660 updatedDataHash , err = calculateHash (ctx , env .Client , provider )
652661 g .Expect (err ).ToNot (HaveOccurred ())
662+
653663 return updatedDataHash
654664 }, 15 * time .Second ).ShouldNot (Equal (initialHash ))
655665 }
@@ -789,7 +799,7 @@ func TestProviderSpecChanges(t *testing.T) {
789799 t .Log ("Ensure namespace exists" , ns .Name )
790800 g .Expect (err ).ToNot (HaveOccurred ())
791801
792- g .Expect (env .CreateAndWait (ctx , dummyConfigMap (ns .Name , testCurrentVersion ))).To (Succeed ())
802+ g .Expect (env .CreateAndWait (ctx , dummyConfigMap (ns .Name ))).To (Succeed ())
793803
794804 provider .SetNamespace (ns .Name )
795805 t .Log ("creating test provider" , provider .GetName ())
0 commit comments