本文整理汇总了Golang中github.com/docker/docker/volume.Volume.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang Volume.Name方法的具体用法?Golang Volume.Name怎么用?Golang Volume.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/docker/docker/volume.Volume
的用法示例。
在下文中一共展示了Volume.Name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: volumeToAPIType
// volumeToAPIType converts a volume.Volume to the type used by the remote API
func volumeToAPIType(v volume.Volume) *types.Volume {
return &types.Volume{
Name: v.Name(),
Driver: v.DriverName(),
Mountpoint: v.Path(),
}
}
示例2: CopyImagePathContent
// CopyImagePathContent copies files in destination to the volume.
func (container *Container) CopyImagePathContent(v volume.Volume, destination string) error {
rootfs, err := symlink.FollowSymlinkInScope(filepath.Join(container.BaseFS, destination), container.BaseFS)
if err != nil {
return err
}
if _, err = ioutil.ReadDir(rootfs); err != nil {
if os.IsNotExist(err) {
return nil
}
return err
}
id := stringid.GenerateNonCryptoID()
path, err := v.Mount(id)
if err != nil {
return err
}
defer func() {
if err := v.Unmount(id); err != nil {
logrus.Warnf("error while unmounting volume %s: %v", v.Name(), err)
}
}()
return copyExistingContents(rootfs, path)
}
示例3: Count
// Count returns the usage count of the passed in volume
func (s *volumeStore) Count(v volume.Volume) int {
vc, exists := s.vols[v.Name()]
if !exists {
return 0
}
return vc.count
}
示例4: Remove
// Remove deletes a volume.
func (d *FakeDriver) Remove(v volume.Volume) error {
if _, exists := d.vols[v.Name()]; !exists {
return fmt.Errorf("no such volume")
}
delete(d.vols, v.Name())
return nil
}
示例5: volumeExists
// volumeExists returns if the volume is still present in the driver.
// An error is returned if there was an issue communicating with the driver.
func volumeExists(v volume.Volume) (bool, error) {
exists, err := lookupVolume(v.DriverName(), v.Name())
if err != nil {
return false, err
}
return exists != nil, nil
}
示例6: Remove
// Remove removes the requested volume. A volume is not removed if the usage count is > 0
func (s *VolumeStore) Remove(v volume.Volume) error {
name := normaliseVolumeName(v.Name())
s.locks.Lock(name)
defer s.locks.Unlock(name)
logrus.Debugf("Removing volume reference: driver %s, name %s", v.DriverName(), name)
vc, exists := s.get(name)
if !exists {
return ErrNoSuchVolume
}
if vc.count > 0 {
return ErrVolumeInUse
}
vd, err := volumedrivers.GetDriver(vc.DriverName())
if err != nil {
return err
}
if err := vd.Remove(vc.Volume); err != nil {
return err
}
s.remove(name)
return nil
}
示例7: Refs
// Refs gets the current list of refs for the given volume
func (s *VolumeStore) Refs(v volume.Volume) []string {
name := v.Name()
s.locks.Lock(name)
defer s.locks.Unlock(name)
return s.getRefs(name)
}
示例8: Count
// Count returns the usage count of the passed in volume
func (s *VolumeStore) Count(v volume.Volume) uint {
s.mu.Lock()
defer s.mu.Unlock()
vc, exists := s.vols[normaliseVolumeName(v.Name())]
if !exists {
return 0
}
return vc.count
}
示例9: Count
// Count returns the usage count of the passed in volume
func (s *volumeStore) Count(v volume.Volume) int {
s.mu.Lock()
defer s.mu.Unlock()
vc, exists := s.vols[v.Name()]
if !exists {
return 0
}
return vc.count
}
示例10: AddMountPointWithVolume
// AddMountPointWithVolume adds a new mount point configured with a volume to the container.
func (container *Container) AddMountPointWithVolume(destination string, vol volume.Volume, rw bool) {
container.MountPoints[destination] = &volume.MountPoint{
Name: vol.Name(),
Driver: vol.DriverName(),
Destination: destination,
RW: rw,
Volume: vol,
CopyData: volume.DefaultCopyMode,
}
}
示例11: Decrement
// Decrement decrements the usage count of the passed in volume by 1
func (s *volumeStore) Decrement(v volume.Volume) {
s.mu.Lock()
defer s.mu.Unlock()
vc, exists := s.vols[v.Name()]
if !exists {
return
}
vc.count--
return
}
示例12: Count
// Count returns the usage count of the passed in volume
func (s *VolumeStore) Count(v volume.Volume) uint {
name := normaliseVolumeName(v.Name())
s.locks.Lock(name)
defer s.locks.Unlock(name)
vc, exists := s.get(name)
if !exists {
return 0
}
return vc.count
}
示例13: volumeToAPIType
// volumeToAPIType converts a volume.Volume to the type used by the remote API
func volumeToAPIType(v volume.Volume) *types.Volume {
tv := &types.Volume{
Name: v.Name(),
Driver: v.DriverName(),
}
if v, ok := v.(interface {
Labels() map[string]string
}); ok {
tv.Labels = v.Labels()
}
return tv
}
示例14: Increment
// Increment increments the usage count of the passed in volume by 1
func (s *volumeStore) Increment(v volume.Volume) {
s.mu.Lock()
defer s.mu.Unlock()
vc, exists := s.vols[v.Name()]
if !exists {
s.vols[v.Name()] = &volumeCounter{v, 1}
return
}
vc.count++
return
}
示例15: Decrement
// Decrement decrements the usage count of the passed in volume by 1
func (s *volumeStore) Decrement(v volume.Volume) {
s.mu.Lock()
defer s.mu.Unlock()
logrus.Debugf("Decrementing volume reference: driver %s, name %s", v.DriverName(), v.Name())
vc, exists := s.vols[v.Name()]
if !exists {
return
}
vc.count--
return
}