Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 78cedf0

Browse files
author
Matthieu Nottale
committed
Render: env->set, err on dup.
Signed-off-by: Matthieu Nottale <[email protected]>
1 parent 54ce063 commit 78cedf0

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

cmd/render.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,22 @@ Override is provided in three different ways:
1818
- External Compose files or template Compose files can be specified with the -c flag.
1919
(Repeat the flag for multiple files). These files will be merged in order with
2020
the app's own Compose file.
21-
- External YAML settings files can be specified with the -s flag. All settings
21+
- External YAML settings files can be specified with the -f flag. All settings
2222
files are merged in order, the app's settings coming first.
2323
- Individual settings values can be passed directly on the command line with the
24-
-e flag. These value takes precedence over all settings files.
24+
-s flag. These value takes precedence over all settings files.
2525
`,
2626
Args: cobra.ExactArgs(1),
2727
Run: func(cmd *cobra.Command, args []string) {
2828
d := make(map[string]string)
2929
for _, v := range renderEnv {
3030
kv := strings.SplitN(v, "=", 2)
3131
if len(kv) != 2 {
32-
fmt.Printf("Malformed env input: '%s'\n", v)
32+
fmt.Printf("Missing '=' in setting '%s', expected KEY=VALUE\n", v)
33+
os.Exit(1)
34+
}
35+
if _, ok := d[kv[0]]; ok {
36+
fmt.Printf("Duplicate command line setting: '%s'\n", kv[0])
3337
os.Exit(1)
3438
}
3539
d[kv[0]] = kv[1]
@@ -55,6 +59,6 @@ var renderEnv []string
5559
func init() {
5660
rootCmd.AddCommand(renderCmd)
5761
renderCmd.Flags().StringArrayVarP(&renderComposeFiles, "compose-files", "c", []string{}, "Override Compose files")
58-
renderCmd.Flags().StringArrayVarP(&renderSettingsFile, "settings-files", "s", []string{}, "Override settings files")
59-
renderCmd.Flags().StringArrayVarP(&renderEnv, "env", "e", []string{}, "Override settings values")
62+
renderCmd.Flags().StringArrayVarP(&renderSettingsFile, "settings-files", "f", []string{}, "Override settings files")
63+
renderCmd.Flags().StringArrayVarP(&renderEnv, "set", "s", []string{}, "Override settings values")
6064
}

e2e/binary_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ func TestRenderBinary(t *testing.T) {
6161
path.Join("render", app.Name()),
6262
}
6363
for _, s := range settings {
64-
args = append(args, "-s", s)
64+
args = append(args, "-f", s)
6565
}
6666
for _, c := range overrides {
6767
args = append(args, "-c", c)
6868
}
6969
for k, v := range env {
70-
args = append(args, "-e", fmt.Sprintf("%s=%s", k, v))
70+
args = append(args, "-s", fmt.Sprintf("%s=%s", k, v))
7171
}
7272
t.Logf("executing with %v", args)
7373
cmd := exec.Command(dockerApp, args...)

0 commit comments

Comments
 (0)