Skip to content

Commit e737d76

Browse files
author
Oleg Sucharevich
committed
support merge of values into same namespace
1 parent c72b273 commit e737d76

File tree

12 files changed

+52
-19
lines changed

12 files changed

+52
-19
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.7.0
1+
0.8.0

cmd/render.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var renderCmd = &cobra.Command{
2525
Use: "render",
2626
Run: func(cmd *cobra.Command, args []string) {
2727
templateReaders := make(map[string]io.Reader)
28-
valueReaders := make(map[string]io.Reader)
28+
valueReaders := make(map[string][]io.Reader)
2929
log := logger.New(nil)
3030
if len(renderCmdOptions.templates) == 0 {
3131
dieOnError(fmt.Errorf("No tempalte given"), log)
@@ -51,7 +51,11 @@ var renderCmd = &cobra.Command{
5151
} else {
5252
valueReader = file
5353
}
54-
valueReaders[renderCmdOptions.rootContext] = valueReader
54+
if _, ok := valueReaders[renderCmdOptions.rootContext]; !ok {
55+
valueReaders[renderCmdOptions.rootContext] = []io.Reader{valueReader}
56+
} else {
57+
valueReaders[renderCmdOptions.rootContext] = append(valueReaders[renderCmdOptions.rootContext], valueReader)
58+
}
5559
} else {
5660
file, err = os.Open(values[1])
5761
dieOnError(err, log)
@@ -61,7 +65,11 @@ var renderCmd = &cobra.Command{
6165
} else {
6266
valueReader = file
6367
}
64-
valueReaders[values[0]] = valueReader
68+
if _, ok := valueReaders[values[0]]; !ok {
69+
valueReaders[values[0]] = []io.Reader{valueReader}
70+
} else {
71+
valueReaders[values[0]] = append(valueReaders[values[0]], valueReader)
72+
}
6573
}
6674
defer file.Close()
6775
}
@@ -84,6 +92,6 @@ func init() {
8492
renderCmd.Flags().StringArrayVar(&renderCmdOptions.templates, "template", []string{}, "Path to template file")
8593
renderCmd.Flags().StringArrayVar(&renderCmdOptions.values, "value", []string{}, "Path to value file")
8694
renderCmd.Flags().StringVar(&renderCmdOptions.rootContext, "root-namespace", "Values", "Name of the root namespace (default: Values)")
87-
renderCmd.Flags().StringVar(&renderCmdOptions.leftDelim, "left-delim", "<<", "Left delimiter (default: <<)")
88-
renderCmd.Flags().StringVar(&renderCmdOptions.rightDelim, "right-delim", ">>", "Right delimiter (default: >>)")
95+
renderCmd.Flags().StringVar(&renderCmdOptions.leftDelim, "left-delim", "{{", "Left delimiter (default: <<)")
96+
renderCmd.Flags().StringVar(&renderCmdOptions.rightDelim, "right-delim", "}}", "Right delimiter (default: >>)")
8997
}

examples/multiple-files/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Run: `pikolo render --template examples/with-namespace/template --value Context=examples/with-namespace/values.yaml`

examples/multiple-files/run.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
pikolo render \
3+
--template examples/multiple-files/templates/t1 \
4+
--template examples/multiple-files/templates/t2 \
5+
--value examples/multiple-files/values/values.yaml \
6+
--value examples/multiple-files/values/values_2.json
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
steps:
2+
step_1:
3+
image: {{ .Values.image }}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
steps:
2+
step_1:
3+
image: {{ .Values.key }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
image: alpine:3.8
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"key": "value"
3+
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ require (
1818
github.com/hairyhenderson/toml v0.3.0 // indirect
1919
github.com/hashicorp/consul/api v1.1.0 // indirect
2020
github.com/hashicorp/vault/api v1.0.4 // indirect
21+
github.com/imdario/mergo v0.3.7
2122
github.com/inconshreveable/log15 v0.0.0-20180818164646-67afb5ed74ec
2223
github.com/joho/godotenv v1.3.0 // indirect
2324
github.com/mattn/go-colorable v0.1.2 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ github.com/hashicorp/vault/sdk v0.1.13 h1:mOEPeOhT7jl0J4AMl1E705+BcmeRs1VmKNb9F0
108108
github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M=
109109
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
110110
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
111+
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
112+
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
111113
github.com/inconshreveable/log15 v0.0.0-20180818164646-67afb5ed74ec h1:CGkYB1Q7DSsH/ku+to+foV4agt2F2miquaLUgF6L178=
112114
github.com/inconshreveable/log15 v0.0.0-20180818164646-67afb5ed74ec/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o=
113115
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=

0 commit comments

Comments
 (0)