mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Small nitpick: create ErrVolumeTargetIsRoot in the volume package
Both lcow_parser.go and linux_parser.go are duplicating the error: "invalid specification: destination can't be '/'" This commit creates a new error called "ErrVolumeTargetIsRoot" that is used by both linux_parser and lcow_parser and remove the duplication in the code. Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
This commit is contained in:
parent
6415f1dcf5
commit
62143af543
3 changed files with 7 additions and 3 deletions
|
@ -2,7 +2,6 @@ package volume
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
"github.com/docker/docker/api/types/mount"
|
||||
|
@ -10,7 +9,7 @@ import (
|
|||
|
||||
var lcowSpecificValidators mountValidator = func(m *mount.Mount) error {
|
||||
if path.Clean(m.Target) == "/" {
|
||||
return fmt.Errorf("invalid specification: destination can't be '/'")
|
||||
return ErrVolumeTargetIsRoot
|
||||
}
|
||||
if m.Type == mount.TypeNamedPipe {
|
||||
return errors.New("Linux containers on Windows do not support named pipe mounts")
|
||||
|
|
|
@ -29,7 +29,7 @@ func linuxSplitRawSpec(raw string) ([]string, error) {
|
|||
func linuxValidateNotRoot(p string) error {
|
||||
p = path.Clean(strings.Replace(p, `\`, `/`, -1))
|
||||
if p == "/" {
|
||||
return fmt.Errorf("invalid specification: destination can't be '/'")
|
||||
return ErrVolumeTargetIsRoot
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package volume
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"runtime"
|
||||
|
||||
"github.com/docker/docker/api/types/mount"
|
||||
|
@ -13,6 +14,10 @@ const (
|
|||
OSWindows = "windows"
|
||||
)
|
||||
|
||||
// ErrVolumeTargetIsRoot is returned when the target destination is root.
|
||||
// It's used by both LCOW and Linux parsers.
|
||||
var ErrVolumeTargetIsRoot = errors.New("invalid specification: destination can't be '/'")
|
||||
|
||||
// Parser represents a platform specific parser for mount expressions
|
||||
type Parser interface {
|
||||
ParseMountRaw(raw, volumeDriver string) (*MountPoint, error)
|
||||
|
|
Loading…
Add table
Reference in a new issue