Files
podman/libpod/version.go
Anders F Björklund b2fef1a8ba Fix setting of version information
It was setting the wrong variable (CamelCase)
in the wrong module ("main", not "libpod")...

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2018-10-31 00:27:08 +01:00

49 lines
1.0 KiB
Go

package libpod
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 {
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
}