github.com/getong/docker@v1.13.1/api/types/mount/mount.go (about)

     1  package mount
     2  
     3  import (
     4  	"os"
     5  )
     6  
     7  // Type represents the type of a mount.
     8  type Type string
     9  
    10  // Type constants
    11  const (
    12  	// TypeBind is the type for mounting host dir
    13  	TypeBind Type = "bind"
    14  	// TypeVolume is the type for remote storage volumes
    15  	TypeVolume Type = "volume"
    16  	// TypeTmpfs is the type for mounting tmpfs
    17  	TypeTmpfs Type = "tmpfs"
    18  )
    19  
    20  // Mount represents a mount (volume).
    21  type Mount struct {
    22  	Type Type `json:",omitempty"`
    23  	// Source specifies the name of the mount. Depending on mount type, this
    24  	// may be a volume name or a host path, or even ignored.
    25  	// Source is not supported for tmpfs (must be an empty value)
    26  	Source   string `json:",omitempty"`
    27  	Target   string `json:",omitempty"`
    28  	ReadOnly bool   `json:",omitempty"`
    29  
    30  	BindOptions   *BindOptions   `json:",omitempty"`
    31  	VolumeOptions *VolumeOptions `json:",omitempty"`
    32  	TmpfsOptions  *TmpfsOptions  `json:",omitempty"`
    33  }
    34  
    35  // Propagation represents the propagation of a mount.
    36  type Propagation string
    37  
    38  const (
    39  	// PropagationRPrivate RPRIVATE
    40  	PropagationRPrivate Propagation = "rprivate"
    41  	// PropagationPrivate PRIVATE
    42  	PropagationPrivate Propagation = "private"
    43  	// PropagationRShared RSHARED
    44  	PropagationRShared Propagation = "rshared"
    45  	// PropagationShared SHARED
    46  	PropagationShared Propagation = "shared"
    47  	// PropagationRSlave RSLAVE
    48  	PropagationRSlave Propagation = "rslave"
    49  	// PropagationSlave SLAVE
    50  	PropagationSlave Propagation = "slave"
    51  )
    52  
    53  // Propagations is the list of all valid mount propagations
    54  var Propagations = []Propagation{
    55  	PropagationRPrivate,
    56  	PropagationPrivate,
    57  	PropagationRShared,
    58  	PropagationShared,
    59  	PropagationRSlave,
    60  	PropagationSlave,
    61  }
    62  
    63  // BindOptions defines options specific to mounts of type "bind".
    64  type BindOptions struct {
    65  	Propagation Propagation `json:",omitempty"`
    66  }
    67  
    68  // VolumeOptions represents the options for a mount of type volume.
    69  type VolumeOptions struct {
    70  	NoCopy       bool              `json:",omitempty"`
    71  	Labels       map[string]string `json:",omitempty"`
    72  	DriverConfig *Driver           `json:",omitempty"`
    73  }
    74  
    75  // Driver represents a volume driver.
    76  type Driver struct {
    77  	Name    string            `json:",omitempty"`
    78  	Options map[string]string `json:",omitempty"`
    79  }
    80  
    81  // TmpfsOptions defines options specific to mounts of type "tmpfs".
    82  type TmpfsOptions struct {
    83  	// Size sets the size of the tmpfs, in bytes.
    84  	//
    85  	// This will be converted to an operating system specific value
    86  	// depending on the host. For example, on linux, it will be convered to
    87  	// use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with
    88  	// docker, uses a straight byte value.
    89  	//
    90  	// Percentages are not supported.
    91  	SizeBytes int64 `json:",omitempty"`
    92  	// Mode of the tmpfs upon creation
    93  	Mode os.FileMode `json:",omitempty"`
    94  
    95  	// TODO(stevvooe): There are several more tmpfs flags, specified in the
    96  	// daemon, that are accepted. Only the most basic are added for now.
    97  	//
    98  	// From docker/docker/pkg/mount/flags.go:
    99  	//
   100  	// var validFlags = map[string]bool{
   101  	// 	"":          true,
   102  	// 	"size":      true, X
   103  	// 	"mode":      true, X
   104  	// 	"uid":       true,
   105  	// 	"gid":       true,
   106  	// 	"nr_inodes": true,
   107  	// 	"nr_blocks": true,
   108  	// 	"mpol":      true,
   109  	// }
   110  	//
   111  	// Some of these may be straightforward to add, but others, such as
   112  	// uid/gid have implications in a clustered system.
   113  }