Use a regex to match --state-values-set-string arguments (#1902)
Signed-off-by: Guillaume Le Blanc <gleblanc@proton.me>
This commit is contained in:
parent
8e188960eb
commit
09c9ceb075
|
|
@ -1,21 +1,23 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/helmfile/helmfile/pkg/maputil"
|
"github.com/helmfile/helmfile/pkg/maputil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewCLIConfigImpl(g *GlobalImpl) error {
|
func NewCLIConfigImpl(g *GlobalImpl) error {
|
||||||
|
re := regexp.MustCompile(`(?:,|^)([^\s=]+)=(['"][^'"]*['"]|[^,]+)`)
|
||||||
optsSet := g.RawStateValuesSetString()
|
optsSet := g.RawStateValuesSetString()
|
||||||
if len(optsSet) > 0 {
|
if len(optsSet) > 0 {
|
||||||
set := map[string]any{}
|
set := map[string]any{}
|
||||||
for i := range optsSet {
|
for i := range optsSet {
|
||||||
ops := strings.Split(optsSet[i], ",")
|
ops := re.FindAllStringSubmatch(optsSet[i], -1)
|
||||||
for j := range ops {
|
for j := range ops {
|
||||||
op := strings.SplitN(ops[j], "=", 2)
|
op := ops[j]
|
||||||
k := maputil.ParseKey(op[0])
|
k := maputil.ParseKey(op[1])
|
||||||
v := op[1]
|
v := op[2]
|
||||||
|
|
||||||
maputil.Set(set, k, v, true)
|
maputil.Set(set, k, v, true)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ if [[ ${HELMFILE_V1MODE} = true ]]; then
|
||||||
info "Comparing ${case_title} for v1 output ${cli_overwrite_environment_values_reverse} with ${cli_overwrite_environment_values_output_dir}/overwritten.yaml"
|
info "Comparing ${case_title} for v1 output ${cli_overwrite_environment_values_reverse} with ${cli_overwrite_environment_values_output_dir}/overwritten.yaml"
|
||||||
for i in $(seq 10); do
|
for i in $(seq 10); do
|
||||||
info "Comparing build/cli-overwrite-environment-values #$i"
|
info "Comparing build/cli-overwrite-environment-values #$i"
|
||||||
${helmfile} -f ${cli_overwrite_environment_values_input_dir}/input_v1.yaml.gotmpl template --state-values-set ns=test3 > ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" shouldn't fail"
|
${helmfile} -f ${cli_overwrite_environment_values_input_dir}/input_v1.yaml.gotmpl template --state-values-set ns=test3 --state-values-set-string imageTag=1.23.3,zone="zone1,zone2" > ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" shouldn't fail"
|
||||||
diff -u ${cli_overwrite_environment_values_output_dir}/output_v1.yaml ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" should be consistent"
|
diff -u ${cli_overwrite_environment_values_output_dir}/output_v1.yaml ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" should be consistent"
|
||||||
echo code=$?
|
echo code=$?
|
||||||
done
|
done
|
||||||
|
|
@ -21,9 +21,9 @@ else
|
||||||
info "Comparing ${case_title} output ${cli_overwrite_environment_values_reverse} with ${cli_overwrite_environment_values_output_dir}/overwritten.yaml"
|
info "Comparing ${case_title} output ${cli_overwrite_environment_values_reverse} with ${cli_overwrite_environment_values_output_dir}/overwritten.yaml"
|
||||||
for i in $(seq 10); do
|
for i in $(seq 10); do
|
||||||
info "Comparing build/cli-overwrite-environment-values #$i"
|
info "Comparing build/cli-overwrite-environment-values #$i"
|
||||||
${helmfile} -f ${cli_overwrite_environment_values_input_dir}/input_v1.yaml.gotmpl template --state-values-set ns=test3 > ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" shouldn't fail"
|
${helmfile} -f ${cli_overwrite_environment_values_input_dir}/input_v1.yaml.gotmpl template --state-values-set ns=test3 --state-values-set-string imageTag=1.23.3,zone="zone1,zone2" > ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" shouldn't fail"
|
||||||
diff -u ${cli_overwrite_environment_values_output_dir}/output_v1.yaml ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" should be consistent"
|
diff -u ${cli_overwrite_environment_values_output_dir}/output_v1.yaml ${cli_overwrite_environment_values_reverse} || fail "\"helmfile template\" should be consistent"
|
||||||
echo code=$?
|
echo code=$?
|
||||||
done
|
done
|
||||||
test_pass "${case_title}"
|
test_pass "${case_title}"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,5 @@
|
||||||
image:
|
image:
|
||||||
tag: {{ .Values.ns }}
|
tag: {{ .Values.imageTag }}
|
||||||
|
|
||||||
|
podAnnotations:
|
||||||
|
zone: {{ .Values.zone }}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ spec:
|
||||||
app.kubernetes.io/instance: test
|
app.kubernetes.io/instance: test
|
||||||
app.kubernetes.io/managed-by: Helm
|
app.kubernetes.io/managed-by: Helm
|
||||||
annotations:
|
annotations:
|
||||||
|
zone: "zone1,zone2"
|
||||||
spec:
|
spec:
|
||||||
|
|
||||||
automountServiceAccountToken: false
|
automountServiceAccountToken: false
|
||||||
|
|
@ -75,7 +76,7 @@ spec:
|
||||||
initContainers:
|
initContainers:
|
||||||
containers:
|
containers:
|
||||||
- name: nginx
|
- name: nginx
|
||||||
image: docker.io/bitnami/nginx:test3
|
image: docker.io/bitnami/nginx:1.23.3
|
||||||
imagePullPolicy: "IfNotPresent"
|
imagePullPolicy: "IfNotPresent"
|
||||||
env:
|
env:
|
||||||
- name: BITNAMI_DEBUG
|
- name: BITNAMI_DEBUG
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue