當前位置: 首頁>>代碼示例>>Golang>>正文


Golang volume.Volume類代碼示例

本文整理匯總了Golang中github.com/docker/docker/volume.Volume的典型用法代碼示例。如果您正苦於以下問題:Golang Volume類的具體用法?Golang Volume怎麽用?Golang Volume使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Volume類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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
}
開發者ID:hurrygeek,項目名稱:docker,代碼行數:8,代碼來源:volumes.go

示例2: removeVolume

func removeVolume(v volume.Volume) error {
	vd, err := getVolumeDriver(v.DriverName())
	if err != nil {
		return nil
	}
	return vd.Remove(v)
}
開發者ID:fwalker,項目名稱:dashboard,代碼行數:7,代碼來源:volumes.go

示例3: 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
}
開發者ID:moxiegirl,項目名稱:docker,代碼行數:8,代碼來源:testutils.go

示例4: 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
}
開發者ID:jfrazelle,項目名稱:docker,代碼行數:9,代碼來源:store.go

示例5: 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
}
開發者ID:ngorskig,項目名稱:docker,代碼行數:27,代碼來源:store.go

示例6: 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)
}
開發者ID:jfrazelle,項目名稱:docker,代碼行數:9,代碼來源:store.go

示例7: 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
}
開發者ID:maaquib,項目名稱:docker,代碼行數:10,代碼來源:store.go

示例8: 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
}
開發者ID:NunoEdgarGub1,項目名稱:docker,代碼行數:10,代碼來源:volumes.go

示例9: 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,
	}
}
開發者ID:moxiegirl,項目名稱:docker,代碼行數:11,代碼來源:container.go

示例10: 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
}
開發者ID:ngorskig,項目名稱:docker,代碼行數:12,代碼來源:store.go

示例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
}
開發者ID:hurrygeek,項目名稱:docker,代碼行數:12,代碼來源:volumes.go

示例12: 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
}
開發者ID:hurrygeek,項目名稱:docker,代碼行數:13,代碼來源:volumes.go

示例13: Dereference

// Dereference removes the specified reference to the volume
func (s *VolumeStore) Dereference(v volume.Volume, ref string) {
	name := v.Name()

	s.locks.Lock(name)
	defer s.locks.Unlock(name)

	s.globalLock.Lock()
	defer s.globalLock.Unlock()

	if s.refs[name] != nil {
		delete(s.refs[name], ref)
	}
}
開發者ID:jfrazelle,項目名稱:docker,代碼行數:14,代碼來源:store.go

示例14: 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.(volume.DetailedVolume); ok {
		tv.Labels = v.Labels()
		tv.Options = v.Options()
		tv.Scope = v.Scope()
	}

	return tv
}
開發者ID:Mic92,項目名稱:docker,代碼行數:14,代碼來源:volumes.go

示例15: setNamed

func (s *VolumeStore) setNamed(v volume.Volume, ref string) {
	name := v.Name()

	s.globalLock.Lock()
	s.names[name] = v
	if len(ref) > 0 {
		if s.refs[name] == nil {
			s.refs[name] = make(map[string]struct{})
		}
		s.refs[name][ref] = struct{}{}
	}
	s.globalLock.Unlock()
}
開發者ID:jfrazelle,項目名稱:docker,代碼行數:13,代碼來源:store.go


注:本文中的github.com/docker/docker/volume.Volume類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。