Use docker.NewClient; move dockerClient before it's used
This commit is contained in:
parent
5e73e746dc
commit
8cd34d3947
|
@ -37,10 +37,17 @@ func NewDockerDriver(ctx *DriverContext) Driver {
|
|||
return &DockerDriver{*ctx}
|
||||
}
|
||||
|
||||
// dockerClient creates *docker.Client using ClientConfig so we can get the
|
||||
// correct socket for the daemon
|
||||
func (d *DockerDriver) dockerClient() (*docker.Client, error) {
|
||||
dockerEndpoint := d.config.Read("docker.endpoint")
|
||||
client, err := docker.NewClient(dockerEndpoint)
|
||||
return client, err
|
||||
}
|
||||
|
||||
func (d *DockerDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) {
|
||||
// Initialize docker API client
|
||||
client, err := d.dockerClient()
|
||||
|
||||
if err != nil {
|
||||
d.logger.Printf("[DEBUG] driver.docker: could not connect to docker daemon: %v", err)
|
||||
return false, nil
|
||||
|
@ -350,18 +357,6 @@ func (d *DockerDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, er
|
|||
return h, nil
|
||||
}
|
||||
|
||||
// dockerClient returns a configured *docker.Client from the ClientConfig
|
||||
func (d *DockerDriver) dockerClient() (*docker.Client, error) {
|
||||
dockerEndpoint := d.config.Read("docker.endpoint")
|
||||
if dockerEndpoint == "" {
|
||||
client, err := docker.NewClientFromEnv()
|
||||
return client, err
|
||||
} else {
|
||||
client, err := docker.NewClient(dockerEndpoint)
|
||||
return client, err
|
||||
}
|
||||
}
|
||||
|
||||
func (h *dockerHandle) ID() string {
|
||||
// Return a handle to the PID
|
||||
pid := dockerPID{
|
||||
|
|
Loading…
Reference in New Issue