summaryrefslogtreecommitdiff
path: root/test/testvol/remove.go
blob: 2839b0b50b98fa2f1ff5aef5919ba40543474ff6 (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 removeCmd = &cobra.Command{
	Use:   "remove NAME",
	Short: "remove a volume",
	Long:  `Remove a volume in the volume plugin listening on --sock-name`,
	Args:  cobra.ExactArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		return removeVol(config.sockName, args[0])
	},
}

func removeVol(sockName, volName string) error {
	plugin, err := getPlugin(sockName)
	if err != nil {
		return err
	}
	removeReq := new(pluginapi.RemoveRequest)
	removeReq.Name = volName
	return plugin.RemoveVolume(removeReq)
}