in pkg/util/util.go [134:155]
func ParseVolumeID(id string) (string, string, string, error) {
// Split off the optional suffix after ":"
realID := id
if colonIndex := strings.Index(id, ":"); colonIndex != -1 {
realID = id[:colonIndex]
}
tokens := strings.Split(realID, "/")
if len(tokens) != 3 {
return "", "", "", fmt.Errorf(
"invalid volume ID %q: expected format PROJECT_ID/LOCATION/INSTANCE_NAME", id)
}
project := tokens[0]
location := tokens[1]
instanceName := tokens[2]
if project == "" || location == "" || instanceName == "" {
return "", "", "", fmt.Errorf(
"invalid volume ID %q: expected format PROJECT_ID/LOCATION/INSTANCE_NAME", id)
}
return project, location, instanceName, nil
}