github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/volume/mounts/parser.go (about) 1 package mounts // import "github.com/docker/docker/volume/mounts" 2 3 import ( 4 "errors" 5 "runtime" 6 7 "github.com/docker/docker/api/types/mount" 8 ) 9 10 // ErrVolumeTargetIsRoot is returned when the target destination is root. 11 // It's used by both LCOW and Linux parsers. 12 var ErrVolumeTargetIsRoot = errors.New("invalid specification: destination can't be '/'") 13 14 // read-write modes 15 var rwModes = map[string]bool{ 16 "rw": true, 17 "ro": true, 18 } 19 20 // Parser represents a platform specific parser for mount expressions 21 type Parser interface { 22 ParseMountRaw(raw, volumeDriver string) (*MountPoint, error) 23 ParseMountSpec(cfg mount.Mount) (*MountPoint, error) 24 ParseVolumesFrom(spec string) (string, string, error) 25 DefaultPropagationMode() mount.Propagation 26 ConvertTmpfsOptions(opt *mount.TmpfsOptions, readOnly bool) (string, error) 27 DefaultCopyMode() bool 28 ValidateVolumeName(name string) error 29 ReadWrite(mode string) bool 30 IsBackwardCompatible(m *MountPoint) bool 31 HasResource(m *MountPoint, absPath string) bool 32 ValidateTmpfsMountDestination(dest string) error 33 ValidateMountConfig(mt *mount.Mount) error 34 } 35 36 // NewParser creates a parser for the current host OS 37 func NewParser() Parser { 38 if runtime.GOOS == "windows" { 39 return NewWindowsParser() 40 } 41 return NewLinuxParser() 42 }