Fix `index out of range [1] with length 1` error on env2map (#1463)
This happened only when helmfile is run in an environment that any environment variable definition does not include `=` and the right side.
This commit is contained in:
parent
9d2c0d4285
commit
0482ba3b6f
|
|
@ -107,7 +107,16 @@ func env2map(env []string) map[string]string {
|
||||||
wanted := map[string]string{}
|
wanted := map[string]string{}
|
||||||
for _, cur := range env {
|
for _, cur := range env {
|
||||||
pair := strings.SplitN(cur, "=", 2)
|
pair := strings.SplitN(cur, "=", 2)
|
||||||
wanted[pair[0]] = pair[1]
|
|
||||||
|
var v string
|
||||||
|
|
||||||
|
// An environment can completely miss `=` and the right side.
|
||||||
|
// If we didn't deal with that, this may fail due to an index-out-of-range error
|
||||||
|
if len(pair) > 1 {
|
||||||
|
v = pair[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
wanted[pair[0]] = v
|
||||||
}
|
}
|
||||||
return wanted
|
return wanted
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue