Merge pull request #1048 from dlorenc/conncheck

Get rid of the default connchecker.
pull/1049/head
dlorenc 2017-01-27 10:20:09 -08:00 committed by GitHub
commit d1accc36e2
1 changed files with 15 additions and 0 deletions

View File

@ -28,8 +28,10 @@ import (
"github.com/docker/machine/drivers/vmwarefusion"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/cert"
"github.com/docker/machine/libmachine/check"
"github.com/docker/machine/libmachine/drivers/plugin"
"github.com/docker/machine/libmachine/drivers/plugin/localbinary"
"github.com/docker/machine/libmachine/host"
"github.com/golang/glog"
)
@ -38,6 +40,18 @@ type CertGenerator struct {
cert.X509CertGenerator
}
type ConnChecker struct {
}
func (cc *ConnChecker) Check(h *host.Host, swarm bool) (string, *auth.Options, error) {
authOptions := h.AuthOptions()
dockerHost, err := h.Driver.GetURL()
if err != nil {
return "", &auth.Options{}, err
}
return dockerHost, authOptions, nil
}
// ValidateCertificate is a reimplementation of the default generator with a longer timeout.
func (cg *CertGenerator) ValidateCertificate(addr string, authOptions *auth.Options) (bool, error) {
tlsConfig, err := cg.ReadTLSConfig(addr, authOptions)
@ -60,6 +74,7 @@ func (cg *CertGenerator) ValidateCertificate(addr string, authOptions *auth.Opti
// StartDriver starts the desired machine driver if necessary.
func StartDriver() {
cert.SetCertGenerator(&CertGenerator{})
check.DefaultConnChecker = &ConnChecker{}
if os.Getenv(localbinary.PluginEnvKey) == localbinary.PluginEnvVal {
driverName := os.Getenv(localbinary.PluginEnvDriverName)