diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-02-12 02:54:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-12 02:54:34 +0100 |
commit | ea20ead35b69b1259f2ff3b00f558c473a921b95 (patch) | |
tree | 9a7e3faba300608db3dd2ee24fbaf02ebf9e66a3 /libpod/adapter/runtime.go | |
parent | 54a5584d84d37632c1c8480d437a012625526a84 (diff) | |
parent | 358da6c8c0375ad41c4669aeef71f9626710c83e (diff) | |
download | podman-ea20ead35b69b1259f2ff3b00f558c473a921b95.tar.gz podman-ea20ead35b69b1259f2ff3b00f558c473a921b95.tar.bz2 podman-ea20ead35b69b1259f2ff3b00f558c473a921b95.zip |
Merge pull request #2313 from baude/remotevolumecreate
podman-remote volume create
Diffstat (limited to 'libpod/adapter/runtime.go')
-rw-r--r-- | libpod/adapter/runtime.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libpod/adapter/runtime.go b/libpod/adapter/runtime.go index 46771b5b6..050ea6ed4 100644 --- a/libpod/adapter/runtime.go +++ b/libpod/adapter/runtime.go @@ -155,3 +155,33 @@ func (r *LocalRuntime) Export(name string, path string) error { func (r *LocalRuntime) Import(ctx context.Context, source, reference string, changes []string, history string, quiet bool) (string, error) { return r.Runtime.Import(ctx, source, reference, changes, history, quiet) } + +// CreateVolume is a wrapper to create volumes +func (r *LocalRuntime) CreateVolume(ctx context.Context, c *cliconfig.VolumeCreateValues, labels, opts map[string]string) (string, error) { + var ( + options []libpod.VolumeCreateOption + volName string + ) + + if len(c.InputArgs) > 0 { + volName = c.InputArgs[0] + options = append(options, libpod.WithVolumeName(volName)) + } + + if c.Flag("driver").Changed { + options = append(options, libpod.WithVolumeDriver(c.Driver)) + } + + if len(labels) != 0 { + options = append(options, libpod.WithVolumeLabels(labels)) + } + + if len(options) != 0 { + options = append(options, libpod.WithVolumeOptions(opts)) + } + newVolume, err := r.NewVolume(ctx, options...) + if err != nil { + return "", err + } + return newVolume.Name(), nil +} |