func decodeBackupURL(backupURL string) (string, string, error) { u, err := url.Parse(backupURL) if err != nil { return "", "", err } v := u.Query() volumeUUID := v.Get("volume") backupUUID := v.Get("backup") if !util.ValidateUUID(volumeUUID) || !util.ValidateUUID(backupUUID) { return "", "", fmt.Errorf("Invalid UUID parsed, got %v and %v", backupUUID, volumeUUID) } return backupUUID, volumeUUID, nil }
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) }