2018-04-17 16:50:28 -04:00
|
|
|
package mounts // import "github.com/docker/docker/volume/mounts"
|
2017-08-01 13:32:44 -04:00
|
|
|
|
|
|
|
import (
|
2018-01-14 06:10:49 -05:00
|
|
|
"errors"
|
2017-08-01 13:32:44 -04:00
|
|
|
"runtime"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types/mount"
|
|
|
|
)
|
|
|
|
|
2018-01-14 06:10:49 -05:00
|
|
|
// 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 '/'")
|
|
|
|
|
2021-07-02 07:25:27 -04:00
|
|
|
// read-write modes
|
|
|
|
var rwModes = map[string]bool{
|
|
|
|
"rw": true,
|
|
|
|
"ro": true,
|
|
|
|
}
|
|
|
|
|
2017-08-01 13:32:44 -04:00
|
|
|
// Parser represents a platform specific parser for mount expressions
|
|
|
|
type Parser interface {
|
|
|
|
ParseMountRaw(raw, volumeDriver string) (*MountPoint, error)
|
|
|
|
ParseMountSpec(cfg mount.Mount) (*MountPoint, error)
|
|
|
|
ParseVolumesFrom(spec string) (string, string, error)
|
|
|
|
DefaultPropagationMode() mount.Propagation
|
|
|
|
ConvertTmpfsOptions(opt *mount.TmpfsOptions, readOnly bool) (string, error)
|
|
|
|
DefaultCopyMode() bool
|
|
|
|
ValidateVolumeName(name string) error
|
|
|
|
ReadWrite(mode string) bool
|
|
|
|
IsBackwardCompatible(m *MountPoint) bool
|
|
|
|
HasResource(m *MountPoint, absPath string) bool
|
|
|
|
ValidateTmpfsMountDestination(dest string) error
|
2017-12-19 05:44:29 -05:00
|
|
|
ValidateMountConfig(mt *mount.Mount) error
|
2017-08-01 13:32:44 -04:00
|
|
|
}
|
|
|
|
|
2021-06-11 15:01:18 -04:00
|
|
|
// NewParser creates a parser for the current host OS
|
|
|
|
func NewParser() Parser {
|
|
|
|
if runtime.GOOS == "windows" {
|
2021-07-02 07:41:47 -04:00
|
|
|
return NewWindowsParser()
|
2017-08-01 13:32:44 -04:00
|
|
|
}
|
2021-07-02 07:41:47 -04:00
|
|
|
return NewLinuxParser()
|
2017-08-01 13:32:44 -04:00
|
|
|
}
|