// NewDockerClient creates a new docker client from client options func NewDockerClient(co *clientutil.ClientOptions) (client DockerClient, err error) { tlsConfig := co.TLSConfig() var dc *dockerclient.Client if tlsConfig != nil { dc, err = dockerclient.NewTLSClient(co.DaemonURL(), co.ClientCertFile(), co.ClientKeyFile(), co.CACertFile()) if err != nil { return } } else { dc, err = dockerclient.NewClient(co.DaemonURL()) if err != nil { return } } return DockerClient{ Client: dc, options: co, }, nil }
// newDockerClient creates a new docker client from client options func newDockerClient(co *clientutil.ClientOptions) (DockerClient, error) { var httpClient *http.Client tlsConfig := co.TLSConfig() host := co.DaemonURL() if tlsConfig != nil { httpClient = &http.Client{ Transport: &http.Transport{ TLSClientConfig: tlsConfig, }, } } apiClient, err := client.NewClient(host, os.Getenv("DOCKER_API_VERSION"), httpClient, nil) if err != nil { return DockerClient{}, err } return DockerClient{ Client: apiClient, options: co, }, nil }