summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-02-10 16:43:00 -0600
committerbaude <bbaude@redhat.com>2019-02-11 14:48:07 -0600
commit358da6c8c0375ad41c4669aeef71f9626710c83e (patch)
treed94d2b1c422ebc13982bbaf98b6b9b43b861a407 /pkg
parentacf2e913730a27fcdc3fcd7c160aa19e071dde36 (diff)
downloadpodman-358da6c8c0375ad41c4669aeef71f9626710c83e.tar.gz
podman-358da6c8c0375ad41c4669aeef71f9626710c83e.tar.bz2
podman-358da6c8c0375ad41c4669aeef71f9626710c83e.zip
podman-remote volume create
create a volume using the remote client over varlink Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/varlinkapi/volumes.go29
1 files changed, 29 insertions, 0 deletions
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())
+}