github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/volume/parser.go (about)

     1  package volume
     2  
     3  import (
     4  	"runtime"
     5  
     6  	"github.com/docker/docker/api/types/mount"
     7  )
     8  
     9  const (
    10  	// OSLinux is the same as runtime.GOOS on linux
    11  	OSLinux = "linux"
    12  	// OSWindows is the same as runtime.GOOS on windows
    13  	OSWindows = "windows"
    14  )
    15  
    16  // Parser represents a platform specific parser for mount expressions
    17  type Parser interface {
    18  	ParseMountRaw(raw, volumeDriver string) (*MountPoint, error)
    19  	ParseMountSpec(cfg mount.Mount) (*MountPoint, error)
    20  	ParseVolumesFrom(spec string) (string, string, error)
    21  	DefaultPropagationMode() mount.Propagation
    22  	ConvertTmpfsOptions(opt *mount.TmpfsOptions, readOnly bool) (string, error)
    23  	DefaultCopyMode() bool
    24  	ValidateVolumeName(name string) error
    25  	ReadWrite(mode string) bool
    26  	IsBackwardCompatible(m *MountPoint) bool
    27  	HasResource(m *MountPoint, absPath string) bool
    28  	ValidateTmpfsMountDestination(dest string) error
    29  	ValidateMountConfig(mt *mount.Mount) error
    30  }
    31  
    32  // NewParser creates a parser for a given container OS, depending on the current host OS (linux on a windows host will resolve to an lcowParser)
    33  func NewParser(containerOS string) Parser {
    34  	switch containerOS {
    35  	case OSWindows:
    36  		return &windowsParser{}
    37  	}
    38  	if runtime.GOOS == OSWindows {
    39  		return &lcowParser{}
    40  	}
    41  	return &linuxParser{}
    42  }