aboutsummaryrefslogtreecommitdiff
path: root/test/testvol/create.go
blob: d29300f0b948eaa7b6337711d6598c3615d0963b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package main

import (
	pluginapi "github.com/docker/go-plugins-helpers/volume"
	"github.com/spf13/cobra"
)

var createCmd = &cobra.Command{
	Use:   "create NAME",
	Short: "create a volume",
	Long:  `Create a volume in the volume plugin listening on --sock-name`,
	Args:  cobra.ExactArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		return createVol(config.sockName, args[0])
	},
}

func createVol(sockName, volName string) error {
	plugin, err := getPlugin(sockName)
	if err != nil {
		return err
	}
	createReq := new(pluginapi.CreateRequest)
	createReq.Name = volName
	return plugin.CreateVolume(createReq)
}