当前位置: 首页>>代码示例>>Golang>>正文


Golang util.GetFlag函数代码示例

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


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


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