volumes.go 322 B

1234567891011121314151617
  1. package common
  2. import (
  3. "regexp"
  4. )
  5. var (
  6. k8sVolumeDir = regexp.MustCompile(`.+(pvc-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}).*`)
  7. )
  8. func ParseKubernetesVolumeSource(source string) string {
  9. groups := k8sVolumeDir.FindStringSubmatch(source)
  10. if len(groups) != 2 {
  11. return ""
  12. }
  13. return groups[1]
  14. }