samalba / dockerclient

Docker client library in Go
http://www.docker.com/
Apache License 2.0
320 stars 140 forks source link

Add TLSConfigFromCertPath #201

Closed keegancsmith closed 8 years ago

keegancsmith commented 8 years ago

Docker TLS info is usually laid out in a specific way by docker. TLSConfigFromCertPath makes it easy to construct a tls.Config in that case. For example on OS X TLSConfigFromCertPath(os.Getenv("DOCKER_CERT_PATH")) will give us a TLS Config to speak to the docker daemon.

keegancsmith commented 8 years ago

ping @vieux

vieux commented 8 years ago

what do you think @ehazlett

bradrydzewski commented 8 years ago

I end up writing this sort of boilerplate code whenever I'm interacting with the Docker daemon. In fact, I'm just about to write some now, which is why I decided to comment on the issue.

I could even see taking this one step further and creating a function that returns a new DockerClient based on the standard DOCKER_HOST, DOCKER_CERT_PATH and DOCKER_TLS_VERIFY environment variables:

func NewDockerClientEnv() (*DockerClient, error)

The benefit is that we now have a reusable, canonical implementation for creating a docker client from the standard environment variables. Just my 2 cents though :smile:

ehazlett commented 8 years ago

Ya +1 to @bradrydzewski idea. This looks like a good start. LGTM