提交 1fc11f56 编写于 作者: T Thomas Stromberg

Add logic for picking the default driver on a host

上级 e651eee9
......@@ -120,6 +120,7 @@ const (
minimumCPUS = 2
minimumDiskSize = "2000mb"
autoUpdate = "auto-update-drivers"
autoDetect = "auto-detect"
)
var (
......@@ -194,7 +195,7 @@ func initKubernetesFlags() {
// initDriverFlags inits the commandline flags for vm drivers
func initDriverFlags() {
startCmd.Flags().String("vm-driver", "", fmt.Sprintf("Driver is one of: %v (defaults to %s)", driver.SupportedDrivers(), driver.Default()))
startCmd.Flags().String("vm-driver", "", fmt.Sprintf("Driver is one of: %v (defaults to auto-detect)", driver.SupportedDrivers()))
startCmd.Flags().Bool(disableDriverMounts, false, "Disables the filesystem mounts provided by the hypervisors")
// kvm2
......@@ -289,6 +290,7 @@ func runStart(cmd *cobra.Command, args []string) {
}
driverName := selectDriver(oldConfig)
glog.Infof("selected: %v", driverName)
err = autoSetDriverOptions(cmd, driverName)
if err != nil {
glog.Errorf("Error autoSetOptions : %v", err)
......@@ -534,12 +536,21 @@ func showKubectlInfo(kcs *kubeconfig.Settings, k8sVersion string) error {
func selectDriver(oldConfig *cfg.Config) string {
name := viper.GetString("vm-driver")
// By default, the driver is whatever we used last time
glog.Infof("selectDriver: flag=%q, old=%v", name, oldConfig)
if name == "" {
name = driver.Default()
// By default, the driver is whatever we used last time
if oldConfig != nil {
return oldConfig.MachineConfig.VMDriver
}
options := driver.Choices()
if len(options) == 0 {
exit.WithCodeT(exit.Config, "Unable to find a usable default driver. Try specifying --vm-driver")
}
pick, alts := driver.Choose(options)
if len(options) > 1 {
out.T(out.Sparkle, `Automatically selected the '{{.driver}}' driver (alternates: {{.alternates}})`, out.V{"driver": pick.Name, "alternates": alts})
}
name = pick.Name
}
if !driver.Supported(name) {
exit.WithCodeT(exit.Failure, "The driver '{{.driver}}' is not supported on {{.os}}", out.V{"driver": name, "os": runtime.GOOS})
......
......@@ -45,6 +45,7 @@ require (
github.com/juju/version v0.0.0-20180108022336-b64dbd566305 // indirect
github.com/libvirt/libvirt-go v3.4.0+incompatible
github.com/machine-drivers/docker-machine-driver-vmware v0.1.1
github.com/machine-drivers/machine v0.16.1 // indirect
github.com/mattn/go-isatty v0.0.8
github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936
github.com/moby/hyperkit v0.0.0-20171020124204-a12cd7250bcd
......
......@@ -441,7 +441,7 @@ func createHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error
return nil, errors.Wrap(err, "error getting driver")
}
dd := def.ConfigCreator(config)
dd := def.Config(config)
data, err := json.Marshal(dd)
if err != nil {
return nil, errors.Wrap(err, "marshal")
......
......@@ -19,6 +19,9 @@ package driver
import (
"fmt"
"os"
"github.com/golang/glog"
"k8s.io/minikube/pkg/minikube/registry"
)
const (
......@@ -77,7 +80,37 @@ func FlagDefaults(name string) FlagHints {
}
}
// Default returns the default driver on this hos
func Default() string {
return VirtualBox
// Choices returns a list of drivers which are possible on this system
func Choices() []registry.DriverState {
options := []registry.DriverState{}
for _, ds := range registry.Installed() {
if !ds.State.Healthy {
glog.Warningf("%s is installed, but unhealthy: %v", ds.Name, ds.State.Error)
continue
}
options = append(options, ds)
glog.Infof("%q driver appears healthy, priority %d", ds.Name, ds.Priority)
}
return options
}
// Choose returns a suggested driver from a set of options
func Choose(options []registry.DriverState) (registry.DriverState, []registry.DriverState) {
pick := registry.DriverState{}
for _, ds := range options {
if ds.Priority > pick.Priority {
pick = ds
}
}
alternates := []registry.DriverState{}
for _, ds := range options {
if ds != pick {
alternates = append(alternates, ds)
}
}
glog.Infof("Picked: %+v", pick)
glog.Infof("Alternatives: %+v", alternates)
return pick, alternates
}
......@@ -85,11 +85,11 @@ func (api *LocalClient) NewHost(drvName string, rawDriver []byte) (*host.Host, e
var err error
if def, err = registry.Driver(drvName); err != nil {
return nil, err
} else if !def.Builtin || def.DriverCreator == nil {
} else if def.Init == nil {
return api.legacyClient.NewHost(drvName, rawDriver)
}
d := def.DriverCreator()
d := def.Init()
err = json.Unmarshal(rawDriver, d)
if err != nil {
......@@ -130,11 +130,11 @@ func (api *LocalClient) Load(name string) (*host.Host, error) {
var def registry.DriverDef
if def, err = registry.Driver(h.DriverName); err != nil {
return nil, err
} else if !def.Builtin || def.DriverCreator == nil {
} else if def.Init == nil {
return api.legacyClient.Load(name)
}
h.Driver = def.DriverCreator()
h.Driver = def.Init()
return h, json.Unmarshal(h.RawDriver, h.Driver)
}
......@@ -165,7 +165,7 @@ func CommandRunner(h *host.Host) (command.Runner, error) {
func (api *LocalClient) Create(h *host.Host) error {
if def, err := registry.Driver(h.DriverName); err != nil {
return err
} else if !def.Builtin || def.DriverCreator == nil {
} else if def.Init == nil {
return api.legacyClient.Create(h)
}
......@@ -278,5 +278,5 @@ func registerDriver(drvName string) {
}
exit.WithError("error getting driver", err)
}
plugin.RegisterDriver(def.DriverCreator())
plugin.RegisterDriver(def.Init())
}
......@@ -81,6 +81,7 @@ var styles = map[StyleEnum]style{
Check: {Prefix: "✅ "},
Celebration: {Prefix: "🎉 "},
Workaround: {Prefix: "👉 ", LowPrefix: lowIndent},
Sparkle: {Prefix: "✨ "},
// Specialized purpose styles
ISODownload: {Prefix: "💿 "},
......
......@@ -83,4 +83,5 @@ const (
Fileserver
Empty
Workaround
Sparkle
)
......@@ -20,30 +20,36 @@ package hyperkit
import (
"fmt"
"os/exec"
"github.com/docker/machine/libmachine/drivers"
"github.com/pborman/uuid"
"k8s.io/minikube/pkg/drivers/hyperkit"
cfg "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/registry"
"k8s.io/minikube/pkg/minikube/driver"
)
const (
docURL = "https://minikube.sigs.k8s.io/docs/reference/drivers/hyperkit/"
)
func init() {
if err := registry.Register(registry.DriverDef{
Name: driver.HyperKit,
Builtin: false,
ConfigCreator: createHyperkitHost,
Name: driver.HyperKit,
Config: configure,
Status: status,
Priority: registry.Preferred,
}); err != nil {
panic(fmt.Sprintf("register: %v", err))
}
}
func createHyperkitHost(config cfg.MachineConfig) interface{} {
uuID := config.UUID
if uuID == "" {
uuID = uuid.NewUUID().String()
func configure(config cfg.MachineConfig) interface{} {
u := config.UUID
if u == "" {
u = uuid.NewUUID().String()
}
return &hyperkit.Driver{
......@@ -58,9 +64,23 @@ func createHyperkitHost(config cfg.MachineConfig) interface{} {
CPU: config.CPUs,
NFSShares: config.NFSShare,
NFSSharesRoot: config.NFSSharesRoot,
UUID: uuID,
UUID: u,
VpnKitSock: config.HyperkitVpnKitSock,
VSockPorts: config.HyperkitVSockPorts,
Cmdline: "loglevel=3 console=ttyS0 console=tty0 noembed nomodeset norestore waitusb=10 systemd.legacy_systemd_cgroup_controller=yes random.trust_cpu=on hw_rng_model=virtio base host=" + cfg.GetMachineName(),
}
}
func status() registry.State {
path, err := exec.LookPath("hyperkit")
if err != nil {
return registry.State{Error: err, Fix: "Run 'brew install hyperkit'", Doc: docURL}
}
err = exec.Command(path, "-v").Run()
if err != nil {
return registry.State{Installed: true, Error: err, Fix: "Run 'brew install hyperkit'", Doc: docURL}
}
return registry.State{Installed: true, Healthy: true}
}
......@@ -30,17 +30,15 @@ import (
func init() {
registry.Register(registry.DriverDef{
Name: driver.HyperV,
Builtin: true,
ConfigCreator: createHypervHost,
DriverCreator: func() drivers.Driver {
return hyperv.NewDriver("", "")
},
Init: func() drivers.Driver { return hyperv.NewDriver("", "") },
Config: configure,
InstallStatus: status,
Priority: registry.Preferred,
})
}
func createHypervHost(config cfg.MachineConfig) interface{} {
func configure(config cfg.MachineConfig) *hyperv.Driver {
d := hyperv.NewDriver(cfg.GetMachineName(), localpath.MiniPath())
d.Boot2DockerURL = config.Downloader.GetISOFileURI(config.MinikubeISO)
d.VSwitch = config.HypervVirtualSwitch
d.MemSize = config.Memory
......@@ -48,6 +46,18 @@ func createHypervHost(config cfg.MachineConfig) interface{} {
d.DiskSize = config.DiskSize
d.SSHUser = "docker"
d.DisableDynamicMemory = true // default to disable dynamic memory as minikube is unlikely to work properly with dynamic memory
return d
}
func status() registry.Status {
path, err := exec.LookPath("powershell")
if err != nil {
return registry.Status{Error: err}
}
err = exec.Command(path, "Get-WindowsOptionalFeature", "-FeatureName", "Microsoft-Hyper-V-All", "-Online").Run()
if err != nil {
return registry.Status{Installed: false, Error: err, Fix: "Start PowerShell as Administrator, and run: 'Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All'", Doc: docURL}
}
return registry.Status{Installed: true, Healthy: true}
}
\ No newline at end of file
......@@ -20,46 +20,35 @@ package kvm2
import (
"fmt"
"os/exec"
"path/filepath"
"github.com/docker/machine/libmachine/drivers"
"k8s.io/minikube/pkg/drivers/kvm"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/registry"
)
const (
docURL = "https://minikube.sigs.k8s.io/docs/reference/drivers/kvm2/"
)
func init() {
if err := registry.Register(registry.DriverDef{
Name: driver.KVM2,
Builtin: false,
ConfigCreator: createKVM2Host,
Name: driver.KVM2,
Config: configure,
Status: status,
Priority: registry.Preferred,
}); err != nil {
panic(fmt.Sprintf("register failed: %v", err))
}
}
// Delete this once the following PR is merged:
// https://github.com/dhiltgen/docker-machine-kvm/pull/68
type kvmDriver struct {
*drivers.BaseDriver
Memory int
DiskSize int
CPU int
Network string
PrivateNetwork string
ISO string
Boot2DockerURL string
DiskPath string
GPU bool
Hidden bool
ConnectionURI string
}
func createKVM2Host(mc config.MachineConfig) interface{} {
func configure(mc config.MachineConfig) interface{} {
name := config.GetMachineName()
return &kvmDriver{
return kvm.Driver{
BaseDriver: &drivers.BaseDriver{
MachineName: name,
StorePath: localpath.MiniPath(),
......@@ -78,3 +67,22 @@ func createKVM2Host(mc config.MachineConfig) interface{} {
ConnectionURI: mc.KVMQemuURI,
}
}
func status() registry.State {
path, err := exec.LookPath("virt-host-validate")
if err != nil {
return registry.State{Error: err, Fix: "Install libvirt", Doc: docURL}
}
err = exec.Command(path, "qemu").Run()
if err != nil {
return registry.State{Installed: true, Error: err, Fix: "Check output of 'virt-host-validate qemu'", Doc: docURL}
}
err = exec.Command("virsh", "list").Run()
if err != nil {
return registry.State{Installed: true, Error: err, Fix: "Check output of 'virsh list'", Doc: docURL}
}
return registry.State{Installed: true, Healthy: true}
}
......@@ -18,6 +18,7 @@ package none
import (
"fmt"
"os/exec"
"github.com/docker/machine/libmachine/drivers"
"k8s.io/minikube/pkg/drivers/none"
......@@ -29,22 +30,28 @@ import (
func init() {
if err := registry.Register(registry.DriverDef{
Name: driver.None,
Builtin: true,
ConfigCreator: createNoneHost,
DriverCreator: func() drivers.Driver {
return none.NewDriver(none.Config{})
},
Name: driver.None,
Config: configure,
Init: func() drivers.Driver { return none.NewDriver(none.Config{}) },
Status: status,
Priority: registry.Discouraged, // requires root
}); err != nil {
panic(fmt.Sprintf("register failed: %v", err))
}
}
// createNoneHost creates a none Driver from a MachineConfig
func createNoneHost(mc config.MachineConfig) interface{} {
func configure(mc config.MachineConfig) interface{} {
return none.NewDriver(none.Config{
MachineName: config.GetMachineName(),
StorePath: localpath.MiniPath(),
ContainerRuntime: mc.ContainerRuntime,
})
}
func status() registry.State {
_, err := exec.LookPath("systemctl")
if err != nil {
return registry.State{Error: err, Fix: "Use a systemd based Linux distribution", Doc: "https://minikube.sigs.k8s.io/docs/reference/drivers/none/"}
}
return registry.State{Installed: true, Healthy: true}
}
......@@ -20,6 +20,7 @@ package parallels
import (
"fmt"
"os/exec"
parallels "github.com/Parallels/docker-machine-parallels"
"github.com/docker/machine/libmachine/drivers"
......@@ -31,12 +32,11 @@ import (
func init() {
err := registry.Register(registry.DriverDef{
Name: driver.Parallels,
Builtin: true,
ConfigCreator: createParallelsHost,
DriverCreator: func() drivers.Driver {
return parallels.NewDriver("", "")
},
Name: driver.Parallels,
Config: configure,
Status: status,
Priority: registry.Default,
Init: func() drivers.Driver { return parallels.NewDriver("", "") },
})
if err != nil {
panic(fmt.Sprintf("unable to register: %v", err))
......@@ -44,7 +44,7 @@ func init() {
}
func createParallelsHost(config cfg.MachineConfig) interface{} {
func configure(config cfg.MachineConfig) interface{} {
d := parallels.NewDriver(cfg.GetMachineName(), localpath.MiniPath()).(*parallels.Driver)
d.Boot2DockerURL = config.Downloader.GetISOFileURI(config.MinikubeISO)
d.Memory = config.Memory
......@@ -52,3 +52,11 @@ func createParallelsHost(config cfg.MachineConfig) interface{} {
d.DiskSize = config.DiskSize
return d
}
func status() registry.State {
_, err := exec.LookPath("docker-machine-driver-parallels")
if err != nil {
return registry.State{Error: err, Fix: "Install docker-machine-driver-parallels", Doc: "https://minikube.sigs.k8s.io/docs/reference/drivers/parallels/"}
}
return registry.State{Installed: true, Healthy: true}
}
/*
Copyright 2018 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package virtualbox
......@@ -18,6 +18,7 @@ package virtualbox
import (
"fmt"
"os/exec"
"github.com/docker/machine/drivers/virtualbox"
"github.com/docker/machine/libmachine/drivers"
......@@ -27,25 +28,26 @@ import (
"k8s.io/minikube/pkg/minikube/registry"
)
const defaultVirtualboxNicType = "virtio"
const (
defaultVirtualboxNicType = "virtio"
docURL = "https://minikube.sigs.k8s.io/docs/reference/drivers/virtualbox/"
)
func init() {
err := registry.Register(registry.DriverDef{
Name: driver.VirtualBox,
Builtin: true,
ConfigCreator: createVirtualboxHost,
DriverCreator: func() drivers.Driver {
return virtualbox.NewDriver("", "")
},
Name: driver.VirtualBox,
Config: configure,
Status: status,
Priority: registry.Fallback,
Init: func() drivers.Driver { return virtualbox.NewDriver("", "") },
})
if err != nil {
panic(fmt.Sprintf("unable to register: %v", err))
}
}
func createVirtualboxHost(mc config.MachineConfig) interface{} {
func configure(mc config.MachineConfig) interface{} {
d := virtualbox.NewDriver(config.GetMachineName(), localpath.MiniPath())
d.Boot2DockerURL = mc.Downloader.GetISOFileURI(mc.MinikubeISO)
d.Memory = mc.Memory
d.CPU = mc.CPUs
......@@ -57,6 +59,19 @@ func createVirtualboxHost(mc config.MachineConfig) interface{} {
d.HostOnlyNicType = defaultVirtualboxNicType
d.DNSProxy = mc.DNSProxy
d.HostDNSResolver = mc.HostDNSResolver
return d
}
func status() registry.State {
path, err := exec.LookPath("vboxmanage")
if err != nil {
return registry.State{Error: err, Fix: "Install VirtualBox", Doc: docURL}
}
err = exec.Command(path, "list", "hostinfo").Run()
if err != nil {
return registry.State{Installed: true, Error: err, Fix: "Install the latest version of VirtualBox", Doc: docURL}
}
return registry.State{Installed: true, Healthy: true}
}
......@@ -18,6 +18,7 @@ package vmware
import (
"fmt"
"os/exec"
vmwcfg "github.com/machine-drivers/docker-machine-driver-vmware/pkg/drivers/vmware/config"
"k8s.io/minikube/pkg/minikube/config"
......@@ -28,16 +29,17 @@ import (
func init() {
err := registry.Register(registry.DriverDef{
Name: driver.VMware,
Builtin: false,
ConfigCreator: createVMwareHost,
Name: driver.VMware,
Config: configure,
Priority: registry.Default,
Status: status,
})
if err != nil {
panic(fmt.Sprintf("unable to register: %v", err))
}
}
func createVMwareHost(mc config.MachineConfig) interface{} {
func configure(mc config.MachineConfig) interface{} {
d := vmwcfg.NewConfig(config.GetMachineName(), localpath.MiniPath())
d.Boot2DockerURL = mc.Downloader.GetISOFileURI(mc.MinikubeISO)
d.Memory = mc.Memory
......@@ -49,3 +51,11 @@ func createVMwareHost(mc config.MachineConfig) interface{} {
d.ISO = d.ResolveStorePath("boot2docker.iso")
return d
}
func status() registry.State {
_, err := exec.LookPath("docker-machine-driver-vmware")
if err != nil {
return registry.State{Error: err, Fix: "Install docker-machine-driver-vmware", Doc: "https://minikube.sigs.k8s.io/docs/reference/drivers/vmware/"}
}
return registry.State{Installed: true, Healthy: true}
}
......@@ -20,30 +20,29 @@ package vmwarefusion
import (
"fmt"
"os/exec"
"github.com/docker/machine/drivers/vmwarefusion"
"github.com/docker/machine/libmachine/drivers"
cfg "k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/driver"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/registry"
"k8s.io/minikube/pkg/minikube/driver"
)
func init() {
if err := registry.Register(registry.DriverDef{
Name: driver.VMwareFusion,
Builtin: true,
ConfigCreator: createVMwareFusionHost,
DriverCreator: func() drivers.Driver {
return vmwarefusion.NewDriver("", "")
},
Name: driver.VMwareFusion,
Config: configure,
Status: status,
Init: func() drivers.Driver { return vmwarefusion.NewDriver("", "") },
Priority: registry.Deprecated,
}); err != nil {
panic(fmt.Sprintf("register: %v", err))
}
}
func createVMwareFusionHost(config cfg.MachineConfig) interface{} {
func configure(config cfg.MachineConfig) interface{} {
d := vmwarefusion.NewDriver(cfg.GetMachineName(), localpath.MiniPath()).(*vmwarefusion.Driver)
d.Boot2DockerURL = config.Downloader.GetISOFileURI(config.MinikubeISO)
d.Memory = config.Memory
......@@ -55,3 +54,11 @@ func createVMwareFusionHost(config cfg.MachineConfig) interface{} {
d.ISO = d.ResolveStorePath("boot2docker.iso")
return d
}
func status() registry.State {
_, err := exec.LookPath("vmrun")
if err != nil {
return registry.State{Error: err, Fix: "Install VMWare Fusion", Doc: "https://minikube.sigs.k8s.io/docs/reference/drivers/vmwarefusion/"}
}
return registry.State{Installed: true, Healthy: true}
}
......@@ -17,15 +17,31 @@ limitations under the License.
package registry
import (
"fmt"
"sync"
"github.com/docker/machine/libmachine/drivers"
"github.com/golang/glog"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/config"
)
type Priority int
const (
// Priority for default driver selection
Unknown Priority = iota
Discouraged
Deprecated
Fallback
Default
Preferred
StronglyPreferred
)
var (
registry = createRegistry()
// ErrDriverNameExist is the error returned when trying to register a driver
// which already exists in registry
ErrDriverNameExist = errors.New("registry: duplicated driver name")
......@@ -47,31 +63,55 @@ type Registry interface {
List() []DriverDef
}
// ConfigFactory is a function that creates a driver config from MachineConfig
type ConfigFactory func(config.MachineConfig) interface{}
// Configurator emits a struct to be marshalled into JSON for Machine Driver
type Configurator func(config.MachineConfig) interface{}
// Loader is a function that loads a byte stream and creates a driver.
type Loader func() drivers.Driver
// Status checks if a driver is available, offering a
type StatusChecker func() State
// State is the current state of the driver and its dependencies
type State struct {
Installed bool
Healthy bool
Error error
Fix string
Doc string
}
// State is metadata relating to a driver and status
type DriverState struct {
Name string
Priority Priority
State State
}
// DriverFactory is a function that loads a byte stream and creates a driver.
type DriverFactory func() drivers.Driver
func (d DriverState) String() string {
return d.Name
}
// DriverDef defines a machine driver metadata. It tells minikube how to initialize
// and load drivers.
// DriverDef defines how to initialize and load a machine driver
type DriverDef struct {
// Name of the machine driver. It has to be unique.
Name string
// BuiltIn indicates if the driver is builtin minikube binary, or the driver is
// triggered through RPC.
Builtin bool
// Config is a function that emits a configured driver struct
Config Configurator
// ConfigCreator generates a raw driver object by minikube's machine config.
ConfigCreator ConfigFactory
// Init is a function that initializes a machine driver, if built-in to the minikube binary
Init Loader
// DriverCreator is the factory method that creates a machine driver instance.
DriverCreator DriverFactory
// Status returns the installation status of the driver
Status StatusChecker
// Priority returns the prioritization for selecting a driver by default.
Priority Priority
}
func (d DriverDef) String() string {
return fmt.Sprintf("{name: %s, builtin: %t}", d.Name, d.Builtin)
return d.Name
}
type driverRegistry struct {
......@@ -85,10 +125,6 @@ func createRegistry() *driverRegistry {
}
}
var (
registry = createRegistry()
)
// ListDrivers lists all drivers in registry
func ListDrivers() []DriverDef {
return registry.List()
......@@ -104,6 +140,32 @@ func Driver(name string) (DriverDef, error) {
return registry.Driver(name)
}
// Installed returns a list of installed drivers
func Installed() []DriverState {
sts := []DriverState{}
for _, d := range registry.List() {
if d.Status == nil {
glog.Errorf("%q does not implement Status", d.Name)
continue
}
s := d.Status()
if s.Installed {
sts = append(sts, DriverState{Name: d.Name, Priority: d.Priority, State: s})
}
}
return sts
}
// Status returns the state of a driver
func Status(name string) (State, error) {
d, err := registry.Driver(name)
if err != nil {
return State{}, err
}
return d.Status(), nil
}
// Register registers a driver with minikube
func (r *driverRegistry) Register(def DriverDef) error {
r.lock.Lock()
defer r.lock.Unlock()
......@@ -116,6 +178,7 @@ func (r *driverRegistry) Register(def DriverDef) error {
return nil
}
// List returns a list of registered drivers
func (r *driverRegistry) List() []DriverDef {
r.lock.Lock()
defer r.lock.Unlock()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册