Skip to content

Commit e7d67b7

Browse files
committed
Update istio-csr e2e: enable tech-preview feature addon
by patching Subscription object Signed-off-by: Swarup Ghosh <swghosh@redhat.com>
1 parent c49fd4e commit e7d67b7

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

test/e2e/certificates_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ var _ = Describe("ACME Certificate", Ordered, func() {
205205
Expect(err).NotTo(HaveOccurred())
206206

207207
By("setting cloud credential secret name in subscription object")
208-
credentialSecret := "aws-creds"
209-
err = patchSubscriptionWithCloudCredential(ctx, loader, credentialSecret)
208+
err = patchSubscriptionWithEnvVars(ctx, loader, map[string]string{
209+
"CLOUD_CREDENTIALS_SECRET_NAME": "aws-creds",
210+
})
210211
Expect(err).NotTo(HaveOccurred())
211212

212213
By("getting AWS zone from Infrastructure object")
@@ -297,8 +298,9 @@ var _ = Describe("ACME Certificate", Ordered, func() {
297298
Expect(err).NotTo(HaveOccurred())
298299

299300
By("setting cloud credential secret name in subscription object")
300-
credentialSecret := "aws-creds"
301-
err = patchSubscriptionWithCloudCredential(ctx, loader, credentialSecret)
301+
err = patchSubscriptionWithEnvVars(ctx, loader, map[string]string{
302+
"CLOUD_CREDENTIALS_SECRET_NAME": "aws-creds",
303+
})
302304
Expect(err).NotTo(HaveOccurred())
303305

304306
By("getting AWS zone from Infrastructure object")
@@ -496,7 +498,9 @@ var _ = Describe("ACME Certificate", Ordered, func() {
496498
Expect(err).NotTo(HaveOccurred())
497499

498500
By("Configure cert-manager to use credential, setting this credential secret name in subscription object")
499-
err = patchSubscriptionWithCloudCredential(ctx, loader, credentialSecret)
501+
err = patchSubscriptionWithEnvVars(ctx, loader, map[string]string{
502+
"CLOUD_CREDENTIALS_SECRET_NAME": credentialSecret,
503+
})
500504
Expect(err).NotTo(HaveOccurred())
501505

502506
By("Getting GCP project ID from Infrastructure object")

test/e2e/istio_csr_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ var _ = Describe("Istio-CSR", Ordered, Label("TechPreview", "Feature:IstioCSR"),
4646

4747
dynamicClient, err = dynamic.NewForConfig(cfg)
4848
Expect(err).Should(BeNil())
49+
50+
By("enable IstioCSR addon feature by patching subscription object")
51+
err = patchSubscriptionWithEnvVars(ctx, loader, map[string]string{
52+
"UNSUPPORTED_ADDON_FEATURES": "IstioCSR=true",
53+
})
54+
Expect(err).NotTo(HaveOccurred())
4955
})
5056

5157
var ns *corev1.Namespace

test/e2e/utils_test.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -400,24 +400,28 @@ func getCertManagerOperatorSubscription(ctx context.Context, loader library.Dyna
400400
return subName, nil
401401
}
402402

403-
// patchSubscriptionWithCloudCredential uses the k8s dynamic client to patche the only Subscription object
404-
// in the cert-manager-operator namespace to inject CLOUD_CREDENTIALS_SECRET_NAME="aws-creds" env
405-
// into its spec.config.env
406-
func patchSubscriptionWithCloudCredential(ctx context.Context, loader library.DynamicResourceLoader, credentialSecret string) error {
403+
// patchSubscriptionWithEnvVars uses the k8s dynamic client to patch the only Subscription object
404+
// in the cert-manager-operator namespace, inject specified env vars into spec.config.env
405+
func patchSubscriptionWithEnvVars(ctx context.Context, loader library.DynamicResourceLoader, envVars map[string]string) error {
407406
subName, err := getCertManagerOperatorSubscription(ctx, loader)
408407
if err != nil {
409408
return err
410409
}
411410

411+
env := make([]interface{}, len(envVars))
412+
i := 0
413+
for k, v := range envVars {
414+
env[i] = map[string]interface{}{
415+
"name": k,
416+
"value": v,
417+
}
418+
i++
419+
}
420+
412421
patch := map[string]interface{}{
413422
"spec": map[string]interface{}{
414423
"config": map[string]interface{}{
415-
"env": []interface{}{
416-
map[string]interface{}{
417-
"name": "CLOUD_CREDENTIALS_SECRET_NAME",
418-
"value": credentialSecret,
419-
},
420-
},
424+
"env": env,
421425
},
422426
},
423427
}

0 commit comments

Comments
 (0)