mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00
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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user