mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-06 01:32:21 +02:00
fix: support escaped commas in --state-values-set (#2813)
* feat: support comma escape for values overwrites Signed-off-by: zhengbayi <zhengbaiyi@sensetime.com> * fix: harden state-values-set parsing and support \, in state-values-set-string - Return a descriptive error instead of panicking when a --state-values-set assignment is missing '=', has an empty key, or ends with a trailing comma - Support escaped commas in --state-values-set-string and preserve other backslashes (including trailing ones), aligning it with --state-values-set and Helm's --set/--set-string; quoted values keep working - Allow empty values in --state-values-set-string for parity with --state-values-set - Restructure parsing into guard-clause helpers with single-level conditionals; parse assignments via strings.Cut - Extend table-driven tests: error cases, --state-values-set-string coverage, combined flags, and unit tests for the split/unescape helpers Signed-off-by: yxxhero <aiopsclub@163.com> --------- Signed-off-by: zhengbayi <zhengbaiyi@sensetime.com> Signed-off-by: yxxhero <aiopsclub@163.com> Co-authored-by: zhengbayi <zhengbaiyi@sensetime.com> Co-authored-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
co-authored by
zhengbayi
yxxhero
parent
226c16b88e
commit
000a6fa660
+24
@@ -76,6 +76,30 @@ Use "helmfile [command] --help" for more information about a command.
|
||||
|
||||
**Note:** Each command has its own specific flags. Use `helmfile [command] --help` to see command-specific options. For example, `helmfile sync --help` shows operational flags like `--timeout`, `--wait`, and `--wait-for-jobs`.
|
||||
|
||||
### State value overrides
|
||||
|
||||
Use `--state-values-set` to override `.Values` within the Helmfile template. Separate
|
||||
assignments with commas, and escape a comma inside a value with `\,`:
|
||||
|
||||
```bash
|
||||
helmfile --state-values-set 'message=hello\,world,replicas=2' build
|
||||
```
|
||||
|
||||
This sets `message` to the string `hello,world` and `replicas` to the number `2`.
|
||||
Single quotes preserve the backslash when passing the argument through the shell.
|
||||
Backslashes before other characters and at the end of a value are preserved.
|
||||
|
||||
`--state-values-set-string` accepts the same syntax but keeps every value as a
|
||||
string without type conversion. Its values may additionally be wrapped in
|
||||
single or double quotes, which allows commas without escaping:
|
||||
|
||||
```bash
|
||||
helmfile --state-values-set-string 'zone="zone1,zone2",imageTag=1.23.3' build
|
||||
```
|
||||
|
||||
Malformed assignments (missing `=`, empty key, or a trailing comma) are reported
|
||||
as errors instead of being partially applied.
|
||||
|
||||
### init
|
||||
|
||||
The `helmfile init` sub-command checks the dependencies required for helmfile operation, such as `helm`, `helm diff plugin`, `helm secrets plugin`, `helm helm-git plugin`, `helm s3 plugin`. When it does not exist or the version is too low, it can be installed automatically.
|
||||
|
||||
Reference in New Issue
Block a user