All checks were successful
continuous-integration/drone/push Build is passing
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package client
|
|
|
|
import (
|
|
"github.com/docker/cli/cli/connhelper"
|
|
"github.com/docker/cli/cli/context/docker"
|
|
dCliContextStore "github.com/docker/cli/cli/context/store"
|
|
dClient "github.com/docker/docker/client"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func newConnectionHelper(daemonURL string) *connhelper.ConnectionHelper {
|
|
helper, err := connhelper.GetConnectionHelper(daemonURL)
|
|
|
|
if err != nil {
|
|
logrus.Fatal(err)
|
|
}
|
|
return helper
|
|
}
|
|
|
|
func getDockerEndpoint(host string) (docker.Endpoint, error) {
|
|
skipTLSVerify := false
|
|
ep := docker.Endpoint{
|
|
EndpointMeta: docker.EndpointMeta{
|
|
Host: host,
|
|
SkipTLSVerify: skipTLSVerify,
|
|
},
|
|
}
|
|
// try to resolve a docker client, validating the configuration
|
|
opts, err := ep.ClientOpts()
|
|
if err != nil {
|
|
return docker.Endpoint{}, err
|
|
}
|
|
if _, err := dClient.NewClientWithOpts(opts...); err != nil {
|
|
return docker.Endpoint{}, err
|
|
}
|
|
return ep, nil
|
|
}
|
|
|
|
func getDockerEndpointMetadataAndTLS(host string) (docker.EndpointMeta, *dCliContextStore.EndpointTLSData, error) {
|
|
ep, err := getDockerEndpoint(host)
|
|
if err != nil {
|
|
return docker.EndpointMeta{}, nil, err
|
|
}
|
|
return ep.EndpointMeta, ep.TLSData.ToStoreTLSData(), nil
|
|
}
|