blob: b876efddd17d3b2fd9eb65b0d3e667a2eff5eb6a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
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
// InstallPrefix is the prefix where podman will be installed.
// It will be populated by the Makefile.
installPrefix string = "/usr/local"
// EtcDir is the sysconfdir where podman should look for system config files.
// It will be populated by the Makefile.
etcDir string = "/etc"
)
//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
}
|