diff --git a/drivers/fakedriver/fakedriver.go b/drivers/fakedriver/fakedriver.go index 566b77e43..b6145635d 100644 --- a/drivers/fakedriver/fakedriver.go +++ b/drivers/fakedriver/fakedriver.go @@ -67,3 +67,7 @@ func (d *Driver) Remove() error { func (d *Driver) Upgrade() error { return nil } + +func (d *Driver) GetSharedDirs() ([]drivers.SharedDir, error) { + return []drivers.SharedDir{}, nil +} diff --git a/libmachine/drivers/base.go b/libmachine/drivers/base.go index 6e88ce701..2c934c1c1 100644 --- a/libmachine/drivers/base.go +++ b/libmachine/drivers/base.go @@ -21,6 +21,15 @@ type VMDriver struct { Memory int CPU int DiskCapacity uint64 // bytes + SharedDirs []SharedDir +} + +type SharedDir struct { + ReadOnly bool + Source string + Tag string + Target string + Type string } // DriverName returns the name of the driver @@ -67,3 +76,7 @@ func (d *BaseDriver) GetBundleName() (string, error) { func (d *BaseDriver) UpdateConfigRaw(rawData []byte) error { return ErrNotImplemented } + +func (d *VMDriver) GetSharedDirs() ([]SharedDir, error) { + return d.SharedDirs, nil +} diff --git a/libmachine/drivers/drivers.go b/libmachine/drivers/drivers.go index c139be692..fcdbf1947 100644 --- a/libmachine/drivers/drivers.go +++ b/libmachine/drivers/drivers.go @@ -27,6 +27,8 @@ type Driver interface { // GetBundleName() Returns the name of the unpacked bundle which was used to create this machine GetBundleName() (string, error) + GetSharedDirs() ([]SharedDir, error) + // GetState returns the state that the host is in (running, stopped, etc) GetState() (state.State, error) diff --git a/libmachine/drivers/rpc/client_driver.go b/libmachine/drivers/rpc/client_driver.go index 36aee3b1e..f7d92049b 100644 --- a/libmachine/drivers/rpc/client_driver.go +++ b/libmachine/drivers/rpc/client_driver.go @@ -7,6 +7,7 @@ import ( "sync" "time" + "github.com/code-ready/machine/libmachine/drivers" "github.com/code-ready/machine/libmachine/drivers/plugin/localbinary" "github.com/code-ready/machine/libmachine/state" "github.com/code-ready/machine/libmachine/version" @@ -73,6 +74,7 @@ const ( StartMethod = `.Start` StopMethod = `.Stop` KillMethod = `.Kill` + GetSharedDirsMethod = `.GetSharedDirs` ) func (ic *InternalClient) Call(serviceMethod string, args interface{}, reply interface{}) error { @@ -310,3 +312,12 @@ func (c *RPCClientDriver) Stop() error { func (c *RPCClientDriver) Kill() error { return c.Client.Call(KillMethod, struct{}{}, nil) } + +func (c *RPCClientDriver) GetSharedDirs() ([]drivers.SharedDir, error) { + var sharedDirs []drivers.SharedDir + if err := c.Client.Call(GetSharedDirsMethod, struct{}{}, &sharedDirs); err != nil { + return []drivers.SharedDir{}, err + } + + return sharedDirs, nil +} diff --git a/libmachine/drivers/rpc/server_driver.go b/libmachine/drivers/rpc/server_driver.go index 59bde528f..f73a5d6a1 100644 --- a/libmachine/drivers/rpc/server_driver.go +++ b/libmachine/drivers/rpc/server_driver.go @@ -137,3 +137,9 @@ func (r *RPCServerDriver) Heartbeat(_ *struct{}, _ *struct{}) error { r.HeartbeatCh <- true return nil } + +func (r *RPCServerDriver) GetSharedDirs(_ *struct{}, reply *[]drivers.SharedDir) error { + sharedDirs, err := r.ActualDriver.GetSharedDirs() + *reply = sharedDirs + return err +}