1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 06:11:12 +00:00
Files
os/docker/client.go

30 lines
642 B
Go
Raw Normal View History

2015-02-08 21:38:37 -07:00
package docker
import (
2016-05-23 17:21:28 -07:00
dockerClient "github.com/docker/engine-api/client"
"github.com/rancher/os/config"
2016-05-23 17:21:28 -07:00
"golang.org/x/net/context"
2015-02-08 21:38:37 -07:00
)
2016-05-23 17:21:28 -07:00
func NewSystemClient() (dockerClient.APIClient, error) {
2016-11-28 00:06:00 -08:00
return NewClient(config.SystemDockerHost)
2015-02-17 01:18:48 -07:00
}
2016-05-23 17:21:28 -07:00
func NewDefaultClient() (dockerClient.APIClient, error) {
2016-11-28 00:06:00 -08:00
return NewClient(config.DockerHost)
2015-02-17 01:18:48 -07:00
}
2016-05-23 17:21:28 -07:00
func NewClient(endpoint string) (dockerClient.APIClient, error) {
client, err := dockerClient.NewClient(endpoint, "", nil, nil)
2015-02-08 21:38:37 -07:00
if err != nil {
return nil, err
}
2015-08-04 14:45:38 -07:00
err = ClientOK(endpoint, func() bool {
2016-05-23 17:21:28 -07:00
_, err := client.Info(context.Background())
2015-08-04 14:45:38 -07:00
return err == nil
})
2015-02-08 21:38:37 -07:00
2015-08-04 14:45:38 -07:00
return client, err
2015-02-08 21:38:37 -07:00
}