volume_copy.go 588 B

12345678910111213141516171819202122232425262728
  1. package volume
  2. import "strings"
  3. const (
  4. // DefaultCopyMode is the copy mode used by default for normal/named volumes
  5. DefaultCopyMode = true
  6. )
  7. // {<copy mode>=isEnabled}
  8. var copyModes = map[string]bool{
  9. "nocopy": false,
  10. }
  11. func copyModeExists(mode string) bool {
  12. _, exists := copyModes[mode]
  13. return exists
  14. }
  15. // GetCopyMode gets the copy mode from the mode string for mounts
  16. func getCopyMode(mode string) (bool, bool) {
  17. for _, o := range strings.Split(mode, ",") {
  18. if isEnabled, exists := copyModes[o]; exists {
  19. return isEnabled, true
  20. }
  21. }
  22. return DefaultCopyMode, false
  23. }