github.com/slava-ustovytski/docker@v1.8.2-rc1/volume/drivers/adapter.go (about)

     1  package volumedrivers
     2  
     3  import "github.com/docker/docker/volume"
     4  
     5  type volumeDriverAdapter struct {
     6  	name  string
     7  	proxy *volumeDriverProxy
     8  }
     9  
    10  func (a *volumeDriverAdapter) Name() string {
    11  	return a.name
    12  }
    13  
    14  func (a *volumeDriverAdapter) Create(name string) (volume.Volume, error) {
    15  	err := a.proxy.Create(name)
    16  	if err != nil {
    17  		return nil, err
    18  	}
    19  	return &volumeAdapter{
    20  		proxy:      a.proxy,
    21  		name:       name,
    22  		driverName: a.name}, nil
    23  }
    24  
    25  func (a *volumeDriverAdapter) Remove(v volume.Volume) error {
    26  	return a.proxy.Remove(v.Name())
    27  }
    28  
    29  type volumeAdapter struct {
    30  	proxy      *volumeDriverProxy
    31  	name       string
    32  	driverName string
    33  	eMount     string // ephemeral host volume path
    34  }
    35  
    36  func (a *volumeAdapter) Name() string {
    37  	return a.name
    38  }
    39  
    40  func (a *volumeAdapter) DriverName() string {
    41  	return a.driverName
    42  }
    43  
    44  func (a *volumeAdapter) Path() string {
    45  	if len(a.eMount) > 0 {
    46  		return a.eMount
    47  	}
    48  	m, _ := a.proxy.Path(a.name)
    49  	return m
    50  }
    51  
    52  func (a *volumeAdapter) Mount() (string, error) {
    53  	var err error
    54  	a.eMount, err = a.proxy.Mount(a.name)
    55  	return a.eMount, err
    56  }
    57  
    58  func (a *volumeAdapter) Unmount() error {
    59  	return a.proxy.Unmount(a.name)
    60  }