volume_propagation_linux.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // +build linux
  2. package volume
  3. import (
  4. "strings"
  5. )
  6. // DefaultPropagationMode defines what propagation mode should be used by
  7. // default if user has not specified one explicitly.
  8. const DefaultPropagationMode string = "rprivate"
  9. // propagation modes
  10. var propagationModes = map[string]bool{
  11. "private": true,
  12. "rprivate": true,
  13. "slave": true,
  14. "rslave": true,
  15. "shared": true,
  16. "rshared": true,
  17. }
  18. // GetPropagation extracts and returns the mount propagation mode. If there
  19. // are no specifications, then by default it is "private".
  20. func GetPropagation(mode string) string {
  21. for _, o := range strings.Split(mode, ",") {
  22. if propagationModes[o] {
  23. return o
  24. }
  25. }
  26. return DefaultPropagationMode
  27. }
  28. // HasPropagation checks if there is a valid propagation mode present in
  29. // passed string. Returns true if a valid propagation mode specifier is
  30. // present, false otherwise.
  31. func HasPropagation(mode string) bool {
  32. for _, o := range strings.Split(mode, ",") {
  33. if propagationModes[o] {
  34. return true
  35. }
  36. }
  37. return false
  38. }