diff --git a/daemon/volumes_unix.go b/daemon/volumes_unix.go index 6f6f4b48ba..80ddcf096d 100644 --- a/daemon/volumes_unix.go +++ b/daemon/volumes_unix.go @@ -71,11 +71,10 @@ func parseBindMount(spec string, mountLabel string, config *runconfig.Config) (* case 3: bind.Destination = arr[1] mode := arr[2] - isValid, isRw := volume.ValidateMountMode(mode) - if !isValid { + if !volume.ValidMountMode(mode) { return nil, fmt.Errorf("invalid mode for volumes-from: %s", mode) } - bind.RW = isRw + bind.RW = volume.ReadWrite(mode) // Mode field is used by SELinux to decide whether to apply label bind.Mode = mode default: @@ -268,7 +267,7 @@ func parseVolumesFrom(spec string) (string, string, error) { if len(specParts) == 2 { mode = specParts[1] - if isValid, _ := volume.ValidateMountMode(mode); !isValid { + if !volume.ValidMountMode(mode) { return "", "", fmt.Errorf("invalid mode for volumes-from: %s", mode) } } diff --git a/opts/opts.go b/opts/opts.go index 398b8b4f37..28ed604e75 100644 --- a/opts/opts.go +++ b/opts/opts.go @@ -202,7 +202,7 @@ func validatePath(val string, validateMountMode bool) (string, error) { containerPath = splited[0] val = path.Clean(containerPath) case 2: - if isValid, _ := volume.ValidateMountMode(splited[1]); validateMountMode && isValid { + if isValid := volume.ValidMountMode(splited[1]); validateMountMode && isValid { containerPath = splited[0] mode = splited[1] val = fmt.Sprintf("%s:%s", path.Clean(containerPath), mode) @@ -213,7 +213,7 @@ func validatePath(val string, validateMountMode bool) (string, error) { case 3: containerPath = splited[1] mode = splited[2] - if isValid, _ := volume.ValidateMountMode(splited[2]); validateMountMode && !isValid { + if isValid := volume.ValidMountMode(splited[2]); validateMountMode && !isValid { return val, fmt.Errorf("bad mount mode specified : %s", mode) } val = fmt.Sprintf("%s:%s:%s", splited[0], containerPath, mode) diff --git a/volume/volume.go b/volume/volume.go index 19c9d77ad9..cfc2207b99 100644 --- a/volume/volume.go +++ b/volume/volume.go @@ -49,13 +49,13 @@ var roModes = map[string]bool{ "Z,ro": true, } -// ValidateMountMode will make sure the mount mode is valid. -// returns if it's a valid mount mode and if it's read-write or not. -func ValidateMountMode(mode string) (bool, bool) { - return roModes[mode] || rwModes[mode], rwModes[mode] +// ValidMountMode will make sure the mount mode is valid. +// returns if it's a valid mount mode or not. +func ValidMountMode(mode string) bool { + return roModes[mode] || rwModes[mode] } -// ReadWrite tells you if a mode string is a valid read-only mode or not. +// ReadWrite tells you if a mode string is a valid read-write mode or not. func ReadWrite(mode string) bool { return rwModes[mode] }