mirror of
https://github.com/containers/podman.git
synced 2025-05-18 15:47:51 +08:00

Add 4 new subcommands to the testvol binary, instead of just serving the volume api it now also can create/list/remove plugins. This is required to test new functionality where volumes are create outside of podman in the plugin. Podman should then be able to pick up the new volumes. The new testvol commands are: - serve: serve the podman api like the the testvol command before - create: create a volume with the given name - list: list all volume names - remove: remove the volume with the given name Also make a small update to the testvol Containerfile so that it can build correctly. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
27 lines
627 B
Go
27 lines
627 B
Go
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)
|
|
}
|