Skip to content

Commit

Permalink
Merge pull request hashicorp#6424 from hashicorp/b-docker-empty-comma…
Browse files Browse the repository at this point in the history
…nd-crash

provider/docker: don't crash with empty commands
  • Loading branch information
jen20 committed Apr 30, 2016
2 parents 7a49c2d + 6913754 commit ac88c18
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions builtin/providers/docker/resource_docker_container_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ac88c18

Please sign in to comment.