From 8561b996447793999a6465f9b9e3f0f7bbea2c6a Mon Sep 17 00:00:00 2001 From: baude Date: Tue, 25 Jun 2019 08:40:19 -0500 Subject: libpod removal from main (phase 2) this is phase 2 for the removal of libpod from main. Signed-off-by: baude --- libpod/define/version.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 libpod/define/version.go (limited to 'libpod/define/version.go') diff --git a/libpod/define/version.go b/libpod/define/version.go new file mode 100644 index 000000000..0f9f49050 --- /dev/null +++ b/libpod/define/version.go @@ -0,0 +1,50 @@ +package define + +import ( + "runtime" + "strconv" + + podmanVersion "github.com/containers/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 { + RemoteAPIVersion int64 + 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{ + RemoteAPIVersion: podmanVersion.RemoteAPIVersion, + Version: podmanVersion.Version, + GoVersion: runtime.Version(), + GitCommit: gitCommit, + Built: buildTime, + OsArch: runtime.GOOS + "/" + runtime.GOARCH, + }, nil +} -- cgit v1.2.3-54-g00ecf