diff --git a/drivers/errdriver/error.go b/drivers/errdriver/error.go index fd9e143052..088ecbfe50 100644 --- a/drivers/errdriver/error.go +++ b/drivers/errdriver/error.go @@ -76,6 +76,10 @@ func (d *Driver) GetSSHUsername() string { return "" } +func (d *Driver) GetBundleName() (string, error) { + return "", NotLoadable{d.Name} +} + func (d *Driver) GetState() (state.State, error) { return state.Error, NotLoadable{d.Name} } diff --git a/drivers/hyperv/hyperv.go b/drivers/hyperv/hyperv.go index 30041e855b..12ae67f00a 100644 --- a/drivers/hyperv/hyperv.go +++ b/drivers/hyperv/hyperv.go @@ -14,7 +14,7 @@ import ( type Driver struct { *drivers.BaseDriver CrcDiskCopier CRCDiskCopier - BundlePath string + BundleName string VirtualSwitch string DiskPath string DiskPathUrl string @@ -85,7 +85,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { } func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { - d.BundlePath = flags.String("hyperv-bundlepath-url") + d.BundleName = flags.String("hyperv-bundlepath-url") d.VirtualSwitch = flags.String("hyperv-virtual-switch") d.Memory = flags.Int("hyperv-memory") d.CPU = flags.Int("hyperv-cpu-count") diff --git a/drivers/virtualbox/virtualbox.go b/drivers/virtualbox/virtualbox.go index 8f4a2ec1c7..ed6a5a21be 100644 --- a/drivers/virtualbox/virtualbox.go +++ b/drivers/virtualbox/virtualbox.go @@ -22,7 +22,7 @@ import ( const ( defaultCPU = 4 defaultMemory = 8192 - defaultBundlePath = "" + defaultBundleName = "" defaultHostOnlyCIDR = "192.168.99.1/24" defaultHostOnlyNictype = "82540EM" defaultHostOnlyPromiscMode = "deny" @@ -43,8 +43,6 @@ var ( type Driver struct { *drivers.BaseDriver - // CRC System bundle - BundlePath string VBoxManager HostInterfaces logsReader LogsReader @@ -124,8 +122,8 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { mcnflag.StringFlag{ Name: "virtualbox-bundlepath-url", Usage: "The URL of the crc bundlepath. Defaults to the latest available version", - Value: defaultBundlePath, - EnvVar: "VIRTUALBOX_BundlePath_URL", + Value: defaultBundleName, + EnvVar: "VIRTUALBOX_BundleName_URL", }, mcnflag.BoolFlag{ Name: "virtualbox-host-dns-resolver", diff --git a/libmachine/drivers/base.go b/libmachine/drivers/base.go index 04537a6e39..222d9335e2 100644 --- a/libmachine/drivers/base.go +++ b/libmachine/drivers/base.go @@ -20,6 +20,7 @@ type BaseDriver struct { SSHPort int SSHKeyPath string StorePath string + BundleName string } // DriverName returns the name of the driver @@ -79,3 +80,8 @@ func (d *BaseDriver) PreCreateCheck() error { func (d *BaseDriver) ResolveStorePath(file string) string { return filepath.Join(d.StorePath, "machines", d.MachineName, file) } + +// Returns the name of the bundle which was used to create this machine +func (d* BaseDriver) GetBundleName() (string, error) { + return d.BundleName, nil +} diff --git a/libmachine/drivers/drivers.go b/libmachine/drivers/drivers.go index 2d967b5bc0..40233d55e9 100644 --- a/libmachine/drivers/drivers.go +++ b/libmachine/drivers/drivers.go @@ -41,6 +41,9 @@ type Driver interface { // GetSSHUsername returns username for use with ssh GetSSHUsername() string + // GetBundleName() Returns the name of the unpacked bundle which was used to create this machine + GetBundleName() (string, error) + // GetURL returns a Docker compatible host URL for connecting to this host // e.g. tcp://1.2.3.4:2376 GetURL() (string, error) diff --git a/libmachine/drivers/rpc/client_driver.go b/libmachine/drivers/rpc/client_driver.go index 76896f167a..dc0cd50ec9 100644 --- a/libmachine/drivers/rpc/client_driver.go +++ b/libmachine/drivers/rpc/client_driver.go @@ -74,6 +74,7 @@ const ( GetSSHKeyPathMethod = `.GetSSHKeyPath` GetSSHPortMethod = `.GetSSHPort` GetSSHUsernameMethod = `.GetSSHUsername` + GetBundleNameMethod = `.GetBundleName` GetStateMethod = `.GetState` PreCreateCheckMethod = `.PreCreateCheck` CreateMethod = `.Create` @@ -334,6 +335,10 @@ func (c *RPCClientDriver) GetSSHUsername() string { return username } +func (c *RPCClientDriver) GetBundleName() (string, error) { + return c.rpcStringCall(GetBundleNameMethod) +} + func (c *RPCClientDriver) GetState() (state.State, error) { var s state.State diff --git a/libmachine/drivers/rpc/server_driver.go b/libmachine/drivers/rpc/server_driver.go index a685256978..1ab03dc91e 100644 --- a/libmachine/drivers/rpc/server_driver.go +++ b/libmachine/drivers/rpc/server_driver.go @@ -181,6 +181,12 @@ func (r *RPCServerDriver) GetSSHUsername(_ *struct{}, reply *string) error { return nil } +func (r *RPCServerDriver) GetBundleName(_ *struct{}, reply *string) error { + path, err := r.ActualDriver.GetBundleName() + *reply = path + return err +} + func (r *RPCServerDriver) GetURL(_ *struct{}, reply *string) error { info, err := r.ActualDriver.GetURL() *reply = info