mirror of
https://github.com/containers/podman
synced 2024-10-21 01:34:37 +00:00
8489dc4345
With the advent of Podman 2.0.0 we crossed the magical barrier of go modules. While we were able to continue importing all packages inside of the project, the project could not be vendored anymore from the outside. Move the go module to new major version and change all imports to `github.com/containers/libpod/v2`. The renaming of the imports was done via `gomove` [1]. [1] https://github.com/KSubedi/gomove Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package define
|
|
|
|
import (
|
|
"runtime"
|
|
"strconv"
|
|
"time"
|
|
|
|
podmanVersion "github.com/containers/libpod/v2/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 {
|
|
APIVersion int64
|
|
Version string
|
|
GoVersion string
|
|
GitCommit string
|
|
BuiltTime 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{
|
|
APIVersion: podmanVersion.APIVersion,
|
|
Version: podmanVersion.Version,
|
|
GoVersion: runtime.Version(),
|
|
GitCommit: gitCommit,
|
|
BuiltTime: time.Unix(buildTime, 0).Format(time.ANSIC),
|
|
Built: buildTime,
|
|
OsArch: runtime.GOOS + "/" + runtime.GOARCH,
|
|
}, nil
|
|
}
|