Skip to content

Commit 85eebfb

Browse files
committed
add --set-string flag to ensure proper parsing of strings
This resolves an issue where numeric values intended to be used as strings could be interpreted as float64 values, causing varius things to fail in unexpected ways. This fix mirrors the changes in the following PR to Helm itself: helm/helm#3599 Closes #83
1 parent c17ec6b commit 85eebfb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cmd/helm.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ func (d *diffCmd) vals() ([]byte, error) {
163163
}
164164
}
165165

166+
// User specified a value via --set-string
167+
for _, value := range d.stringValues {
168+
if err := strvals.ParseIntoString(value, base); err != nil {
169+
return []byte{}, fmt.Errorf("failed parsing --set-string data: %s", err)
170+
}
171+
}
172+
166173
return yaml.Marshal(base)
167174
}
168175

cmd/upgrade.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type diffCmd struct {
2020
detailedExitCode bool
2121
valueFiles valueFiles
2222
values []string
23+
stringValues []string
2324
reuseValues bool
2425
resetValues bool
2526
allowUnreleased bool
@@ -72,6 +73,7 @@ func newChartCommand() *cobra.Command {
7273
f.BoolP("suppress-secrets", "q", false, "suppress secrets in the output")
7374
f.VarP(&diff.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)")
7475
f.StringArrayVar(&diff.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
76+
f.StringArrayVar(&diff.stringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
7577
f.BoolVar(&diff.reuseValues, "reuse-values", false, "reuse the last release's values and merge in any new values")
7678
f.BoolVar(&diff.resetValues, "reset-values", false, "reset the values to the ones built into the chart and merge in any new values")
7779
f.BoolVar(&diff.allowUnreleased, "allow-unreleased", false, "enables diffing of releases that are not yet deployed via Helm")

0 commit comments

Comments
 (0)