github.com/minamijoyo/terraform@v0.7.8-0.20161029001309-18b3736ba44b/builtin/providers/docker/config.go (about) 1 package docker 2 3 import ( 4 "path/filepath" 5 6 dc "github.com/fsouza/go-dockerclient" 7 ) 8 9 // Config is the structure that stores the configuration to talk to a 10 // Docker API compatible host. 11 type Config struct { 12 Host string 13 CertPath string 14 } 15 16 // NewClient() returns a new Docker client. 17 func (c *Config) NewClient() (*dc.Client, error) { 18 // If there is no cert information, then just return the direct client 19 if c.CertPath == "" { 20 return dc.NewClient(c.Host) 21 } 22 23 // If there is cert information, load it and use it. 24 ca := filepath.Join(c.CertPath, "ca.pem") 25 cert := filepath.Join(c.CertPath, "cert.pem") 26 key := filepath.Join(c.CertPath, "key.pem") 27 return dc.NewTLSClient(c.Host, cert, key, ca) 28 } 29 30 // Data ia structure for holding data that we fetch from Docker. 31 type Data struct { 32 DockerImages map[string]*dc.APIImages 33 }