Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Lazarev committed Sep 9, 2021
1 parent 8d2f9a0 commit ac37c0c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ v0.1.3
- fixed all from previous(0.1.2) note
- could use "self" in importValuesFrom

v0.1.2
v0.1.2 (not actual)
- go template [Actions](https://pkg.go.dev/text/template#hdr-Actions) could be used but yaml should we readable for yaml-parsers. So easest way to do it is using comment befor actions "#"
like this:
```
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ func ReadValues(valuesFiles ImportValues, dir string) (vals Values) {
func mergeKeys(left, right Values) Values {
for key, rightVal := range right {
if leftVal, present := left[key]; present {
left[key] = mergeKeys(leftVal.(Values), rightVal.(Values))
if _, ok := leftVal.(Values); ok {
left[key] = mergeKeys(leftVal.(Values), rightVal.(Values))
} else {
left[key] = rightVal
}
} else {
left[key] = rightVal
}
Expand Down
1 change: 1 addition & 0 deletions test/base-values2.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
enabled: true
clusterName: aws-eu-test-42
default: from_base
6 changes: 3 additions & 3 deletions test/template-values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
importValuesFrom:
- self
- base-values1.yaml
- base-values2.yaml
- self

default: qwerty
default: from_this
myapp:
cluster: {{ .Values.clusterName }}
enabled: {{ .Values.enabled }}
Expand All @@ -13,6 +13,6 @@ myapp:
minReplicas: {{ .Values.defaults.minReplicas }}
{{- if .Values.default }}
run: {{ .Values.default }}
{{- end -}}
{{- end }}

resources: {{ toYaml .Values.defaults.resources | nindent 6 }}

0 comments on commit ac37c0c

Please sign in to comment.