diff options
author | cdoern <cdoern@redhat.com> | 2021-09-01 10:59:23 -0400 |
---|---|---|
committer | cdoern <cdoern@redhat.com> | 2021-09-14 08:32:07 -0400 |
commit | 84005330aa3d25cf6134fffc1bf20354d4a3dd85 (patch) | |
tree | aef148fafb73e36c3fed0fd7c0f2696f98a71c79 /cmd | |
parent | ad26684856551251100b945305f91246888ef153 (diff) | |
download | podman-84005330aa3d25cf6134fffc1bf20354d4a3dd85.tar.gz podman-84005330aa3d25cf6134fffc1bf20354d4a3dd85.tar.bz2 podman-84005330aa3d25cf6134fffc1bf20354d4a3dd85.zip |
Pod Volumes Support
added support for the --volume flag in pods using the new infra container design.
users can specify all volume options they can with regular containers
resolves #10379
Signed-off-by: cdoern <cdoern@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/common/create.go | 24 | ||||
-rw-r--r-- | cmd/podman/pods/create.go | 21 |
2 files changed, 27 insertions, 18 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index 325c1dc69..6200592b4 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -660,18 +660,6 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions, ) _ = cmd.RegisterFlagCompletionFunc(mountFlagName, AutocompleteMountFlag) - volumeDesciption := "Bind mount a volume into the container" - if registry.IsRemote() { - volumeDesciption = "Bind mount a volume into the container. Volume src will be on the server machine, not the client" - } - volumeFlagName := "volume" - createFlags.StringArrayVarP( - &cf.Volume, - volumeFlagName, "v", volumes(), - volumeDesciption, - ) - _ = cmd.RegisterFlagCompletionFunc(volumeFlagName, AutocompleteVolumeFlag) - volumesFromFlagName := "volumes-from" createFlags.StringArrayVar( &cf.VolumesFrom, @@ -865,4 +853,16 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions, "PID namespace to use", ) _ = cmd.RegisterFlagCompletionFunc(pidFlagName, AutocompleteNamespace) + + volumeDesciption := "Bind mount a volume into the container" + if registry.IsRemote() { + volumeDesciption = "Bind mount a volume into the container. Volume source will be on the server machine, not the client" + } + volumeFlagName := "volume" + createFlags.StringArrayVarP( + &cf.Volume, + volumeFlagName, "v", volumes(), + volumeDesciption, + ) + _ = cmd.RegisterFlagCompletionFunc(volumeFlagName, AutocompleteVolumeFlag) } diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go index b3f84dcd8..7000c92c8 100644 --- a/cmd/podman/pods/create.go +++ b/cmd/podman/pods/create.go @@ -132,12 +132,7 @@ func create(cmd *cobra.Command, args []string) error { createOptions.Share = nil } else { // reassign certain optios for lbpod api, these need to be populated in spec - createOptions.InfraConmonPidFile = infraOptions.ConmonPIDFile - createOptions.InfraName = infraOptions.Name - createOptions.Hostname = infraOptions.Hostname - createOptions.Cpus = infraOptions.CPUS - createOptions.CpusetCpus = infraOptions.CPUSetCPUs - createOptions.Pid = infraOptions.PID + MapOptions() flags := cmd.Flags() infraOptions.Net, err = common.NetFlagsToNetOptions(nil, *flags, false) if err != nil { @@ -265,6 +260,10 @@ func create(cmd *cobra.Command, args []string) error { if err != nil { return err } + podSpec.Volumes = podSpec.InfraContainerSpec.Volumes + podSpec.ImageVolumes = podSpec.InfraContainerSpec.ImageVolumes + podSpec.OverlayVolumes = podSpec.InfraContainerSpec.OverlayVolumes + podSpec.Mounts = podSpec.InfraContainerSpec.Mounts } PodSpec := entities.PodSpec{PodSpecGen: *podSpec} response, err := registry.ContainerEngine().PodCreate(context.Background(), PodSpec) @@ -291,3 +290,13 @@ func replacePod(name string) error { } return removePods([]string{name}, rmOptions, false) } + +func MapOptions() { + createOptions.Cpus = infraOptions.CPUS + createOptions.CpusetCpus = infraOptions.CPUSetCPUs + createOptions.Hostname = infraOptions.Hostname + createOptions.InfraConmonPidFile = infraOptions.ConmonPIDFile + createOptions.InfraName = infraOptions.Name + createOptions.Pid = infraOptions.PID + createOptions.Volume = infraOptions.Volume +} |