mirror of
https://github.com/rancher/os.git
synced 2025-06-23 05:27:03 +00:00
The commit 9d76b79ac3
refactor code for function
"NewClient", and we should delete the unused const
variable.
Signed-off-by: Wang Long <long.wanglong@huawei.com>
29 lines
575 B
Go
29 lines
575 B
Go
package docker
|
|
|
|
import (
|
|
dockerClient "github.com/fsouza/go-dockerclient"
|
|
"github.com/rancher/os/config"
|
|
)
|
|
|
|
func NewSystemClient() (*dockerClient.Client, error) {
|
|
return NewClient(config.DOCKER_SYSTEM_HOST)
|
|
}
|
|
|
|
func NewDefaultClient() (*dockerClient.Client, error) {
|
|
return NewClient(config.DOCKER_HOST)
|
|
}
|
|
|
|
func NewClient(endpoint string) (*dockerClient.Client, error) {
|
|
client, err := dockerClient.NewClient(endpoint)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
err = ClientOK(endpoint, func() bool {
|
|
_, err := client.Info()
|
|
return err == nil
|
|
})
|
|
|
|
return client, err
|
|
}
|