mirror of
https://github.com/helmfile/helmfile.git
synced 2026-09-30 06:44:35 +02:00
feat: override state(former "enviroment") values via command-line args (#644)
The addition of `--set k1=v1,k2=v2` and `--values file1 --values file2` was originally planned in #361. But it turned out we already had `--values` for existing helmfile commands like `sync`. Duplicated flags doesn't work, obviously. So this actually add `--state-values-set k1=v1,k2=v2` and `--set-values-file file1 --set-values-file file2`. They are called "state" values according to the discussion we had at #640 Resolves #361
This commit is contained in:
@@ -48,3 +48,28 @@ func CastKeysToStrings(s interface{}) (map[string]interface{}, error) {
|
||||
}
|
||||
return new, nil
|
||||
}
|
||||
|
||||
func Set(m map[string]interface{}, key []string, value string) map[string]interface{} {
|
||||
if len(key) == 0 {
|
||||
panic(fmt.Errorf("bug: unexpected length of key: %d", len(key)))
|
||||
}
|
||||
|
||||
k := key[0]
|
||||
|
||||
if len(key) == 1 {
|
||||
m[k] = value
|
||||
return m
|
||||
}
|
||||
|
||||
remain := key[1:]
|
||||
|
||||
nested, ok := m[k]
|
||||
if !ok {
|
||||
new_m := map[string]interface{}{}
|
||||
nested = Set(new_m, remain, value)
|
||||
}
|
||||
|
||||
m[k] = nested
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user