util.go 370 B

1234567891011121314151617
  1. package storageos
  2. import (
  3. "fmt"
  4. "strings"
  5. )
  6. // ParseRef is a helper to split out the namespace and name from a path
  7. // reference.
  8. func ParseRef(ref string) (namespace string, name string, err error) {
  9. parts := strings.Split(ref, "/")
  10. if len(parts) != 2 {
  11. return "", "", fmt.Errorf("Name must be prefixed with <namespace>/")
  12. }
  13. return parts[0], parts[1], nil
  14. }