parser.go 1.3 KB

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