aboutsummaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-07-04 22:22:07 +0200
committerGitHub <noreply@github.com>2019-07-04 22:22:07 +0200
commitf7407f2eb512e1407f8281009eb829f37405119b (patch)
tree08bbb002a9bcac9620aeedb9c5b43bcb6ffc63ca /libpod/container_internal.go
parent1fe2965e4f672674f7b66648e9973a0ed5434bb4 (diff)
parentaeabc45ccef10fc858677765675bd86944a93db6 (diff)
downloadpodman-f7407f2eb512e1407f8281009eb829f37405119b.tar.gz
podman-f7407f2eb512e1407f8281009eb829f37405119b.tar.bz2
podman-f7407f2eb512e1407f8281009eb829f37405119b.zip
Merge pull request #3472 from haircommander/generate-volumes
generate kube with volumes
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 4ed1209bb..611fa9800 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1537,3 +1537,34 @@ func (c *Container) prepareCheckpointExport() (err error) {
return nil
}
+
+// sortUserVolumes sorts the volumes specified for a container
+// between named and normal volumes
+func (c *Container) sortUserVolumes(ctrSpec *spec.Spec) ([]*ContainerNamedVolume, []spec.Mount) {
+ namedUserVolumes := []*ContainerNamedVolume{}
+ userMounts := []spec.Mount{}
+
+ // We need to parse all named volumes and mounts into maps, so we don't
+ // end up with repeated lookups for each user volume.
+ // Map destination to struct, as destination is what is stored in
+ // UserVolumes.
+ namedVolumes := make(map[string]*ContainerNamedVolume)
+ mounts := make(map[string]spec.Mount)
+ for _, namedVol := range c.config.NamedVolumes {
+ namedVolumes[namedVol.Dest] = namedVol
+ }
+ for _, mount := range ctrSpec.Mounts {
+ mounts[mount.Destination] = mount
+ }
+
+ for _, vol := range c.config.UserVolumes {
+ if volume, ok := namedVolumes[vol]; ok {
+ namedUserVolumes = append(namedUserVolumes, volume)
+ } else if mount, ok := mounts[vol]; ok {
+ userMounts = append(userMounts, mount)
+ } else {
+ logrus.Warnf("Could not find mount at destination %q when parsing user volumes for container %s", vol, c.ID())
+ }
+ }
+ return namedUserVolumes, userMounts
+}