Fold communication-checking code into docker.Client.NewClient()

This commit is contained in:
Bryan Boreham committed 2015-06-12 14:45:29 +01:00
1 parent 698d352322
commit 086daca3d0
1 file changed
+4 -14
+4 -14
View File
@@ -24,30 +24,20 @@ type Client struct {
*docker.Client *docker.Client
} }
// NewClient creates a new Docker client // NewClient creates a new Docker client and checks we can talk to Docker
func NewClient(apiPath string) (*Client, error) { func NewClient(apiPath string) (*Client, error) {
dc, err := docker.NewClient(apiPath) dc, err := docker.NewClient(apiPath)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &Client{dc}, nil client := &Client{dc}
}
// Start starts the client
func (c *Client) Start(apiPath string) error {
client, err := docker.NewClient(apiPath)
if err != nil {
Error.Printf("[docker] Unable to connect to Docker API on %s: %s", apiPath, err)
return err
}
env, err := client.Version() env, err := client.Version()
if err != nil { if err != nil {
Error.Printf("[docker] Unable to connect to Docker API on %s: %s", apiPath, err) return nil, err
return err
} }
Info.Printf("[docker] Using Docker API on %s: %v", apiPath, env) Info.Printf("[docker] Using Docker API on %s: %v", apiPath, env)
return nil return client, nil
} }
// AddObserver adds an observer for docker events // AddObserver adds an observer for docker events