summaryrefslogtreecommitdiff
path: root/cmd/podman/varlink.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-01-31 13:20:04 -0600
committerbaude <bbaude@redhat.com>2019-02-08 10:26:43 -0600
commit25a3923b61a5ca014318e6d957f68abd03947297 (patch)
tree2ccb4a0bd9bda70c1c258dcb1b8aca8961d9ad30 /cmd/podman/varlink.go
parent962850c6e0dfcee926af31fc0ad24f1f6c26f8ac (diff)
downloadpodman-25a3923b61a5ca014318e6d957f68abd03947297.tar.gz
podman-25a3923b61a5ca014318e6d957f68abd03947297.tar.bz2
podman-25a3923b61a5ca014318e6d957f68abd03947297.zip
Migrate to cobra CLI
We intend to migrate to the cobra cli from urfave/cli because the project is more well maintained. There are also some technical reasons as well which extend into our remote client work. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/varlink.go')
-rw-r--r--cmd/podman/varlink.go45
1 files changed, 25 insertions, 20 deletions
diff --git a/cmd/podman/varlink.go b/cmd/podman/varlink.go
index 38ce77415..2b76e034e 100644
--- a/cmd/podman/varlink.go
+++ b/cmd/podman/varlink.go
@@ -5,55 +5,60 @@ package main
import (
"time"
+ "github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
iopodman "github.com/containers/libpod/cmd/podman/varlink"
"github.com/containers/libpod/pkg/varlinkapi"
"github.com/containers/libpod/version"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
- "github.com/urfave/cli"
+ "github.com/spf13/cobra"
"github.com/varlink/go/varlink"
)
var (
+ varlinkCommand cliconfig.VarlinkValues
varlinkDescription = `
podman varlink
run varlink interface
`
- varlinkFlags = []cli.Flag{
- cli.IntFlag{
- Name: "timeout, t",
- Usage: "Time until the varlink session expires in milliseconds. Use 0 to disable the timeout.",
- Value: 1000,
+ _varlinkCommand = &cobra.Command{
+ Use: "varlink",
+ Short: "Run varlink interface",
+ Long: varlinkDescription,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ varlinkCommand.InputArgs = args
+ varlinkCommand.GlobalFlags = MainGlobalOpts
+ return varlinkCmd(&varlinkCommand)
},
- }
- varlinkCommand = &cli.Command{
- Name: "varlink",
- Usage: "Run varlink interface",
- Description: varlinkDescription,
- Flags: sortFlags(varlinkFlags),
- Action: varlinkCmd,
- ArgsUsage: "VARLINK_URI",
- OnUsageError: usageErrorHandler,
+ Example: "VARLINK_URI",
}
)
-func varlinkCmd(c *cli.Context) error {
- args := c.Args()
+func init() {
+ varlinkCommand.Command = _varlinkCommand
+ flags := varlinkCommand.Flags()
+ flags.Int64VarP(&varlinkCommand.Timeout, "timeout", "t", 1000, "Time until the varlink session expires in milliseconds. Use 0 to disable the timeout")
+
+ rootCmd.AddCommand(varlinkCommand.Command)
+}
+
+func varlinkCmd(c *cliconfig.VarlinkValues) error {
+ args := c.InputArgs
if len(args) < 1 {
return errors.Errorf("you must provide a varlink URI")
}
- timeout := time.Duration(c.Int64("timeout")) * time.Millisecond
+ timeout := time.Duration(c.Timeout) * time.Millisecond
// Create a single runtime for varlink
- runtime, err := libpodruntime.GetRuntime(c)
+ runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "error creating libpod runtime")
}
defer runtime.Shutdown(false)
- var varlinkInterfaces = []*iopodman.VarlinkInterface{varlinkapi.New(c, runtime)}
+ var varlinkInterfaces = []*iopodman.VarlinkInterface{varlinkapi.New(&c.PodmanCommand, runtime)}
// Register varlink service. The metadata can be retrieved with:
// $ varlink info [varlink address URI]
service, err := varlink.NewService(