Catch potential custom network errors in docker

This commit is contained in:
Colin Hebert 2016-01-31 08:31:30 +11:00
parent 50d8d5773f
commit edd907c043

View file

@ -162,8 +162,11 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
if v, ok := d.GetOk("networks"); ok {
connectionOpts := dc.NetworkConnectionOptions{Container: retContainer.ID}
for _, network := range v.(*schema.Set).List() {
client.ConnectNetwork(network.(string), connectionOpts)
for _, rawNetwork := range v.(*schema.Set).List() {
network := rawNetwork.(string)
if err := client.ConnectNetwork(network), connectionOpts); err != nil {
return fmt.Errorf("Unable to connect to network '%s': %s", network, err)
}
}
}