mirror of
https://github.com/rancher/os.git
synced 2025-09-12 21:23:13 +00:00
Move around code for better clarity
This commit is contained in:
committed by
niusmallnan
parent
2f50b7b178
commit
1f50386828
29
pkg/docker/client.go
Normal file
29
pkg/docker/client.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
dockerClient "github.com/docker/engine-api/client"
|
||||
"github.com/rancher/os/config"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func NewSystemClient() (dockerClient.APIClient, error) {
|
||||
return NewClient(config.SystemDockerHost)
|
||||
}
|
||||
|
||||
func NewDefaultClient() (dockerClient.APIClient, error) {
|
||||
return NewClient(config.DockerHost)
|
||||
}
|
||||
|
||||
func NewClient(endpoint string) (dockerClient.APIClient, error) {
|
||||
client, err := dockerClient.NewClient(endpoint, "", nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = ClientOK(endpoint, func() bool {
|
||||
_, err := client.Info(context.Background())
|
||||
return err == nil
|
||||
})
|
||||
|
||||
return client, err
|
||||
}
|
Reference in New Issue
Block a user