提交 57f931c1 编写于 作者: M Matt Rickard 提交者: GitHub

Merge pull request #1377 from dlorenc/noapi

Move more of the libmachine code up into minikube.
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"time" "time"
"k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/provision"
"github.com/docker/machine/drivers/virtualbox" "github.com/docker/machine/drivers/virtualbox"
"github.com/docker/machine/libmachine" "github.com/docker/machine/libmachine"
...@@ -37,8 +38,10 @@ import ( ...@@ -37,8 +38,10 @@ import (
"github.com/docker/machine/libmachine/drivers/rpc" "github.com/docker/machine/libmachine/drivers/rpc"
"github.com/docker/machine/libmachine/engine" "github.com/docker/machine/libmachine/engine"
"github.com/docker/machine/libmachine/host" "github.com/docker/machine/libmachine/host"
"github.com/docker/machine/libmachine/mcnutils"
"github.com/docker/machine/libmachine/persist" "github.com/docker/machine/libmachine/persist"
"github.com/docker/machine/libmachine/ssh" "github.com/docker/machine/libmachine/ssh"
"github.com/docker/machine/libmachine/state"
"github.com/docker/machine/libmachine/swarm" "github.com/docker/machine/libmachine/swarm"
"github.com/docker/machine/libmachine/version" "github.com/docker/machine/libmachine/version"
"github.com/pkg/errors" "github.com/pkg/errors"
...@@ -172,12 +175,51 @@ func (api *LocalClient) Load(name string) (*host.Host, error) { ...@@ -172,12 +175,51 @@ func (api *LocalClient) Load(name string) (*host.Host, error) {
func (api *LocalClient) Close() error { return nil } func (api *LocalClient) Close() error { return nil }
// TODO(r2d4): We can rewrite the create function,
// for now, just defer to libmachine's implementation
func (api *LocalClient) Create(h *host.Host) error { func (api *LocalClient) Create(h *host.Host) error {
c := libmachine.NewClient(api.storePath, api.certsDir) steps := []struct {
c.SSHClientType = ssh.Native name string
return c.Create(h) f func() error
}{
{
"Bootstrapping certs.",
func() error { return cert.BootstrapCertificates(h.AuthOptions()) },
},
{
"Running precreate checks.",
h.Driver.PreCreateCheck,
},
{
"Saving driver.",
func() error {
return api.Save(h)
},
},
{
"Creating VM.",
h.Driver.Create,
},
{
"Waiting for VM to start.",
func() error {
return mcnutils.WaitFor(drivers.MachineInState(h.Driver, state.Running))
},
},
{
"Provisioning VM.",
func() error {
pv := provision.NewBuildrootProvisioner(h.Driver)
return pv.Provision(*h.HostOptions.SwarmOptions, *h.HostOptions.AuthOptions, *h.HostOptions.EngineOptions)
},
},
}
for _, step := range steps {
if err := step.f(); err != nil {
return errors.Wrap(err, fmt.Sprintf("Error executing step: %s\n", step.name))
}
}
return nil
} }
func StartDriver() { func StartDriver() {
...@@ -190,11 +232,6 @@ func StartDriver() { ...@@ -190,11 +232,6 @@ func StartDriver() {
localbinary.CurrentBinaryIsDockerMachine = true localbinary.CurrentBinaryIsDockerMachine = true
} }
// CertGenerator is used to override the default machine CertGenerator with a longer timeout.
type CertGenerator struct {
cert.X509CertGenerator
}
type ConnChecker struct { type ConnChecker struct {
} }
...@@ -207,6 +244,11 @@ func (cc *ConnChecker) Check(h *host.Host, swarm bool) (string, *auth.Options, e ...@@ -207,6 +244,11 @@ func (cc *ConnChecker) Check(h *host.Host, swarm bool) (string, *auth.Options, e
return dockerHost, authOptions, nil return dockerHost, authOptions, nil
} }
// CertGenerator is used to override the default machine CertGenerator with a longer timeout.
type CertGenerator struct {
cert.X509CertGenerator
}
// ValidateCertificate is a reimplementation of the default generator with a longer timeout. // ValidateCertificate is a reimplementation of the default generator with a longer timeout.
func (cg *CertGenerator) ValidateCertificate(addr string, authOptions *auth.Options) (bool, error) { func (cg *CertGenerator) ValidateCertificate(addr string, authOptions *auth.Options) (bool, error) {
tlsConfig, err := cg.ReadTLSConfig(addr, authOptions) tlsConfig, err := cg.ReadTLSConfig(addr, authOptions)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册