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