support alternate DOCKER_HOST settings when launching the plugin

This commit is contained in:
Paul Bellamy authored and Bryan Boreham committed 2015-12-15 18:12:31 +00:00
1 parent f28ad350bd
commit a4ef96690e
2 files changed
+15 -5

No files matched your search

+14 -4
View File
@@ -30,7 +30,7 @@ func NewClient(apiPath string) (*Client, error) {
} }
client := &Client{dc} client := &Client{dc}
return client, client.checkWorking(apiPath) return client, client.checkWorking()
} }
func NewVersionedClient(apiPath string, apiVersionString string) (*Client, error) { func NewVersionedClient(apiPath string, apiVersionString string) (*Client, error) {
@@ -43,15 +43,25 @@ func NewVersionedClient(apiPath string, apiVersionString string) (*Client, error
} }
client := &Client{dc} client := &Client{dc}
return client, client.checkWorking(apiPath) return client, client.checkWorking()
} }
func (c *Client) checkWorking(apiPath string) error { func NewVersionedClientFromEnv(apiVersionString string) (*Client, error) {
dc, err := docker.NewVersionedClientFromEnv(apiVersionString)
if err != nil {
return nil, err
}
client := &Client{dc}
return client, client.checkWorking()
}
func (c *Client) checkWorking() error {
env, err := c.Version() env, err := c.Version()
if err != nil { if err != nil {
return err return err
} }
Log.Infof("[docker] Using Docker API on %s: %v", apiPath, env) Log.Infof("[docker] Using Docker API on %s: %v", c.Endpoint(), env)
return nil return nil
} }
+1 -1
View File
@@ -49,7 +49,7 @@ func main() {
Log.Println("Weave plugin", version, "Command line options:", os.Args[1:]) Log.Println("Weave plugin", version, "Command line options:", os.Args[1:])
// API 1.21 is the first version that supports docker network commands // API 1.21 is the first version that supports docker network commands
dockerClient, err := docker.NewVersionedClient("unix:///var/run/docker.sock", "1.21") dockerClient, err := docker.NewVersionedClientFromEnv("1.21")
if err != nil { if err != nil {
Log.Fatalf("unable to connect to docker: %s", err) Log.Fatalf("unable to connect to docker: %s", err)
} }