From 99a37afc3ae0616fa99b39ecdb5a436f2150480f Mon Sep 17 00:00:00 2001 From: baude Date: Thu, 2 Aug 2018 16:21:36 -0500 Subject: Add Runc and Conmon versions to Podman Version It will be handy to know the runc and conmon versions as our code gets into the wild. Signed-off-by: baude Closes: #1207 Approved by: rhatdan --- libpod/info.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libpod') diff --git a/libpod/info.go b/libpod/info.go index cc9d55553..fe422747c 100644 --- a/libpod/info.go +++ b/libpod/info.go @@ -7,10 +7,12 @@ import ( "os" "runtime" "strconv" + "strings" "time" "github.com/docker/docker/pkg/system" "github.com/pkg/errors" + "github.com/projectatomic/libpod/utils" ) // InfoData holds the info type, i.e store, host etc and the data for each type @@ -84,6 +86,11 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) { } info["hostname"] = host + // Don't think this should be catastrophic if we cannot get the versions + conmonVersion, _ := r.GetConmonVersion() + ociruntimeVersion, _ := r.GetOCIRuntimeVersion() + info["conmonVersion"] = conmonVersion + info["OCIRuntimeVersion"] = ociruntimeVersion return info, nil } @@ -146,3 +153,21 @@ func readUptime() (string, error) { } return string(f[0]), nil } + +// GetConmonVersion returns a string representation of the conmon version +func (r *Runtime) GetConmonVersion() (string, error) { + output, err := utils.ExecCmd(r.conmonPath, "--version") + if err != nil { + return "", err + } + return strings.TrimSuffix(strings.Replace(output, "\n", ", ", 1), "\n"), nil +} + +// GetOCIRuntimeVersion returns a string representation of the oci runtimes version +func (r *Runtime) GetOCIRuntimeVersion() (string, error) { + output, err := utils.ExecCmd(r.ociRuntimePath, "--version") + if err != nil { + return "", err + } + return strings.TrimSuffix(output, "\n"), nil +} -- cgit v1.2.3-54-g00ecf