Skip to content

Commit

Permalink
Add shared SharedDir type
Browse files Browse the repository at this point in the history
  • Loading branch information
cfergeau authored and anjannath committed Jul 26, 2022
1 parent 1d9a2a1 commit 06729fd
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/fakedriver/fakedriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
13 changes: 13 additions & 0 deletions libmachine/drivers/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions libmachine/drivers/drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 11 additions & 0 deletions libmachine/drivers/rpc/client_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -73,6 +74,7 @@ const (
StartMethod = `.Start`
StopMethod = `.Stop`
KillMethod = `.Kill`
GetSharedDirsMethod = `.GetSharedDirs`
)

func (ic *InternalClient) Call(serviceMethod string, args interface{}, reply interface{}) error {
Expand Down Expand Up @@ -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
}
6 changes: 6 additions & 0 deletions libmachine/drivers/rpc/server_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 06729fd

Please sign in to comment.