From 2f23546818ab98a991513c3228501ce4e61a6ef6 Mon Sep 17 00:00:00 2001 From: Tom Hadlaw Date: Tue, 30 Jul 2024 09:40:40 -0700 Subject: [PATCH] test: single quote all --set parameters. Currently the ginkgo test runner program would quote the --set devices='{eth0,...}' parameter to safely pass the devices array. This also works if you single quote the whole kv pair, i.e.: --set 'devices={eth0, eth1}' Similarily, trying to do a helm override with a curly bracket array requires that the kv is single quoted. So instead of having a special case for the devices array, we will just single quote all helm parameters which shouldn't change anything for all other existing --set params. Signed-off-by: Tom Hadlaw --- test/helpers/kubectl.go | 14 +++++++++++--- test/k8s/hubble.go | 2 +- test/k8s/updates.go | 14 +++++++------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/test/helpers/kubectl.go b/test/helpers/kubectl.go index c9913751acfb9..c89bd0bc19fa4 100644 --- a/test/helpers/kubectl.go +++ b/test/helpers/kubectl.go @@ -2616,7 +2616,7 @@ func (kub *Kubectl) overwriteHelmOptions(options map[string]string) error { if err != nil { return err } - devices := fmt.Sprintf(`'{%s,%s,%s}'`, privateIface, defaultIfaceIPv4, defaultIfaceIPv6) + devices := fmt.Sprintf(`{%s,%s,%s}`, privateIface, defaultIfaceIPv4, defaultIfaceIPv6) addIfNotOverwritten(options, "devices", devices) } @@ -2787,7 +2787,11 @@ func (kub *Kubectl) RunHelm(action, repo, helmName, version, namespace string, o optionsString := "" for k, v := range options { - optionsString += fmt.Sprintf(" --set %s=%s ", k, v) + if v == "true" || v == "false" { + optionsString += fmt.Sprintf(" --set %s=%s ", k, v) + } else { + optionsString += fmt.Sprintf(" --set '%s=%s' ", k, v) + } } return kub.ExecMiddle(fmt.Sprintf("helm %s %s %s "+ @@ -4333,7 +4337,11 @@ func (kub *Kubectl) HelmTemplate(chartDir, namespace, filename string, options m optionsString := "" for k, v := range options { - optionsString += fmt.Sprintf(" --set %s=%s ", k, v) + if v == "true" || v == "false" { + optionsString += fmt.Sprintf(" --set %s=%s ", k, v) + } else { + optionsString += fmt.Sprintf(" --set '%s=%s' ", k, v) + } } return kub.ExecMiddle("helm template --validate " + diff --git a/test/k8s/hubble.go b/test/k8s/hubble.go index 5eeca4633ce5c..313742b1f1a57 100644 --- a/test/k8s/hubble.go +++ b/test/k8s/hubble.go @@ -126,7 +126,7 @@ var _ = Describe("K8sAgentHubbleTest", func() { ciliumFilename = helpers.TimestampFilename("cilium.yaml") DeployCiliumOptionsAndDNS(kubectl, ciliumFilename, map[string]string{ - "hubble.metrics.enabled": `"{dns:query;ignoreAAAA,drop,tcp,flow,port-distribution,icmp,http}"`, + "hubble.metrics.enabled": `{dns:query;ignoreAAAA,drop,tcp,flow,port-distribution,icmp,http}`, "hubble.relay.enabled": "true", "bpf.monitorAggregation": "none", }) diff --git a/test/k8s/updates.go b/test/k8s/updates.go index 291f52ea93227..84e04eba4da04 100644 --- a/test/k8s/updates.go +++ b/test/k8s/updates.go @@ -186,7 +186,7 @@ func InstallAndValidateCiliumUpgrades(kubectl *helpers.Kubectl, oldHelmChartVers "cleanState": "true", "image.tag": imageTag, "sleepAfterInit": "true", - "operator.enabled": "false ", + "operator.enabled": "false", "hubble.tls.enabled": "false", "cluster.name": clusterName, "cluster.id": clusterID, @@ -268,9 +268,9 @@ func InstallAndValidateCiliumUpgrades(kubectl *helpers.Kubectl, oldHelmChartVers hasNewHelmValues := versioncheck.MustCompile(">=1.12.90") if hasNewHelmValues(versioncheck.MustVersion(newHelmChartVersion)) { - opts["bandwidthManager.enabled"] = "false " + opts["bandwidthManager.enabled"] = "false" } else { - opts["bandwidthManager"] = "false " + opts["bandwidthManager"] = "false" } // Eventually allows multiple return values, and performs the assertion @@ -421,12 +421,12 @@ func InstallAndValidateCiliumUpgrades(kubectl *helpers.Kubectl, oldHelmChartVers By("Install Cilium pre-flight check DaemonSet") opts = map[string]string{ - "preflight.enabled": "true ", - "config.enabled": "false ", - "operator.enabled": "false ", + "preflight.enabled": "true", + "config.enabled": "false", + "operator.enabled": "false", "preflight.image.tag": newImageVersion, "nodeinit.enabled": "false", - "agent": "false ", + "agent": "false", } EventuallyWithOffset(1, func() (*helpers.CmdRes, error) {