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

Golang util.GetFlag函数代码示例

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

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



在下文中一共展示了GetFlag函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: doVolumeCreate

func doVolumeCreate(c *cli.Context) error {
	var err error

	name := c.Args().First()
	size, err := getSize(c, err)
	driverName, err := util.GetFlag(c, "driver", false, err)
	backupURL, err := util.GetFlag(c, "backup", false, err)
	if err != nil {
		return err
	}

	driverVolumeID := c.String("id")
	volumeType := c.String("type")
	iops := c.Int("iops")
	prepareForVM := c.Bool("vm")

	request := &api.VolumeCreateRequest{
		Name:           name,
		DriverName:     driverName,
		Size:           size,
		BackupURL:      backupURL,
		DriverVolumeID: driverVolumeID,
		Type:           volumeType,
		IOPS:           int64(iops),
		PrepareForVM:   prepareForVM,
		Verbose:        c.GlobalBool(verboseFlag),
	}

	url := "/volumes/create"

	return sendRequestAndPrint("POST", url, request)
}
开发者ID:PaulCharlton,项目名称:convoy,代码行数:32,代码来源:volume.go


示例2: getSize

func getSize(c *cli.Context, err error) (int64, error) {
	size, err := util.GetFlag(c, "size", false, err)
	if err != nil {
		return 0, err
	}
	return util.ParseSize(size)
}
开发者ID:PaulCharlton,项目名称:convoy,代码行数:7,代码来源:volume.go


示例3: doBackupDelete

func doBackupDelete(c *cli.Context) error {
	var err error
	backupURL, err := util.GetFlag(c, "", true, err)
	if err != nil {
		return err
	}

	request := &api.BackupDeleteRequest{
		URL: backupURL,
	}
	url := "/backups"
	return sendRequestAndPrint("DELETE", url, request)
}
开发者ID:alwang1234,项目名称:convoy,代码行数:13,代码来源:objectstore.go


示例4: doBackupRestore

func doBackupRestore(c *cli.Context) error {
	var err error
	backupURL, err := util.GetFlag(c, "", true, err)
	if err != nil {
		return err
	}
	backupURL = util.UnescapeURL(backupURL)

	toFile, err := util.GetFlag(c, "to", true, err)
	if err != nil {
		return err
	}

	if err := objectstore.RestoreDeltaBlockBackup(backupURL, toFile); err != nil {
		return err
	}

	if err := createNewSnapshotMetafile(toFile + ".meta"); err != nil {
		return err
	}
	return nil
}
开发者ID:th3architect,项目名称:longhorn,代码行数:22,代码来源:main.go


示例5: doBackupDelete

func doBackupDelete(c *cli.Context) error {
	var err error
	backupURL, err := util.GetFlag(c, "", true, err)
	if err != nil {
		return err
	}
	backupURL = util.UnescapeURL(backupURL)

	if err := objectstore.DeleteDeltaBlockBackup(backupURL); err != nil {
		return err
	}
	return nil
}
开发者ID:th3architect,项目名称:longhorn,代码行数:13,代码来源:main.go


示例6: doBackupInspect

func doBackupInspect(c *cli.Context) error {
	var err error

	backupURL, err := util.GetFlag(c, "", true, err)
	if err != nil {
		return err
	}

	request := &api.BackupListRequest{
		URL: backupURL,
	}
	url := "/backups/inspect"
	return sendRequestAndPrint("GET", url, request)
}
开发者ID:alwang1234,项目名称:convoy,代码行数:14,代码来源:objectstore.go


示例7: doBackupList

func doBackupList(c *cli.Context) error {
	var err error

	destURL, err := util.GetFlag(c, "", true, err)
	volumeName, err := util.GetName(c, "volume-name", false, err)
	if err != nil {
		return err
	}

	request := &api.BackupListRequest{
		URL:        destURL,
		VolumeName: volumeName,
	}
	url := "/backups/list"
	return sendRequestAndPrint("GET", url, request)
}
开发者ID:alwang1234,项目名称:convoy,代码行数:16,代码来源:objectstore.go


示例8: doBackupList

func doBackupList(c *cli.Context) error {
	var err error

	destURL, err := util.GetFlag(c, "", true, err)
	volumeName, err := util.GetName(c, "volume", false, err)
	if err != nil {
		return err

	}
	list, err := objectstore.List(volumeName, destURL, DRIVERNAME)
	if err != nil {
		return err
	}
	fmt.Println(list)
	return nil
}
开发者ID:th3architect,项目名称:longhorn,代码行数:16,代码来源:main.go


示例9: doVolumeMount

func doVolumeMount(c *cli.Context) error {
	var err error

	volumeUUID, err := getOrRequestUUID(c, "", true)
	mountPoint, err := util.GetFlag(c, "mountpoint", false, err)
	if err != nil {
		return err
	}

	request := &api.VolumeMountRequest{
		VolumeUUID: volumeUUID,
		MountPoint: mountPoint,
		Verbose:    c.GlobalBool(verboseFlag),
	}

	url := "/volumes/mount"
	return sendRequestAndPrint("POST", url, request)
}
开发者ID:PaulCharlton,项目名称:convoy,代码行数:18,代码来源:volume.go


示例10: doVolumeList

func (s *daemon) doVolumeList(version string, w http.ResponseWriter, r *http.Request, objs map[string]string) error {
	driverSpecific, err := util.GetFlag(r, "driver", false, nil)
	if err != nil {
		return err
	}

	var data []byte
	if driverSpecific == "1" {
		result := s.getVolumeList()
		data, err = api.ResponseOutput(&result)
	} else {
		data, err = s.listVolume()
	}
	if err != nil {
		return err
	}
	_, err = w.Write(data)
	return err
}
开发者ID:alwang1234,项目名称:convoy,代码行数:19,代码来源:volume.go


示例11: getName

func getName(c *cli.Context, key string, required bool) (string, error) {
	var err error
	var name string
	if key == "" {
		name = c.Args().First()
	} else {
		name, err = util.GetFlag(c, key, required, err)
		if err != nil {
			return "", err
		}
	}
	if name == "" && !required {
		return "", nil
	}

	if err := util.CheckName(name); err != nil {
		return "", err
	}
	return name, nil
}
开发者ID:alwang1234,项目名称:convoy,代码行数:20,代码来源:client.go


示例12: doBackupInspect

func doBackupInspect(c *cli.Context) error {
	var err error

	backupURL, err := util.GetFlag(c, "", true, err)
	if err != nil {
		return err
	}
	backupURL = util.UnescapeURL(backupURL)

	info, err := objectstore.GetBackupInfo(backupURL)
	if err != nil {
		return err
	}
	data, err := api.ResponseOutput(info)
	if err != nil {
		return err
	}
	fmt.Println(string(data))
	return nil
}
开发者ID:th3architect,项目名称:longhorn,代码行数:20,代码来源:main.go


示例13: getOrRequestUUID

func getOrRequestUUID(c *cli.Context, key string, required bool) (string, error) {
	var err error
	var id string
	if key == "" {
		id = c.Args().First()
	} else {
		id, err = util.GetFlag(c, key, required, err)
		if err != nil {
			return "", err
		}
	}
	if id == "" && !required {
		return "", nil
	}

	if util.ValidateUUID(id) {
		return id, nil
	}

	return requestUUID(id)
}
开发者ID:PaulCharlton,项目名称:convoy,代码行数:21,代码来源:client.go


示例14: doBackupCreate

func doBackupCreate(c *cli.Context) error {
	var err error

	destURL, err := util.GetFlag(c, "dest", false, err)
	if err != nil {
		return err
	}

	snapshotName, err := getName(c, "", true)
	if err != nil {
		return err
	}

	request := &api.BackupCreateRequest{
		URL:          destURL,
		SnapshotName: snapshotName,
		Verbose:      c.GlobalBool(verboseFlag),
	}

	url := "/backups/create"
	return sendRequestAndPrint("POST", url, request)
}
开发者ID:alwang1234,项目名称:convoy,代码行数:22,代码来源:objectstore.go


示例15: doVolumeList

func (s *daemon) doVolumeList(version string, w http.ResponseWriter, r *http.Request, objs map[string]string) error {
	s.GlobalLock.RLock()
	defer s.GlobalLock.RUnlock()

	driverSpecific, err := util.GetFlag(r, "driver", false, nil)
	if err != nil {
		return err
	}

	var data []byte
	if driverSpecific == "1" {
		result := make(map[string]map[string]string)
		for _, driver := range s.ConvoyDrivers {
			volOps, err := driver.VolumeOps()
			if err != nil {
				break
			}
			volumes, err := volOps.ListVolume(map[string]string{})
			if err != nil {
				break
			}
			for k, v := range volumes {
				v["Driver"] = driver.Name()
				result[k] = v
			}
		}
		data, err = api.ResponseOutput(&result)
	} else {
		data, err = s.listVolume()
	}
	if err != nil {
		return err
	}
	_, err = w.Write(data)
	return err
}
开发者ID:ppawiggers,项目名称:convoy,代码行数:36,代码来源:volume.go


示例16: doBackupCreate

func doBackupCreate(c *cli.Context) error {
	var (
		err         error
		backingFile *replica.BackingFile
	)

	destURL, err := util.GetFlag(c, "dest", true, err)
	if err != nil {
		return err
	}

	snapshotName, err := getName(c, "", true)
	if err != nil {
		return err
	}

	volumeName, err := util.GetFlag(c, "volume", true, err)
	if err != nil {
		return err
	}

	dir, err := os.Getwd()
	if err != nil {
		return err
	}

	volumeInfo, err := replica.ReadInfo(dir)
	if err != nil {
		return err
	}
	if volumeInfo.BackingFileName != "" {
		backingFileName := volumeInfo.BackingFileName
		if _, err := os.Stat(backingFileName); err != nil {
			return err
		}

		backingFile, err = openBackingFile(backingFileName)
		if err != nil {
			return err
		}
	}
	replicaBackup := replica.NewBackup(backingFile)

	volume := &objectstore.Volume{
		Name:        volumeName,
		Driver:      DRIVERNAME,
		Size:        volumeInfo.Size,
		CreatedTime: util.Now(),
	}
	snapshot := &objectstore.Snapshot{
		Name:        snapshotName,
		CreatedTime: util.Now(),
	}

	log.Debugf("Starting backup for %v, snapshot %v, dest %v", volume, snapshot, destURL)
	backupURL, err := objectstore.CreateDeltaBlockBackup(volume, snapshot, destURL, replicaBackup)
	if err != nil {
		return err
	}
	fmt.Println(backupURL)
	return nil
}
开发者ID:th3architect,项目名称:longhorn,代码行数:62,代码来源:main.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang util.ListConfigIDs函数代码示例发布时间:2022-05-28
下一篇:
Golang api.ResponseOutput函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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