diff options
author | baude <bbaude@redhat.com> | 2018-03-26 09:39:14 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-04-23 14:29:45 +0000 |
commit | 8493dba23c73617d9529b7ca13b400d50ac6f455 (patch) | |
tree | c0de0c67334b9fa7166e01cae95dc560c1e2455a /cmd/podman/varlink.go | |
parent | cf1d884ffa45b342f38a78189bbd86186ce6cbfe (diff) | |
download | podman-8493dba23c73617d9529b7ca13b400d50ac6f455.tar.gz podman-8493dba23c73617d9529b7ca13b400d50ac6f455.tar.bz2 podman-8493dba23c73617d9529b7ca13b400d50ac6f455.zip |
Initial varlink implementation
Signed-off-by: baude <bbaude@redhat.com>
Closes: #627
Approved by: mheon
Diffstat (limited to 'cmd/podman/varlink.go')
-rw-r--r-- | cmd/podman/varlink.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/cmd/podman/varlink.go b/cmd/podman/varlink.go new file mode 100644 index 000000000..75ddc6c4d --- /dev/null +++ b/cmd/podman/varlink.go @@ -0,0 +1,60 @@ +package main + +import ( + "github.com/pkg/errors" + "github.com/projectatomic/libpod/cmd/podman/ioprojectatomicpodman" + "github.com/projectatomic/libpod/pkg/varlinkapi" + "github.com/projectatomic/libpod/version" + "github.com/urfave/cli" + "github.com/varlink/go/varlink" +) + +var ( + varlinkDescription = ` + podman varlink + + run varlink interface +` + varlinkFlags = []cli.Flag{} + varlinkCommand = cli.Command{ + Name: "varlink", + Usage: "Run varlink interface", + Description: varlinkDescription, + Flags: varlinkFlags, + Action: varlinkCmd, + ArgsUsage: "VARLINK_URI", + } +) + +func varlinkCmd(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + return errors.Errorf("you must provide a varlink URI") + } + + var varlinkInterfaces = []*ioprojectatomicpodman.VarlinkInterface{varlinkapi.VarlinkLibpod} + // Register varlink service. The metadata can be retrieved with: + // $ varlink info [varlink address URI] + service, err := varlink.NewService( + "Atomic", + "podman", + version.Version, + "https://github.com/projectatomic/libpod", + ) + if err != nil { + return errors.Wrapf(err, "unable to create new varlink service") + } + + for _, i := range varlinkInterfaces { + if err := service.RegisterInterface(i); err != nil { + return errors.Errorf("unable to register varlink interface %v", i) + } + } + + // Run the varlink server at the given address + if err = service.Listen(args[0], 0); err != nil { + return errors.Errorf("unable to start varlink service") + } + + return nil +} |