summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-03-26 09:39:14 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-23 14:29:45 +0000
commit8493dba23c73617d9529b7ca13b400d50ac6f455 (patch)
treec0de0c67334b9fa7166e01cae95dc560c1e2455a /libpod
parentcf1d884ffa45b342f38a78189bbd86186ce6cbfe (diff)
downloadpodman-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 'libpod')
-rw-r--r--libpod/version.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/libpod/version.go b/libpod/version.go
new file mode 100644
index 000000000..9bc4fe616
--- /dev/null
+++ b/libpod/version.go
@@ -0,0 +1,50 @@
+package libpod
+
+import (
+ "runtime"
+ "strconv"
+
+ "github.com/projectatomic/libpod/cmd/podman/ioprojectatomicpodman"
+ podmanVersion "github.com/projectatomic/libpod/version"
+)
+
+// 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
+)
+
+//Version is an output struct for varlink
+type Version struct {
+ ioprojectatomicpodman.VarlinkInterface
+ Version string
+ GoVersion string
+ GitCommit string
+ Built int64
+ OsArch string
+}
+
+// GetVersion returns a VersionOutput struct for varlink and podman
+func GetVersion() (Version, error) {
+ var err error
+ var buildTime int64
+ if BuildInfo != "" {
+ // Converts unix time from string to int64
+ buildTime, err = strconv.ParseInt(BuildInfo, 10, 64)
+
+ if err != nil {
+ return Version{}, err
+ }
+ }
+ return Version{
+ Version: podmanVersion.Version,
+ GoVersion: runtime.Version(),
+ GitCommit: GitCommit,
+ Built: buildTime,
+ OsArch: runtime.GOOS + "/" + runtime.GOARCH,
+ }, nil
+}