updated test

Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
pull/12791/head
Suleiman Dibirov 1 year ago
parent 12a1ec7348
commit 5beaa1799d

@ -72,8 +72,13 @@ func TestTemplateCmd(t *testing.T) {
golden: "output/template-chart-with-ingress-with-map-host.txt",
},
{
name: "check chart with map type ingress host and set ingress.hosts[1].host=changed_host.com",
cmd: fmt.Sprintf("template '%s' --set ingress.enabled=true --set ingress.hosts[1].host=changed_host.com", "testdata/testcharts/chart-with-ingress-with-list-host"),
name: "check chart with map type ingress host and set ingress.hosts[1].host=changed_host.com and -f values.yaml",
cmd: fmt.Sprintf(
"template '%s' %s %s",
"testdata/testcharts/chart-with-ingress-with-list-host",
"--set ingress.enabled=true --set ingress.hosts[1].host=changed_host.com",
"--set certificate.dnsNames[1][1]=changed_dns_host.local",
),
golden: "output/template-chart-with-ingress-with-list-host.txt",
},
{

@ -10,3 +10,16 @@ spec:
- host: "myhost1.local"
- host: "changed_host.com"
- host: "myhost3.local"
---
# Source: chart-with-ingress-with-list-host/templates/certificate.yaml
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: chart-with-ingress-with-list-host
spec:
dnsNames:
- "podinfo"
- "[myhost1.local changed_dns_host.local myhost3.local]"
issuerRef:
kind: ClusterIssuer
name: self-signed

@ -0,0 +1,13 @@
{{- if .Values.certificate.create -}}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ .Chart.Name }}
spec:
dnsNames:
{{- range .Values.certificate.dnsNames }}
- {{ . | quote }}
{{- end }}
issuerRef:
{{- .Values.certificate.issuerRef | toYaml | trimSuffix "\n" | nindent 4 }}
{{- end }}

@ -12,3 +12,12 @@ ingress:
- host: myhost2.local
- host: myhost3.local
tls: []
certificate:
create: true
issuerRef:
kind: ClusterIssuer
name: self-signed
dnsNames:
- podinfo
- [myhost1.local, myhost2.local, myhost3.local]

@ -312,36 +312,34 @@ func coalesceListsFullKey(printf printFn, dst, src []interface{}, prefix string,
// Because dest has higher precedence than src, dest values override src
// values.
for key, val := range src {
fullkey := concatPrefix(prefix, fmt.Sprintf("%v", key))
if key == len(dst) {
dst = append(dst, val)
} else if dst[key] == nil {
dst[key] = val
} else if istable(val) {
if !istable(dst[key]) {
fullkey := concatPrefix(prefix, fmt.Sprintf("%v", key))
printf("warning: cannot overwrite table with non table for %s (%v)", fullkey, val)
}
dst[key] = coalesceTablesFullKey(
printf,
dst[key].(map[string]interface{}),
val.(map[string]interface{}),
prefix,
fullkey,
merge,
)
} else if islist(val) {
if !islist(dst[key]) {
fullkey := concatPrefix(prefix, fmt.Sprintf("%v", key))
printf("warning: cannot overwrite list with non list for %s (%v)", fullkey, val)
}
dst[key] = coalesceListsFullKey(
printf,
dst[key].([]interface{}),
val.([]interface{}),
prefix,
fullkey,
merge,
)
} else {
dst[key] = val
}
}
return dst

Loading…
Cancel
Save