Skip to content

Commit

Permalink
test: single quote all --set parameters.
Browse files Browse the repository at this point in the history
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 <tom.hadlaw@isovalent.com>
  • Loading branch information
tommyp1ckles authored and rolinh committed Aug 1, 2024
1 parent 2aabd55 commit 2f23546
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
14 changes: 11 additions & 3 deletions test/helpers/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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 "+
Expand Down Expand Up @@ -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 " +
Expand Down
2 changes: 1 addition & 1 deletion test/k8s/hubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
Expand Down
14 changes: 7 additions & 7 deletions test/k8s/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2f23546

Please sign in to comment.