summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/abi/volumes.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-03-21 14:46:39 +0100
committerGitHub <noreply@github.com>2020-03-21 14:46:39 +0100
commit195a82ffbc435716ef5bb69f6eefa333abe3f840 (patch)
tree5d37dc8abce399a4bad65eb7eb81614ce63a63cc /pkg/domain/infra/abi/volumes.go
parente1f2851976fb66b92779fcb45a2ae2117923ca4e (diff)
parentc3a9ff11743c1ee25515ced348ec635fb7703aa0 (diff)
downloadpodman-195a82ffbc435716ef5bb69f6eefa333abe3f840.tar.gz
podman-195a82ffbc435716ef5bb69f6eefa333abe3f840.tar.bz2
podman-195a82ffbc435716ef5bb69f6eefa333abe3f840.zip
Merge pull request #5577 from baude/v2volumecreate
podmanv2 volume create
Diffstat (limited to 'pkg/domain/infra/abi/volumes.go')
-rw-r--r--pkg/domain/infra/abi/volumes.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/pkg/domain/infra/abi/volumes.go b/pkg/domain/infra/abi/volumes.go
new file mode 100644
index 000000000..0783af441
--- /dev/null
+++ b/pkg/domain/infra/abi/volumes.go
@@ -0,0 +1,38 @@
+// +build ABISupport
+
+package abi
+
+import (
+ "context"
+
+ "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/containers/libpod/pkg/domain/infra/abi/parse"
+)
+
+func (ic *ContainerEngine) VolumeCreate(ctx context.Context, opts entities.VolumeCreateOptions) (*entities.IdOrNameResponse, error) {
+ var (
+ volumeOptions []libpod.VolumeCreateOption
+ )
+ if len(opts.Name) > 0 {
+ volumeOptions = append(volumeOptions, libpod.WithVolumeName(opts.Name))
+ }
+ if len(opts.Driver) > 0 {
+ volumeOptions = append(volumeOptions, libpod.WithVolumeDriver(opts.Driver))
+ }
+ if len(opts.Label) > 0 {
+ volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(opts.Label))
+ }
+ if len(opts.Options) > 0 {
+ parsedOptions, err := parse.ParseVolumeOptions(opts.Options)
+ if err != nil {
+ return nil, err
+ }
+ volumeOptions = append(volumeOptions, parsedOptions...)
+ }
+ vol, err := ic.Libpod.NewVolume(ctx, volumeOptions...)
+ if err != nil {
+ return nil, err
+ }
+ return &entities.IdOrNameResponse{IdOrName: vol.Name()}, nil
+}