Remove out-of-process driver startup.
parent
c3b56fa10b
commit
e9980356f1
|
@ -22,9 +22,9 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/machine/drivers/virtualbox"
|
||||
"github.com/docker/machine/libmachine"
|
||||
"github.com/docker/machine/libmachine/auth"
|
||||
"github.com/docker/machine/libmachine/drivers"
|
||||
"github.com/docker/machine/libmachine/drivers/rpc"
|
||||
"github.com/docker/machine/libmachine/engine"
|
||||
"github.com/docker/machine/libmachine/host"
|
||||
|
@ -91,18 +91,16 @@ func StartCluster(h *host.Host) (string, error) {
|
|||
}
|
||||
|
||||
func createHost(api libmachine.API) (*host.Host, error) {
|
||||
rawDriver, err := json.Marshal(&drivers.BaseDriver{
|
||||
MachineName: constants.MachineName,
|
||||
StorePath: constants.Minipath,
|
||||
})
|
||||
driver := virtualbox.NewDriver(constants.MachineName, constants.Minipath)
|
||||
data, err := json.Marshal(driver)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error attempting to marshal bare driver data: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
driverName := "virtualbox"
|
||||
h, err := api.NewHost(driverName, rawDriver)
|
||||
h, err := api.NewHost(driverName, data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error getting new host: %s", err)
|
||||
return nil, fmt.Errorf("Error creating new host: %s", err)
|
||||
}
|
||||
|
||||
setHostOptions(h)
|
||||
|
|
|
@ -4,13 +4,14 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/docker/machine/libmachine/state"
|
||||
"github.com/kubernetes/minikube/cli/constants"
|
||||
"github.com/kubernetes/minikube/cli/tests"
|
||||
)
|
||||
|
||||
func TestCreateHost(t *testing.T) {
|
||||
api := &tests.MockAPI{}
|
||||
|
||||
exists, _ := api.Exists(machineName)
|
||||
exists, _ := api.Exists(constants.MachineName)
|
||||
if exists {
|
||||
t.Fatal("Machine already exists.")
|
||||
}
|
||||
|
@ -18,12 +19,12 @@ func TestCreateHost(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("Error creating host: %v", err)
|
||||
}
|
||||
exists, _ = api.Exists(machineName)
|
||||
exists, _ = api.Exists(constants.MachineName)
|
||||
if !exists {
|
||||
t.Fatal("Machine does not exist, but should.")
|
||||
}
|
||||
|
||||
h, err := api.Load(machineName)
|
||||
h, err := api.Load(constants.MachineName)
|
||||
if err != nil {
|
||||
t.Fatalf("Error loading machine: %v", err)
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/docker/machine/libmachine/drivers/plugin/localbinary"
|
||||
"github.com/kubernetes/minikube/cli/machine"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -29,8 +27,6 @@ var RootCmd = &cobra.Command{
|
|||
Long: `Minikube is a CLI tool that provisions and manages single-node Kubernetes
|
||||
clusters optimized for development workflows.
|
||||
`,
|
||||
Run: runRoot,
|
||||
PersistentPreRun: preRunRoot,
|
||||
}
|
||||
|
||||
// Execute adds all child commands to the root command sets flags appropriately.
|
||||
|
@ -42,24 +38,6 @@ func Execute() {
|
|||
}
|
||||
}
|
||||
|
||||
func runRoot(cmd *cobra.Command, args []string) {
|
||||
// The libmachine driver model attempts to start the same binary it's run from as a "driver" process.
|
||||
// If this environment varialbe is set, we have to act as a "driver" isntead of a CLI.
|
||||
if os.Getenv(localbinary.PluginEnvKey) == localbinary.PluginEnvVal {
|
||||
driverName := os.Getenv(localbinary.PluginEnvDriverName)
|
||||
machine.StartDriver(driverName)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func preRunRoot(cmd *cobra.Command, args []string) {
|
||||
// Libmachine code uses this boolean to indicate that this process should run as the main CLI, not as
|
||||
// a "driver".
|
||||
if os.Getenv(localbinary.PluginEnvKey) != localbinary.PluginEnvVal {
|
||||
localbinary.CurrentBinaryIsDockerMachine = true
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
cobra.OnInitialize(initConfig)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue