Allow to escape newlines and tabs in --set

Fixes #3251
pull/3262/head
Mathieu Parent 8 years ago
parent 188964c507
commit c873b1c82e

@ -300,6 +300,12 @@ nodeSelector:
kubernetes.io/role: master
```
Other escape sequences are supported:
- ```\\n```
- ```\\r```
- ```\\t```
- any unsupported sequence will keep the following character
Deeply nested data structures can be difficult to express using `--set`. Chart
designers are encouraged to consider the `--set` usage when designing the format
of a `values.yaml` file.

@ -286,6 +286,15 @@ func runesUntil(in io.RuneReader, stop map[rune]bool) ([]rune, rune, error) {
if e != nil {
return v, next, e
}
switch next {
case 'n':
next = '\n'
case 'r':
next = '\r'
case 't':
next = '\t'
}
v = append(v, next)
default:
v = append(v, r)

@ -255,6 +255,10 @@ func TestParseSet(t *testing.T) {
str: "nested[1][1]=1",
expect: map[string]interface{}{"nested": []interface{}{nil, []interface{}{nil, 1}}},
},
{
str: "escapes=hello\\n\\tworld",
expect: map[string]interface{}{"escapes": "hello\n\tworld"},
},
}
for _, tt := range tests {

Loading…
Cancel
Save