From 358da6c8c0375ad41c4669aeef71f9626710c83e Mon Sep 17 00:00:00 2001 From: baude Date: Sun, 10 Feb 2019 16:43:00 -0600 Subject: podman-remote volume create create a volume using the remote client over varlink Signed-off-by: baude --- pkg/varlinkapi/volumes.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pkg/varlinkapi/volumes.go (limited to 'pkg/varlinkapi') diff --git a/pkg/varlinkapi/volumes.go b/pkg/varlinkapi/volumes.go new file mode 100644 index 000000000..d1e4ae3c6 --- /dev/null +++ b/pkg/varlinkapi/volumes.go @@ -0,0 +1,29 @@ +package varlinkapi + +import ( + "github.com/containers/libpod/cmd/podman/varlink" + "github.com/containers/libpod/libpod" +) + +// VolumeCreate creates a libpod volume based on input from a varlink connection +func (i *LibpodAPI) VolumeCreate(call iopodman.VarlinkCall, options iopodman.VolumeCreateOpts) error { + var volumeOptions []libpod.VolumeCreateOption + + if len(options.VolumeName) > 0 { + volumeOptions = append(volumeOptions, libpod.WithVolumeName(options.VolumeName)) + } + if len(options.Driver) > 0 { + volumeOptions = append(volumeOptions, libpod.WithVolumeDriver(options.Driver)) + } + if len(options.Labels) > 0 { + volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(options.Labels)) + } + if len(options.Options) > 0 { + volumeOptions = append(volumeOptions, libpod.WithVolumeOptions(options.Options)) + } + newVolume, err := i.Runtime.NewVolume(getContext(), volumeOptions...) + if err != nil { + return call.ReplyErrorOccurred(err.Error()) + } + return call.ReplyVolumeCreate(newVolume.Name()) +} -- cgit v1.2.3-54-g00ecf