terraform/builtin/providers/docker/config.go

34 lines
833 B
Go
Raw Normal View History

package docker
import (
"path/filepath"
dc "github.com/fsouza/go-dockerclient"
)
2015-03-29 03:37:20 +02:00
// Config is the structure that stores the configuration to talk to a
// Docker API compatible host.
type Config struct {
Host string
CertPath string
}
// NewClient() returns a new Docker client.
func (c *Config) NewClient() (*dc.Client, error) {
// If there is no cert information, then just return the direct client
if c.CertPath == "" {
return dc.NewClient(c.Host)
}
// If there is cert information, load it and use it.
ca := filepath.Join(c.CertPath, "ca.pem")
cert := filepath.Join(c.CertPath, "cert.pem")
key := filepath.Join(c.CertPath, "key.pem")
return dc.NewTLSClient(c.Host, cert, key, ca)
}
2015-03-29 03:37:20 +02:00
// Data ia structure for holding data that we fetch from Docker.
type Data struct {
DockerImages map[string]*dc.APIImages
}