Add a little safety around variables that are passed into provisioner.
This commit is contained in:
parent
bd0b1190f6
commit
6c3030c73a
|
@ -347,8 +347,9 @@ func (p *Provisioner) createFlattenedEnvVars(elevated bool) (flattened string, e
|
|||
// Split vars into key/value components
|
||||
for _, envVar := range p.config.Vars {
|
||||
keyValue := strings.Split(envVar, "=")
|
||||
if len(keyValue) != 2 {
|
||||
err = errors.New("Shell provisioner environment variables must be in key=value format")
|
||||
|
||||
if len(keyValue) != 2 || keyValue[0] == "" {
|
||||
err = errors.New(fmt.Sprintf("Shell provisioner environment variables must be in key=value format. Currently it is '%s'", envVar))
|
||||
return
|
||||
}
|
||||
envVars[keyValue[0]] = keyValue[1]
|
||||
|
|
|
@ -305,10 +305,10 @@ func (p *Provisioner) createFlattenedEnvVars() (flattened string, err error) {
|
|||
// Split vars into key/value components
|
||||
for _, envVar := range p.config.Vars {
|
||||
keyValue := strings.Split(envVar, "=")
|
||||
if len(keyValue) != 2 {
|
||||
err = errors.New("Shell provisioner environment variables must be in key=value format")
|
||||
if len(keyValue) != 2 || keyValue[0] == "" {
|
||||
err = errors.New(fmt.Sprintf("Shell provisioner environment variables must be in key=value format. Currently it is '%s'", envVar))
|
||||
return
|
||||
}
|
||||
}
|
||||
envVars[keyValue[0]] = keyValue[1]
|
||||
}
|
||||
// Create a list of env var keys in sorted order
|
||||
|
|
Loading…
Reference in New Issue