Merge pull request #6424 from hashicorp/b-docker-empty-command-crash
provider/docker: don't crash with empty commands
This commit is contained in:
commit
ac88c18cac
|
@ -51,6 +51,11 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
|
|||
|
||||
if v, ok := d.GetOk("command"); ok {
|
||||
createOpts.Config.Cmd = stringListToStringSlice(v.([]interface{}))
|
||||
for _, v := range createOpts.Config.Cmd {
|
||||
if v == "" {
|
||||
return fmt.Errorf("values for command may not be empty")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("entrypoint"); ok {
|
||||
|
@ -269,6 +274,10 @@ func resourceDockerContainerDelete(d *schema.ResourceData, meta interface{}) err
|
|||
func stringListToStringSlice(stringList []interface{}) []string {
|
||||
ret := []string{}
|
||||
for _, v := range stringList {
|
||||
if v == nil {
|
||||
ret = append(ret, "")
|
||||
continue
|
||||
}
|
||||
ret = append(ret, v.(string))
|
||||
}
|
||||
return ret
|
||||
|
|
Loading…
Reference in New Issue