diff options
author | baude <bbaude@redhat.com> | 2019-02-10 16:43:00 -0600 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-02-11 14:48:07 -0600 |
commit | 358da6c8c0375ad41c4669aeef71f9626710c83e (patch) | |
tree | d94d2b1c422ebc13982bbaf98b6b9b43b861a407 /cmd | |
parent | acf2e913730a27fcdc3fcd7c160aa19e071dde36 (diff) | |
download | podman-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 'cmd')
-rw-r--r-- | cmd/podman/commands_remoteclient.go | 4 | ||||
-rw-r--r-- | cmd/podman/varlink/io.podman.varlink | 12 | ||||
-rw-r--r-- | cmd/podman/volume_create.go | 36 |
3 files changed, 21 insertions, 31 deletions
diff --git a/cmd/podman/commands_remoteclient.go b/cmd/podman/commands_remoteclient.go index 80083eab9..993137fde 100644 --- a/cmd/podman/commands_remoteclient.go +++ b/cmd/podman/commands_remoteclient.go @@ -25,7 +25,9 @@ func getPodSubCommands() []*cobra.Command { } func getVolumeSubCommands() []*cobra.Command { - return []*cobra.Command{} + return []*cobra.Command{ + _volumeCreateCommand, + } } func getGenerateSubCommands() []*cobra.Command { diff --git a/cmd/podman/varlink/io.podman.varlink b/cmd/podman/varlink/io.podman.varlink index 101232b0c..7263cfea3 100644 --- a/cmd/podman/varlink/io.podman.varlink +++ b/cmd/podman/varlink/io.podman.varlink @@ -27,6 +27,15 @@ type ContainerChanges ( deleted: []string ) +type VolumeCreateOpts ( + volumeName: string, + driver: string, + labels: [string]string, + options: [string]string +) + + + # ImageInList describes the structure that is returned in # ListImages. type ImageInList ( @@ -1053,6 +1062,9 @@ method ContainerStateData(name: string) -> (config: string) method SendFile(type: string, length: int) -> (file_handle: string) method ReceiveFile(path: string, delete: bool) -> (len: int) +method VolumeCreate(options: VolumeCreateOpts) -> (volumeName: string) + + # ImageNotFound means the image could not be found by the provided name or ID in local storage. error ImageNotFound (name: string) diff --git a/cmd/podman/volume_create.go b/cmd/podman/volume_create.go index e0ff4c341..238579501 100644 --- a/cmd/podman/volume_create.go +++ b/cmd/podman/volume_create.go @@ -4,8 +4,7 @@ import ( "fmt" "github.com/containers/libpod/cmd/podman/cliconfig" - "github.com/containers/libpod/cmd/podman/libpodruntime" - "github.com/containers/libpod/libpod" + "github.com/containers/libpod/libpod/adapter" "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -41,13 +40,7 @@ func init() { } func volumeCreateCmd(c *cliconfig.VolumeCreateValues) error { - var ( - options []libpod.VolumeCreateOption - err error - volName string - ) - - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) + runtime, err := adapter.GetRuntime(&c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } @@ -57,36 +50,19 @@ func volumeCreateCmd(c *cliconfig.VolumeCreateValues) error { return errors.Errorf("too many arguments, create takes at most 1 argument") } - 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.String("driver"))) - } - labels, err := getAllLabels([]string{}, c.Label) if err != nil { return errors.Wrapf(err, "unable to process labels") } - if len(labels) != 0 { - options = append(options, libpod.WithVolumeLabels(labels)) - } opts, err := getAllLabels([]string{}, c.Opt) if err != nil { return errors.Wrapf(err, "unable to process options") } - if len(options) != 0 { - options = append(options, libpod.WithVolumeOptions(opts)) - } - vol, err := runtime.NewVolume(getContext(), options...) - if err != nil { - return err + volumeName, err := runtime.CreateVolume(getContext(), c, labels, opts) + if err == nil { + fmt.Println(volumeName) } - fmt.Printf("%s\n", vol.Name()) - - return nil + return err } |