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 <bbaude@redhat.com>

Closes: #1207
Approved by: rhatdan
This commit is contained in:
baude
2018-08-02 16:21:36 -05:00
committed by Atomic Bot
parent 5acbbf03e3
commit 99a37afc3a
2 changed files with 68 additions and 16 deletions

View File

@ -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
}