From 84005330aa3d25cf6134fffc1bf20354d4a3dd85 Mon Sep 17 00:00:00 2001 From: cdoern Date: Wed, 1 Sep 2021 10:59:23 -0400 Subject: 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 --- cmd/podman/common/create.go | 24 ++++++++++++------------ cmd/podman/pods/create.go | 21 +++++++++++++++------ 2 files changed, 27 insertions(+), 18 deletions(-) (limited to 'cmd/podman') 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 +} -- cgit v1.2.3-54-g00ecf