providers/docker: ping docker server on startup

This commit is contained in:
Mitchell Hashimoto 2015-03-28 19:06:48 -07:00
parent 2f0235b23d
commit 118a5b9dfd
1 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,8 @@
package docker package docker
import ( import (
"fmt"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
) )
@ -38,5 +40,15 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
CertPath: d.Get("cert_path").(string), CertPath: d.Get("cert_path").(string),
} }
return config.NewClient() client, err := config.NewClient()
if err != nil {
return nil, fmt.Errorf("Error initializing Docker client: %s", err)
}
err = client.Ping()
if err != nil {
return nil, fmt.Errorf("Error pinging Docker server: %s", err)
}
return client, nil
} }