summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/commit.go2
-rw-r--r--cmd/podman/common.go6
-rw-r--r--cmd/podman/create.go7
-rw-r--r--cmd/podman/history.go2
-rw-r--r--cmd/podman/images.go25
-rw-r--r--cmd/podman/import.go2
-rw-r--r--cmd/podman/info.go2
-rw-r--r--cmd/podman/inspect.go9
-rw-r--r--cmd/podman/ioprojectatomicpodman/generate.go3
-rw-r--r--cmd/podman/ioprojectatomicpodman/io.projectatomic.podman.varlink65
-rw-r--r--cmd/podman/load.go8
-rw-r--r--cmd/podman/main.go1
-rw-r--r--cmd/podman/pull.go2
-rw-r--r--cmd/podman/push.go20
-rw-r--r--cmd/podman/restart.go2
-rw-r--r--cmd/podman/run.go10
-rw-r--r--cmd/podman/save.go2
-rw-r--r--cmd/podman/start.go2
-rw-r--r--cmd/podman/utils.go7
-rw-r--r--cmd/podman/varlink.go60
-rw-r--r--cmd/podman/version.go39
21 files changed, 211 insertions, 65 deletions
diff --git a/cmd/podman/commit.go b/cmd/podman/commit.go
index 57798156b..ef45a9f05 100644
--- a/cmd/podman/commit.go
+++ b/cmd/podman/commit.go
@@ -100,7 +100,7 @@ func commitCmd(c *cli.Context) error {
Changes: c.StringSlice("change"),
Author: c.String("author"),
}
- newImage, err := ctr.Commit(reference, options)
+ newImage, err := ctr.Commit(getContext(), reference, options)
if err != nil {
return err
}
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index 755285c95..9ee99bebc 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -1,6 +1,7 @@
package main
import (
+ "context"
"reflect"
"regexp"
"strings"
@@ -67,6 +68,11 @@ func validateFlags(c *cli.Context, flags []cli.Flag) error {
return nil
}
+// getContext returns a non-nil, empty context
+func getContext() context.Context {
+ return context.TODO()
+}
+
// Common flags shared between commands
var createFlags = []cli.Flag{
cli.StringSliceFlag{
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 97490d6c0..930f90483 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -180,12 +180,13 @@ func createCmd(c *cli.Context) error {
defer runtime.Shutdown(false)
rtc := runtime.GetConfig()
+ ctx := getContext()
- newImage, err := runtime.ImageRuntime().New(c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false)
+ newImage, err := runtime.ImageRuntime().New(ctx, c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false)
if err != nil {
return err
}
- data, err := newImage.Inspect()
+ data, err := newImage.Inspect(ctx)
createConfig, err := parseCreateOpts(c, runtime, newImage.Names()[0], data)
if err != nil {
return err
@@ -209,7 +210,7 @@ func createCmd(c *cli.Context) error {
options = append(options, libpod.WithShmDir(createConfig.ShmDir))
options = append(options, libpod.WithShmSize(createConfig.Resources.ShmSize))
options = append(options, libpod.WithGroups(createConfig.GroupAdd))
- ctr, err := runtime.NewContainer(runtimeSpec, options...)
+ ctr, err := runtime.NewContainer(ctx, runtimeSpec, options...)
if err != nil {
return err
}
diff --git a/cmd/podman/history.go b/cmd/podman/history.go
index 0f9698f4f..51ad0edcb 100644
--- a/cmd/podman/history.go
+++ b/cmd/podman/history.go
@@ -110,7 +110,7 @@ func historyCmd(c *cli.Context) error {
format: format,
}
- history, layers, err := image.History()
+ history, layers, err := image.History(getContext())
if err != nil {
return errors.Wrapf(err, "error getting history of image %q", image.InputName)
}
diff --git a/cmd/podman/images.go b/cmd/podman/images.go
index 4e2114705..076c5956d 100644
--- a/cmd/podman/images.go
+++ b/cmd/podman/images.go
@@ -1,6 +1,7 @@
package main
import (
+ "context"
"reflect"
"strings"
"time"
@@ -105,8 +106,10 @@ func imagesCmd(c *cli.Context) error {
return errors.New("'podman images' requires at most 1 argument")
}
+ ctx := getContext()
+
if len(c.StringSlice("filter")) > 0 || newImage != nil {
- filterFuncs, err = CreateFilterFuncs(runtime, c, newImage)
+ filterFuncs, err = CreateFilterFuncs(ctx, runtime, c, newImage)
if err != nil {
return err
}
@@ -141,7 +144,7 @@ func imagesCmd(c *cli.Context) error {
filteredImages = images
}
- return generateImagesOutput(runtime, filteredImages, opts)
+ return generateImagesOutput(ctx, runtime, filteredImages, opts)
}
func (i imagesOptions) setOutputFormat() string {
@@ -179,7 +182,7 @@ func imagesToGeneric(templParams []imagesTemplateParams, JSONParams []imagesJSON
}
// getImagesTemplateOutput returns the images information to be printed in human readable format
-func getImagesTemplateOutput(runtime *libpod.Runtime, images []*image.Image, opts imagesOptions) (imagesOutput []imagesTemplateParams) {
+func getImagesTemplateOutput(ctx context.Context, runtime *libpod.Runtime, images []*image.Image, opts imagesOptions) (imagesOutput []imagesTemplateParams) {
for _, img := range images {
createdTime := img.Created()
@@ -190,7 +193,7 @@ func getImagesTemplateOutput(runtime *libpod.Runtime, images []*image.Image, opt
// get all specified repo:tag pairs and print them separately
for repo, tags := range image.ReposToMap(img.Names()) {
for _, tag := range tags {
- size, err := img.Size()
+ size, err := img.Size(ctx)
if err != nil {
size = nil
}
@@ -210,9 +213,9 @@ func getImagesTemplateOutput(runtime *libpod.Runtime, images []*image.Image, opt
}
// getImagesJSONOutput returns the images information in its raw form
-func getImagesJSONOutput(runtime *libpod.Runtime, images []*image.Image) (imagesOutput []imagesJSONParams) {
+func getImagesJSONOutput(ctx context.Context, runtime *libpod.Runtime, images []*image.Image) (imagesOutput []imagesJSONParams) {
for _, img := range images {
- size, err := img.Size()
+ size, err := img.Size(ctx)
if err != nil {
size = nil
}
@@ -230,7 +233,7 @@ func getImagesJSONOutput(runtime *libpod.Runtime, images []*image.Image) (images
// generateImagesOutput generates the images based on the format provided
-func generateImagesOutput(runtime *libpod.Runtime, images []*image.Image, opts imagesOptions) error {
+func generateImagesOutput(ctx context.Context, runtime *libpod.Runtime, images []*image.Image, opts imagesOptions) error {
if len(images) == 0 {
return nil
}
@@ -238,10 +241,10 @@ func generateImagesOutput(runtime *libpod.Runtime, images []*image.Image, opts i
switch opts.format {
case formats.JSONString:
- imagesOutput := getImagesJSONOutput(runtime, images)
+ imagesOutput := getImagesJSONOutput(ctx, runtime, images)
out = formats.JSONStructArray{Output: imagesToGeneric([]imagesTemplateParams{}, imagesOutput)}
default:
- imagesOutput := getImagesTemplateOutput(runtime, images, opts)
+ imagesOutput := getImagesTemplateOutput(ctx, runtime, images, opts)
out = formats.StdoutTemplateArray{Output: imagesToGeneric(imagesOutput, []imagesJSONParams{}), Template: opts.outputformat, Fields: imagesOutput[0].HeaderMap()}
}
return formats.Writer(out).Out()
@@ -266,7 +269,7 @@ func (i *imagesTemplateParams) HeaderMap() map[string]string {
// CreateFilterFuncs returns an array of filter functions based on the user inputs
// and is later used to filter images for output
-func CreateFilterFuncs(r *libpod.Runtime, c *cli.Context, img *image.Image) ([]image.ResultFilter, error) {
+func CreateFilterFuncs(ctx context.Context, r *libpod.Runtime, c *cli.Context, img *image.Image) ([]image.ResultFilter, error) {
var filterFuncs []image.ResultFilter
for _, filter := range c.StringSlice("filter") {
splitFilter := strings.Split(filter, "=")
@@ -287,7 +290,7 @@ func CreateFilterFuncs(r *libpod.Runtime, c *cli.Context, img *image.Image) ([]i
filterFuncs = append(filterFuncs, image.DanglingFilter())
case "label":
labelFilter := strings.Join(splitFilter[1:], "=")
- filterFuncs = append(filterFuncs, image.LabelFilter(labelFilter))
+ filterFuncs = append(filterFuncs, image.LabelFilter(ctx, labelFilter))
default:
return nil, errors.Errorf("invalid filter %s ", splitFilter[0])
}
diff --git a/cmd/podman/import.go b/cmd/podman/import.go
index bebd4486c..f57d70af0 100644
--- a/cmd/podman/import.go
+++ b/cmd/podman/import.go
@@ -107,7 +107,7 @@ func importCmd(c *cli.Context) error {
source = file
}
- newImage, err := runtime.ImageRuntime().Import(source, reference, writer, image.SigningOptions{}, config)
+ newImage, err := runtime.ImageRuntime().Import(getContext(), source, reference, writer, image.SigningOptions{}, config)
if err == nil {
fmt.Println(newImage.ID())
}
diff --git a/cmd/podman/info.go b/cmd/podman/info.go
index 89f32a258..1c4ba2515 100644
--- a/cmd/podman/info.go
+++ b/cmd/podman/info.go
@@ -79,6 +79,6 @@ func debugInfo(c *cli.Context) map[string]interface{} {
info["compiler"] = runtime.Compiler
info["go version"] = runtime.Version()
info["podman version"] = c.App.Version
- info["git commit"] = gitCommit
+ info["git commit"] = libpod.GitCommit
return info
}
diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go
index 4c4154d88..ce6ccd77f 100644
--- a/cmd/podman/inspect.go
+++ b/cmd/podman/inspect.go
@@ -1,6 +1,7 @@
package main
import (
+ "context"
"encoding/json"
"strings"
@@ -86,7 +87,7 @@ func inspectCmd(c *cli.Context) error {
inspectType = inspectTypeContainer
}
- inspectedObjects, iterateErr := iterateInput(c, args, runtime, inspectType)
+ inspectedObjects, iterateErr := iterateInput(getContext(), c, args, runtime, inspectType)
var out formats.Writer
if outputFormat != "" && outputFormat != formats.JSONString {
@@ -102,7 +103,7 @@ func inspectCmd(c *cli.Context) error {
}
// func iterateInput iterates the images|containers the user has requested and returns the inspect data and error
-func iterateInput(c *cli.Context, args []string, runtime *libpod.Runtime, inspectType string) ([]interface{}, error) {
+func iterateInput(ctx context.Context, c *cli.Context, args []string, runtime *libpod.Runtime, inspectType string) ([]interface{}, error) {
var (
data interface{}
inspectedItems []interface{}
@@ -133,7 +134,7 @@ func iterateInput(c *cli.Context, args []string, runtime *libpod.Runtime, inspec
inspectError = errors.Wrapf(err, "error getting image %q", input)
break
}
- data, err = image.Inspect()
+ data, err = image.Inspect(ctx)
if err != nil {
inspectError = errors.Wrapf(err, "error parsing image data %q", image.ID())
break
@@ -146,7 +147,7 @@ func iterateInput(c *cli.Context, args []string, runtime *libpod.Runtime, inspec
inspectError = errors.Wrapf(err, "error getting image %q", input)
break
}
- data, err = image.Inspect()
+ data, err = image.Inspect(ctx)
if err != nil {
inspectError = errors.Wrapf(err, "error parsing image data %q", image.ID())
break
diff --git a/cmd/podman/ioprojectatomicpodman/generate.go b/cmd/podman/ioprojectatomicpodman/generate.go
new file mode 100644
index 000000000..b24234f0a
--- /dev/null
+++ b/cmd/podman/ioprojectatomicpodman/generate.go
@@ -0,0 +1,3 @@
+package ioprojectatomicpodman
+
+//go:generate $GOPATH/bin/varlink-go-interface-generator io.projectatomic.podman.varlink
diff --git a/cmd/podman/ioprojectatomicpodman/io.projectatomic.podman.varlink b/cmd/podman/ioprojectatomicpodman/io.projectatomic.podman.varlink
new file mode 100644
index 000000000..00a99017c
--- /dev/null
+++ b/cmd/podman/ioprojectatomicpodman/io.projectatomic.podman.varlink
@@ -0,0 +1,65 @@
+# Podman Service Interface
+interface io.projectatomic.podman
+
+type Version (
+ version: string,
+ go_version: string,
+ git_commit: string,
+ built: int,
+ os_arch: string
+)
+
+type NotImplemented (
+ comment: string
+)
+
+type StringResponse (
+ message: string
+)
+
+# System
+method Ping() -> (ping: StringResponse)
+method GetVersion() -> (version: Version)
+
+# Containers
+method ListContainers() -> (notimplemented: NotImplemented)
+method CreateContainer() -> (notimplemented: NotImplemented)
+method InspectContainer() -> (notimplemented: NotImplemented)
+method ListContainerProcesses() -> (notimplemented: NotImplemented)
+method GetContainerLogs() -> (notimplemented: NotImplemented)
+method ListContainerChanges() -> (notimplemented: NotImplemented)
+method ExportContainer() -> (notimplemented: NotImplemented)
+method GetContainerStats() -> (notimplemented: NotImplemented)
+method ResizeContainerTty() -> (notimplemented: NotImplemented)
+method StartContainer() -> (notimplemented: NotImplemented)
+method StopContainer() -> (notimplemented: NotImplemented)
+method RestartContainer() -> (notimplemented: NotImplemented)
+method KillContainer() -> (notimplemented: NotImplemented)
+method UpdateContainer() -> (notimplemented: NotImplemented)
+method RenameContainer() -> (notimplemented: NotImplemented)
+method PauseContainer() -> (notimplemented: NotImplemented)
+method UnpauseContainer() -> (notimplemented: NotImplemented)
+method AttachToContainer() -> (notimplemented: NotImplemented)
+method WaitContainer() -> (notimplemented: NotImplemented)
+method RemoveContainer() -> (notimplemented: NotImplemented)
+method DeleteStoppedContainers() -> (notimplemented: NotImplemented)
+
+# Images
+method ListImages() -> (notimplemented: NotImplemented)
+method BuildImage() -> (notimplemented: NotImplemented)
+method CreateImage() -> (notimplemented: NotImplemented)
+method InspectImage() -> (notimplemented: NotImplemented)
+method HistoryImage() -> (notimplemented: NotImplemented)
+method PushImage() -> (notimplemented: NotImplemented)
+method TagImage() -> (notimplemented: NotImplemented)
+method RemoveImage() -> (notimplemented: NotImplemented)
+method SearchImage() -> (notimplemented: NotImplemented)
+method DeleteUnusedImages() -> (notimplemented: NotImplemented)
+method CreateFromContainer() -> (notimplemented: NotImplemented)
+method ImportImage() -> (notimplemented: NotImplemented)
+method ExportImage() -> (notimplemented: NotImplemented)
+method PullImage() -> (notimplemented: NotImplemented)
+
+
+# Something failed
+error ActionFailed (reason: string)
diff --git a/cmd/podman/load.go b/cmd/podman/load.go
index 1fb723750..ec616170c 100644
--- a/cmd/podman/load.go
+++ b/cmd/podman/load.go
@@ -98,18 +98,20 @@ func loadCmd(c *cli.Context) error {
writer = os.Stderr
}
+ ctx := getContext()
+
src := libpod.DockerArchive + ":" + input
- newImage, err := runtime.ImageRuntime().New(src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false)
+ newImage, err := runtime.ImageRuntime().New(ctx, src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false)
if err != nil {
// generate full src name with specified image:tag
fullSrc := libpod.OCIArchive + ":" + input
if image != "" {
fullSrc = fullSrc + ":" + image
}
- newImage, err = runtime.ImageRuntime().New(fullSrc, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false)
+ newImage, err = runtime.ImageRuntime().New(ctx, fullSrc, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false)
if err != nil {
src = libpod.DirTransport + ":" + input
- newImage, err = runtime.ImageRuntime().New(src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false)
+ newImage, err = runtime.ImageRuntime().New(ctx, src, c.String("signature-policy"), "", writer, &libpodImage.DockerRegistryOptions{}, libpodImage.SigningOptions{}, false, false)
if err != nil {
return errors.Wrapf(err, "error pulling %q", src)
}
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index ef11f7905..a283c2622 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -70,6 +70,7 @@ func main() {
topCommand,
umountCommand,
unpauseCommand,
+ varlinkCommand,
versionCommand,
waitCommand,
}
diff --git a/cmd/podman/pull.go b/cmd/podman/pull.go
index cab549a02..14e4e9252 100644
--- a/cmd/podman/pull.go
+++ b/cmd/podman/pull.go
@@ -103,7 +103,7 @@ func pullCmd(c *cli.Context) error {
forceSecure = c.Bool("tls-verify")
}
- newImage, err := runtime.ImageRuntime().New(image, c.String("signature-policy"), c.String("authfile"), writer, &dockerRegistryOptions, image2.SigningOptions{}, true, forceSecure)
+ newImage, err := runtime.ImageRuntime().New(getContext(), image, c.String("signature-policy"), c.String("authfile"), writer, &dockerRegistryOptions, image2.SigningOptions{}, true, forceSecure)
if err != nil {
return errors.Wrapf(err, "error pulling image %q", image)
}
diff --git a/cmd/podman/push.go b/cmd/podman/push.go
index 3a39a1a0e..369d4d4f2 100644
--- a/cmd/podman/push.go
+++ b/cmd/podman/push.go
@@ -76,17 +76,25 @@ var (
)
func pushCmd(c *cli.Context) error {
- var registryCreds *types.DockerAuthConfig
+ var (
+ registryCreds *types.DockerAuthConfig
+ destName string
+ )
args := c.Args()
- if len(args) < 2 {
- return errors.New("podman push requires exactly 2 arguments")
+ srcName := args[0]
+ if len(args) == 0 || len(args) > 2 {
+ return errors.New("podman push requires at least one image name, and optionally a second to specify a different destination name")
+ }
+ switch len(args) {
+ case 1:
+ destName = args[0]
+ case 2:
+ destName = args[1]
}
if err := validateFlags(c, pushFlags); err != nil {
return err
}
- srcName := args[0]
- destName := args[1]
// --compress and --format can only be used for the "dir" transport
splitArg := strings.SplitN(destName, ":", 2)
@@ -151,5 +159,5 @@ func pushCmd(c *cli.Context) error {
}
//return runtime.PushImage(srcName, destName, options)
- return newImage.PushImage(destName, manifestType, c.String("authfile"), c.String("signature-policy"), writer, c.Bool("compress"), so, &dockerRegistryOptions)
+ return newImage.PushImage(getContext(), destName, manifestType, c.String("authfile"), c.String("signature-policy"), writer, c.Bool("compress"), so, &dockerRegistryOptions)
}
diff --git a/cmd/podman/restart.go b/cmd/podman/restart.go
index 84aa5f830..7eb168743 100644
--- a/cmd/podman/restart.go
+++ b/cmd/podman/restart.go
@@ -105,7 +105,7 @@ func restartCtr(timeout uint, ctr *libpod.Container) error {
}
}
- if err := ctr.Start(); err != nil {
+ if err := ctr.Start(getContext()); err != nil {
return err
}
diff --git a/cmd/podman/run.go b/cmd/podman/run.go
index ac6361070..abb319a63 100644
--- a/cmd/podman/run.go
+++ b/cmd/podman/run.go
@@ -58,13 +58,15 @@ func runCmd(c *cli.Context) error {
return errors.Errorf("image name or ID is required")
}
+ ctx := getContext()
+
rtc := runtime.GetConfig()
- newImage, err := runtime.ImageRuntime().New(c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false)
+ newImage, err := runtime.ImageRuntime().New(ctx, c.Args()[0], rtc.SignaturePolicyPath, "", os.Stderr, nil, image.SigningOptions{}, false, false)
if err != nil {
return errors.Wrapf(err, "unable to find image")
}
- data, err := newImage.Inspect()
+ data, err := newImage.Inspect(ctx)
if err != nil {
return err
}
@@ -105,7 +107,7 @@ func runCmd(c *cli.Context) error {
options = append(options, libpod.WithCgroupParent(createConfig.CgroupParent))
}
- ctr, err := runtime.NewContainer(runtimeSpec, options...)
+ ctr, err := runtime.NewContainer(ctx, runtimeSpec, options...)
if err != nil {
return err
}
@@ -133,7 +135,7 @@ func runCmd(c *cli.Context) error {
// Handle detached start
if createConfig.Detach {
- if err := ctr.Start(); err != nil {
+ if err := ctr.Start(ctx); err != nil {
// This means the command did not exist
exitCode = 127
if strings.Index(err.Error(), "permission denied") > -1 {
diff --git a/cmd/podman/save.go b/cmd/podman/save.go
index 009984640..edf725e6d 100644
--- a/cmd/podman/save.go
+++ b/cmd/podman/save.go
@@ -117,7 +117,7 @@ func saveCmd(c *cli.Context) error {
if err != nil {
return err
}
- if err := newImage.PushImage(dest, manifestType, "", "", writer, c.Bool("compress"), libpodImage.SigningOptions{}, &libpodImage.DockerRegistryOptions{}); err != nil {
+ if err := newImage.PushImage(getContext(), dest, manifestType, "", "", writer, c.Bool("compress"), libpodImage.SigningOptions{}, &libpodImage.DockerRegistryOptions{}); err != nil {
if err2 := os.Remove(output); err2 != nil {
logrus.Errorf("error deleting %q: %v", output, err)
}
diff --git a/cmd/podman/start.go b/cmd/podman/start.go
index 06b8f815f..fb16e08cd 100644
--- a/cmd/podman/start.go
+++ b/cmd/podman/start.go
@@ -121,7 +121,7 @@ func startCmd(c *cli.Context) error {
continue
}
// Handle non-attach start
- if err := ctr.Start(); err != nil {
+ if err := ctr.Start(getContext()); err != nil {
if lastError != nil {
fmt.Fprintln(os.Stderr, lastError)
}
diff --git a/cmd/podman/utils.go b/cmd/podman/utils.go
index 925674474..cf0047db9 100644
--- a/cmd/podman/utils.go
+++ b/cmd/podman/utils.go
@@ -1,6 +1,7 @@
package main
import (
+ "fmt"
"os"
gosignal "os/signal"
@@ -161,7 +162,7 @@ func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detac
streams.AttachInput = false
}
- attachChan, err := ctr.StartAndAttach(streams, detachKeys, resize)
+ attachChan, err := ctr.StartAndAttach(getContext(), streams, detachKeys, resize)
if err != nil {
return err
}
@@ -170,6 +171,10 @@ func startAttachCtr(ctr *libpod.Container, stdout, stderr, stdin *os.File, detac
ProxySignals(ctr)
}
+ if stdout == nil && stderr == nil {
+ fmt.Printf("%s\n", ctr.ID())
+ }
+
err = <-attachChan
if err != nil {
return errors.Wrapf(err, "error attaching to container %s", ctr.ID())
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
+}
diff --git a/cmd/podman/version.go b/cmd/podman/version.go
index be9b406e7..952cf32d3 100644
--- a/cmd/podman/version.go
+++ b/cmd/podman/version.go
@@ -2,41 +2,30 @@ package main
import (
"fmt"
- "runtime"
- "strconv"
"time"
+ "github.com/pkg/errors"
+ "github.com/projectatomic/libpod/libpod"
"github.com/urfave/cli"
)
-// Overwritten at build time
-var (
- // gitCommit is the commit that the binary is being built from.
- // It will be populated by the Makefile.
- gitCommit string
- // buildInfo is the time at which the binary was built
- // It will be populated by the Makefile.
- buildInfo string
-)
-
// versionCmd gets and prints version info for version command
func versionCmd(c *cli.Context) error {
- fmt.Println("Version: ", c.App.Version)
- fmt.Println("Go Version: ", runtime.Version())
- if gitCommit != "" {
- fmt.Println("Git Commit: ", gitCommit)
+ output, err := libpod.GetVersion()
+ if err != nil {
+ errors.Wrapf(err, "unable to determine version")
+ }
+ fmt.Println("Version: ", output.Version)
+ fmt.Println("Go Version: ", output.GoVersion)
+ if output.GitCommit != "" {
+ fmt.Println("Git Commit: ", output.GitCommit)
}
- if buildInfo != "" {
- // Converts unix time from string to int64
- buildTime, err := strconv.ParseInt(buildInfo, 10, 64)
- if err != nil {
- return err
- }
- // Prints out the build time in readable format
- fmt.Println("Built: ", time.Unix(buildTime, 0).Format(time.ANSIC))
+ // Prints out the build time in readable format
+ if libpod.BuildInfo != "" {
+ fmt.Println("Built: ", time.Unix(output.Built, 0).Format(time.ANSIC))
}
- fmt.Println("OS/Arch: ", runtime.GOOS+"/"+runtime.GOARCH)
+ fmt.Println("OS/Arch: ", output.OsArch)
return nil
}