summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-15 09:10:12 -0400
committerGitHub <noreply@github.com>2021-09-15 09:10:12 -0400
commit4b6ffda31c258aadcbc6171a7dd745d0fb17393c (patch)
treeb05003f91e2f1fd73dd1cd945241d3d7188d2b5f /pkg
parent4dd7bfdfaa3adf95af39fd45f74d49cea0c80064 (diff)
parent84005330aa3d25cf6134fffc1bf20354d4a3dd85 (diff)
downloadpodman-4b6ffda31c258aadcbc6171a7dd745d0fb17393c.tar.gz
podman-4b6ffda31c258aadcbc6171a7dd745d0fb17393c.tar.bz2
podman-4b6ffda31c258aadcbc6171a7dd745d0fb17393c.zip
Merge pull request #11409 from cdoern/podVolumes
Pod Volumes Support
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/libpod/pods.go4
-rw-r--r--pkg/domain/entities/pods.go1
-rw-r--r--pkg/specgen/generate/container_create.go14
-rw-r--r--pkg/specgen/podspecgen.go16
4 files changed, 31 insertions, 4 deletions
diff --git a/pkg/api/handlers/libpod/pods.go b/pkg/api/handlers/libpod/pods.go
index cc686c69d..1f03e121e 100644
--- a/pkg/api/handlers/libpod/pods.go
+++ b/pkg/api/handlers/libpod/pods.go
@@ -52,13 +52,11 @@ func PodCreate(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to decode specgen"))
return
}
- tempSpec := &specgen.SpecGenerator{} // temporary spec since infra cannot be decoded into
- err = json.Unmarshal(out, tempSpec) // unmarhal matching options
+ err = json.Unmarshal(out, psg.InfraContainerSpec) // unmarhal matching options
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to decode specgen"))
return
}
- psg.InfraContainerSpec = tempSpec // set infra spec equal to temp
// a few extra that do not have the same json tags
psg.InfraContainerSpec.Name = psg.InfraName
psg.InfraContainerSpec.ConmonPidFile = psg.InfraConmonPidFile
diff --git a/pkg/domain/entities/pods.go b/pkg/domain/entities/pods.go
index d9dd0c532..a74725c63 100644
--- a/pkg/domain/entities/pods.go
+++ b/pkg/domain/entities/pods.go
@@ -131,6 +131,7 @@ type PodCreateOptions struct {
Cpus float64
CpusetCpus string
Userns specgen.Namespace
+ Volume []string
}
// PodLogsOptions describes the options to extract pod logs.
diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go
index fbb229e1c..91230338e 100644
--- a/pkg/specgen/generate/container_create.go
+++ b/pkg/specgen/generate/container_create.go
@@ -28,15 +28,27 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener
return nil, nil, nil, err
}
- // If joining a pod, retrieve the pod for use.
+ // If joining a pod, retrieve the pod for use, and its infra container
var pod *libpod.Pod
+ var cont *libpod.Container
+ var config *libpod.ContainerConfig
if s.Pod != "" {
pod, err = rt.LookupPod(s.Pod)
if err != nil {
return nil, nil, nil, errors.Wrapf(err, "error retrieving pod %s", s.Pod)
}
+ if pod.HasInfraContainer() {
+ cont, err = pod.InfraContainer()
+ if err != nil {
+ return nil, nil, nil, err
+ }
+ config = cont.Config()
+ }
}
+ if config != nil && (len(config.NamedVolumes) > 0 || len(config.UserVolumes) > 0 || len(config.ImageVolumes) > 0 || len(config.OverlayVolumes) > 0) {
+ s.VolumesFrom = append(s.VolumesFrom, config.ID)
+ }
// Set defaults for unset namespaces
if s.PidNS.IsDefault() {
defaultNS, err := GetDefaultNamespaceMode("pid", rtc, pod)
diff --git a/pkg/specgen/podspecgen.go b/pkg/specgen/podspecgen.go
index 8872a1321..5f72fc47d 100644
--- a/pkg/specgen/podspecgen.go
+++ b/pkg/specgen/podspecgen.go
@@ -72,6 +72,22 @@ type PodBasicConfig struct {
// Any containers created within the pod will inherit the pod's userns settings.
// Optional
Userns Namespace `json:"userns,omitempty"`
+ // Mounts are mounts that will be added to the pod.
+ // These will supersede Image Volumes and VolumesFrom (WIP) volumes where
+ // there are conflicts.
+ // Optional.
+ Mounts []spec.Mount `json:"mounts,omitempty"`
+ // Volumes are named volumes that will be added to the pod.
+ // These will supersede Image Volumes and VolumesFrom (WIP) volumes where
+ // there are conflicts.
+ // Optional.
+ Volumes []*NamedVolume `json:"volumes,omitempty"`
+ // Overlay volumes are named volumes that will be added to the pod.
+ // Optional.
+ OverlayVolumes []*OverlayVolume `json:"overlay_volumes,omitempty"`
+ // Image volumes bind-mount a container-image mount into the pod's infra container.
+ // Optional.
+ ImageVolumes []*ImageVolume `json:"image_volumes,omitempty"`
}
// PodNetworkConfig contains networking configuration for a pod.