• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang volume.Volume类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/docker/docker/volume.Volume的典型用法代码示例。如果您正苦于以下问题:Golang Volume类的具体用法?Golang Volume怎么用?Golang Volume使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Volume类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: 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()
	name := normaliseVolumeName(v.Name())
	logrus.Debugf("Incrementing volume reference: driver %s, name %s", v.DriverName(), name)

	vc, exists := s.vols[name]
	if !exists {
		s.vols[name] = &volumeCounter{v, 1}
		return
	}
	vc.count++
}
开发者ID:maaquib,项目名称:docker,代码行数:14,代码来源:store.go


示例17: 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()
	name := normaliseVolumeName(v.Name())
	logrus.Debugf("Decrementing volume reference: driver %s, name %s", v.DriverName(), name)

	vc, exists := s.vols[name]
	if !exists {
		return
	}
	if vc.count == 0 {
		return
	}
	vc.count--
}
开发者ID:maaquib,项目名称:docker,代码行数:16,代码来源:store.go


示例18: 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(),
		Mountpoint: v.Path(),
	}
	if v, ok := v.(interface {
		Labels() map[string]string
	}); ok {
		tv.Labels = v.Labels()
	}
	return tv
}
开发者ID:vmware,项目名称:vic,代码行数:14,代码来源:volumes.go


示例19: 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
	}

	path, err := v.Mount()
	if err != nil {
		return err
	}
	defer v.Unmount()
	return copyExistingContents(rootfs, path)
}
开发者ID:kjplatz,项目名称:vic,代码行数:21,代码来源:container_unix.go


示例20: 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) {
	vd, err := volumedrivers.GetDriver(v.DriverName())
	if err != nil {
		return false, errors.Wrapf(err, "error while checking if volume %q exists in driver %q", v.Name(), v.DriverName())
	}
	exists, err := vd.Get(v.Name())
	if err != nil {
		err = errors.Cause(err)
		if _, ok := err.(net.Error); ok {
			return false, errors.Wrapf(err, "error while checking if volume %q exists in driver %q", v.Name(), v.DriverName())
		}

		// At this point, the error could be anything from the driver, such as "no such volume"
		// Let's not check an error here, and instead check if the driver returned a volume
	}
	if exists == nil {
		return false, nil
	}
	return true, nil
}
开发者ID:harche,项目名称:docker,代码行数:22,代码来源:store.go



注:本文中的github.com/docker/docker/volume.Volume类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang drivers.Lookup函数代码示例发布时间:2022-05-23
下一篇:
Golang volume.MountPoint类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap