aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/info.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2017-12-15 16:58:36 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-12-18 16:46:05 +0000
commit5770dc2640c216525ab84031e3712fcc46b3b087 (patch)
tree8a1c5c4e4a6ce6a35a3767247623a62bfd698f77 /cmd/podman/info.go
parentde3468e120d489d046c08dad72ba2262e222ccb1 (diff)
downloadpodman-5770dc2640c216525ab84031e3712fcc46b3b087.tar.gz
podman-5770dc2640c216525ab84031e3712fcc46b3b087.tar.bz2
podman-5770dc2640c216525ab84031e3712fcc46b3b087.zip
Rename all references to kpod to podman
The decision is in, kpod is going to be named podman. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #145 Approved by: umohnani8
Diffstat (limited to 'cmd/podman/info.go')
-rw-r--r--cmd/podman/info.go84
1 files changed, 84 insertions, 0 deletions
diff --git a/cmd/podman/info.go b/cmd/podman/info.go
new file mode 100644
index 000000000..89f32a258
--- /dev/null
+++ b/cmd/podman/info.go
@@ -0,0 +1,84 @@
+package main
+
+import (
+ "runtime"
+
+ "github.com/pkg/errors"
+ "github.com/projectatomic/libpod/cmd/podman/formats"
+ "github.com/projectatomic/libpod/libpod"
+ "github.com/urfave/cli"
+)
+
+var (
+ infoDescription = "display system information"
+ infoCommand = cli.Command{
+ Name: "info",
+ Usage: infoDescription,
+ Description: `Information display here pertain to the host, current storage stats, and build of podman. Useful for the user and when reporting issues.`,
+ Flags: infoFlags,
+ Action: infoCmd,
+ ArgsUsage: "",
+ }
+ infoFlags = []cli.Flag{
+ cli.BoolFlag{
+ Name: "debug, D",
+ Usage: "display additional debug information",
+ },
+ cli.StringFlag{
+ Name: "format",
+ Usage: "Change the output format to JSON or a Go template",
+ },
+ }
+)
+
+func infoCmd(c *cli.Context) error {
+ if err := validateFlags(c, infoFlags); err != nil {
+ return err
+ }
+ info := map[string]interface{}{}
+
+ runtime, err := getRuntime(c)
+ if err != nil {
+ return errors.Wrapf(err, "could not get runtime")
+ }
+ defer runtime.Shutdown(false)
+
+ infoArr, err := runtime.Info()
+ if err != nil {
+ return errors.Wrapf(err, "error getting info")
+ }
+
+ if c.Bool("debug") {
+ debugInfo := debugInfo(c)
+ infoArr = append(infoArr, libpod.InfoData{Type: "debug", Data: debugInfo})
+ }
+
+ for _, currInfo := range infoArr {
+ info[currInfo.Type] = currInfo.Data
+ }
+
+ var out formats.Writer
+ infoOutputFormat := c.String("format")
+ switch infoOutputFormat {
+ case formats.JSONString:
+ out = formats.JSONStruct{Output: info}
+ case "":
+ out = formats.YAMLStruct{Output: info}
+ default:
+ out = formats.StdoutTemplate{Output: info, Template: infoOutputFormat}
+ }
+
+ formats.Writer(out).Out()
+
+ return nil
+}
+
+// top-level "debug" info
+func debugInfo(c *cli.Context) map[string]interface{} {
+ info := map[string]interface{}{}
+ info["compiler"] = runtime.Compiler
+ info["go version"] = runtime.Version()
+ info["podman version"] = c.App.Version
+ info["git commit"] = gitCommit
+ return info
+}