當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。