summaryrefslogtreecommitdiff
path: root/cmd/kpod/version.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2017-11-01 11:24:59 -0400
committerMatthew Heon <matthew.heon@gmail.com>2017-11-01 11:24:59 -0400
commita031b83a09a8628435317a03f199cdc18b78262f (patch)
treebc017a96769ce6de33745b8b0b1304ccf38e9df0 /cmd/kpod/version.go
parent2b74391cd5281f6fdf391ff8ad50fd1490f6bf89 (diff)
downloadpodman-a031b83a09a8628435317a03f199cdc18b78262f.tar.gz
podman-a031b83a09a8628435317a03f199cdc18b78262f.tar.bz2
podman-a031b83a09a8628435317a03f199cdc18b78262f.zip
Initial checkin from CRI-O repo
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'cmd/kpod/version.go')
-rw-r--r--cmd/kpod/version.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/cmd/kpod/version.go b/cmd/kpod/version.go
new file mode 100644
index 000000000..586c41da6
--- /dev/null
+++ b/cmd/kpod/version.go
@@ -0,0 +1,48 @@
+package main
+
+import (
+ "fmt"
+ "runtime"
+ "strconv"
+ "time"
+
+ "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)
+ }
+ 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))
+ }
+ fmt.Println("OS/Arch: ", runtime.GOOS+"/"+runtime.GOARCH)
+
+ return nil
+}
+
+// Cli command to print out the full version of kpod
+var versionCommand = cli.Command{
+ Name: "version",
+ Usage: "Display the KPOD Version Information",
+ Action: versionCmd,
+}