summaryrefslogtreecommitdiff
path: root/libpod/volume.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-09-06 13:48:33 +0200
committerGitHub <noreply@github.com>2019-09-06 13:48:33 +0200
commit0d8a22496e3c7e3d44251bdbac194c55de141e2c (patch)
treec3591e9470b5b90842e6764b71b3e3988bc8fab5 /libpod/volume.go
parenta4572c4f681ef23495495f313ae513d5ba3fd495 (diff)
parentde9a394fcff19ae4422a3f65502c8790787351fd (diff)
downloadpodman-0d8a22496e3c7e3d44251bdbac194c55de141e2c.tar.gz
podman-0d8a22496e3c7e3d44251bdbac194c55de141e2c.tar.bz2
podman-0d8a22496e3c7e3d44251bdbac194c55de141e2c.zip
Merge pull request #3931 from mheon/volumes_with_options
Add support for mounting volumes with local driver and options
Diffstat (limited to 'libpod/volume.go')
-rw-r--r--libpod/volume.go30
1 files changed, 22 insertions, 8 deletions
diff --git a/libpod/volume.go b/libpod/volume.go
index abfa7b3f4..b4de3aedc 100644
--- a/libpod/volume.go
+++ b/libpod/volume.go
@@ -6,17 +6,20 @@ import (
"github.com/containers/libpod/libpod/lock"
)
-// Volume is the type used to create named volumes
-// TODO: all volumes should be created using this and the Volume API
+// Volume is a libpod named volume.
+// Named volumes may be shared by multiple containers, and may be created using
+// more complex options than normal bind mounts. They may be backed by a mounted
+// filesystem on the host.
type Volume struct {
config *VolumeConfig
+ state *VolumeState
valid bool
runtime *Runtime
lock lock.Locker
}
-// VolumeConfig holds the volume's config information
+// VolumeConfig holds the volume's immutable configuration.
type VolumeConfig struct {
// Name of the volume.
Name string `json:"name"`
@@ -26,7 +29,7 @@ type VolumeConfig struct {
Labels map[string]string `json:"labels"`
// The volume driver. Empty string or local does not activate a volume
// driver, all other volumes will.
- Driver string `json:"driver"`
+ Driver string `json:"volumeDriver"`
// The location the volume is mounted at.
MountPoint string `json:"mountPoint"`
// Time the volume was created.
@@ -34,7 +37,7 @@ type VolumeConfig struct {
// Options to pass to the volume driver. For the local driver, this is
// a list of mount options. For other drivers, they are passed to the
// volume driver handling the volume.
- Options map[string]string `json:"options"`
+ Options map[string]string `json:"volumeOptions,omitempty"`
// Whether this volume was created for a specific container and will be
// removed with it.
IsCtrSpecific bool `json:"ctrSpecific"`
@@ -44,6 +47,18 @@ type VolumeConfig struct {
GID int `json:"gid"`
}
+// VolumeState holds the volume's mutable state.
+// Volumes are not guaranteed to have a state. Only volumes using the Local
+// driver that have mount options set will create a state.
+type VolumeState struct {
+ // MountCount is the number of times this volume has been requested to
+ // be mounted.
+ // It is incremented on mount() and decremented on unmount().
+ // On incrementing from 0, the volume will be mounted on the host.
+ // On decrementing to 0, the volume will be unmounted on the host.
+ MountCount uint `json:"mountCount"`
+}
+
// Name retrieves the volume's name
func (v *Volume) Name() string {
return v.config.Name
@@ -78,10 +93,9 @@ func (v *Volume) MountPoint() string {
// Options return the volume's options
func (v *Volume) Options() map[string]string {
options := make(map[string]string)
- for key, value := range v.config.Options {
- options[key] = value
+ for k, v := range v.config.Options {
+ options[k] = v
}
-
return options
}