From d245c6df29e0c124da25e25cd9fbc5f1095bb6f7 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Fri, 15 Mar 2019 10:01:23 -0400 Subject: Switch Libpod over to new explicit named volumes This swaps the previous handling (parse all volume mounts on the container and look for ones that might refer to named volumes) for the new, explicit named volume lists stored per-container. It also deprecates force-removing volumes that are in use. I don't know how we want to handle this yet, but leaving containers that depend on a volume that no longer exists is definitely not correct. Signed-off-by: Matthew Heon --- libpod/container.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'libpod/container.go') diff --git a/libpod/container.go b/libpod/container.go index b02e536c5..74dc5be5c 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -371,7 +371,7 @@ type ContainerConfig struct { } // ContainerNamedVolume is a named volume that will be mounted into the -// container. +// container. Each named volume is a libpod Volume present in the state. type ContainerNamedVolume struct { // Name is the name of the volume to mount in. // Must resolve to a valid volume present in this Podman. @@ -502,6 +502,22 @@ func (c *Container) StaticDir() string { return c.config.StaticDir } +// NamedVolumes returns the container's named volumes. +// The name of each is guaranteed to point to a valid libpod Volume present in +// the state. +func (c *Container) NamedVolumes() []*ContainerNamedVolume { + volumes := []*ContainerNamedVolume{} + for _, vol := range c.config.NamedVolumes { + newVol := new(ContainerNamedVolume) + newVol.Name = vol.Name + newVol.Dest = vol.Dest + newVol.Options = vol.Options + volumes = append(volumes, newVol) + } + + return volumes +} + // Privileged returns whether the container is privileged func (c *Container) Privileged() bool { return c.config.Privileged -- cgit v1.2.3-54-g00ecf