Skip to content

Commit 11989b5

Browse files
prabdebsimt2
authored andcommitted
Revoming unnecessary logics and renaming the CLIValues SETValues
1 parent 90bac85 commit 11989b5

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

cmd/apply.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@ apps, mh acts on all apps in your mh config.`,
3737
// Build additional configuration from environment and CLI
3838
envCLIConfig := lib.MHConfig{
3939
PrintRendered: viper.GetBool("printRendered"),
40-
}
41-
42-
// Add values passed via CLI using --set
43-
if viper.GetStringSlice("set") != nil {
44-
envCLIConfig = lib.MHConfig{
45-
CLIValues: viper.GetStringSlice("set"),
46-
}
40+
SETValues: viper.GetStringSlice("set"),
4741
}
4842

4943
// Merge configuration from file, environment and CLI into default

cmd/simulate.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@ apps, mh acts on all apps in your mh config.`,
3737
// Build additional configuration from environment and CLI
3838
envCLIConfig := lib.MHConfig{
3939
PrintRendered: viper.GetBool("printRendered"),
40-
}
41-
42-
// Add values passed via CLI using --set
43-
if viper.GetStringSlice("set") != nil {
44-
envCLIConfig = lib.MHConfig{
45-
CLIValues: viper.GetStringSlice("set"),
46-
}
40+
SETValues: viper.GetStringSlice("set"),
4741
}
4842

4943
// Merge configuration from file, environment and CLI into default

mhlib/app.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,11 @@ func (a *App) render(configFile string) (*string, *string, *[]byte, error) {
230230
}
231231

232232
// Add config via --set command
233-
for _, value := range a.MHConfig.CLIValues {
234-
strvals.ParseInto(value, config)
233+
for _, value := range a.MHConfig.SETValues {
234+
err := strvals.ParseInto(value, config)
235+
if err != nil {
236+
return nil, nil, nil, fmt.Errorf("Failed to parse values provided via --set : %v", err)
237+
}
235238
}
236239

237240
out, err := engine.New().Render(fakeChart, config)

mhlib/mhConfig.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type MHConfig struct {
2727
Simulate bool `yaml:"simulate"`
2828
TargetContext string `yaml:"targetContext"`
2929
Team string `yaml:"team"`
30-
CLIValues []string `yaml:"cliValues"`
30+
SETValues []string `yaml:"setValues"`
3131
}
3232

3333
// DefaultMHConfig is the default mh config and will most likely be modified
@@ -44,7 +44,7 @@ var DefaultMHConfig = MHConfig{
4444
Simulate: false,
4545
TargetContext: "localhost",
4646
Team: "sre",
47-
CLIValues: []string{""},
47+
SETValues: []string{""},
4848
}
4949

5050
// MergeMHConfigs merges an arbitrary number of MHConfigs with rising priority.

0 commit comments

Comments
 (0)