From 3dc1b8e83f2459a58d65f3bb918975cd6f1bb794 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 16 Feb 2022 06:04:22 -0500 Subject: Add podman volume mount support Fixes: https://github.com/containers/podman/issues/12768 Signed-off-by: Daniel J Walsh --- cmd/podman/volumes/mount.go | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 cmd/podman/volumes/mount.go (limited to 'cmd/podman/volumes/mount.go') diff --git a/cmd/podman/volumes/mount.go b/cmd/podman/volumes/mount.go new file mode 100644 index 000000000..1f78187b8 --- /dev/null +++ b/cmd/podman/volumes/mount.go @@ -0,0 +1,51 @@ +package volumes + +import ( + "fmt" + + "github.com/containers/podman/v4/cmd/podman/common" + "github.com/containers/podman/v4/cmd/podman/registry" + "github.com/containers/podman/v4/cmd/podman/utils" + "github.com/spf13/cobra" +) + +var ( + volumeMountDescription = `Mount a volume and return the mountpoint` + volumeMountCommand = &cobra.Command{ + Annotations: map[string]string{ + registry.UnshareNSRequired: "", + registry.ParentNSRequired: "", + registry.EngineMode: registry.ABIMode, + }, + Use: "mount NAME", + Short: "Mount volume", + Long: volumeMountDescription, + RunE: volumeMount, + Example: `podman volume mount myvol`, + Args: cobra.ExactArgs(1), + ValidArgsFunction: common.AutocompleteVolumes, + } +) + +func init() { + registry.Commands = append(registry.Commands, registry.CliCommand{ + Command: volumeMountCommand, + Parent: volumeCmd, + }) +} + +func volumeMount(cmd *cobra.Command, args []string) error { + var errs utils.OutputErrors + reports, err := registry.ContainerEngine().VolumeMount(registry.GetContext(), args) + if err != nil { + return err + } + for _, r := range reports { + if r.Err == nil { + fmt.Println(r.Path) + continue + } + errs = append(errs, r.Err) + } + return errs.PrintErrors() +} -- cgit v1.2.3-54-g00ecf