From fa30407d5fec0e448f5da623e1edd12ef8a26403 Mon Sep 17 00:00:00 2001 From: Miciah Masters Date: Mon, 1 Nov 2021 22:24:08 -0400 Subject: [PATCH] test/e2e: updateDNSConfig: Replace integer literals Follow-up to commit fe8c1ee814a5d1c361461ab39b49543ba61666f1. * test/e2e/dns_ingressdegrade_test.go (updateDNSConfig): Replace integer literals with len(injectError). Change injectError to a const. --- test/e2e/dns_ingressdegrade_test.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/e2e/dns_ingressdegrade_test.go b/test/e2e/dns_ingressdegrade_test.go index 5a9f9db3b6..e0cffa4ae0 100644 --- a/test/e2e/dns_ingressdegrade_test.go +++ b/test/e2e/dns_ingressdegrade_test.go @@ -78,25 +78,27 @@ func TestIngressStatus(t *testing.T) { } } -// updateDNSConfig - utility to set/unset PrivateZone Tags/ID +// updateDNSConfig sets an invalid Tag or ID for the cluster DNS config's +// PrivateZone if the set argument is true and reverts the DNS config back to +// its original setting if the set argument is false. func updateDNSConfig(set bool, dnsConfig *configv1.DNS) { - // Azure privateZone uses "/" notation the original error- prefix did not cause the privateZone to fail - // Tested on AWS and GCP - injectError := "/error" + // Tested on Azure, AWS, and GCP. Azure privateZone uses "/" notation, + // so prepending "error-" without "/" does not cause a failure on Azure. + const injectError = "/error" if dnsConfig.Spec.PrivateZone.ID != "" { if set { dnsConfig.Spec.PrivateZone.ID = injectError + dnsConfig.Spec.PrivateZone.ID } else { - // remove injectError from prefix - dnsConfig.Spec.PrivateZone.ID = dnsConfig.Spec.PrivateZone.ID[6:] + // Remove injectError from prefix. + dnsConfig.Spec.PrivateZone.ID = dnsConfig.Spec.PrivateZone.ID[len(injectError):] } } if dnsConfig.Spec.PrivateZone.Tags["Name"] != "" { if set { dnsConfig.Spec.PrivateZone.Tags["Name"] = injectError + dnsConfig.Spec.PrivateZone.Tags["Name"] } else { - // remove injectError from prefix - dnsConfig.Spec.PrivateZone.Tags["Name"] = dnsConfig.Spec.PrivateZone.Tags["Name"][6:] + // Remove injectError from prefix. + dnsConfig.Spec.PrivateZone.Tags["Name"] = dnsConfig.Spec.PrivateZone.Tags["Name"][len(injectError):] } } }