summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-09-28 11:09:08 -0700
committerGitHub <noreply@github.com>2018-09-28 11:09:08 -0700
commit77d80228481d1902be0a9ed30622189b54d2e3b0 (patch)
tree3b55f94a0f2d1deb82431abfc59476b07a91dafb /libpod
parentca8469aace64d71fdb1849607d8227c31a3cf4da (diff)
parent6db7027e975029bc8c50fef958452d502620edea (diff)
downloadpodman-77d80228481d1902be0a9ed30622189b54d2e3b0.tar.gz
podman-77d80228481d1902be0a9ed30622189b54d2e3b0.tar.bz2
podman-77d80228481d1902be0a9ed30622189b54d2e3b0.zip
Merge pull request #1561 from baude/addbuildahdisttoinfo
Add buildah version and distribution to info
Diffstat (limited to 'libpod')
-rw-r--r--libpod/info.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/libpod/info.go b/libpod/info.go
index 3add1ce0f..4cbf3f734 100644
--- a/libpod/info.go
+++ b/libpod/info.go
@@ -1,8 +1,10 @@
package libpod
import (
+ "bufio"
"bytes"
"fmt"
+ "github.com/containers/buildah"
"io/ioutil"
"os"
"runtime"
@@ -39,6 +41,7 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) {
info["SwapFree"] = mi.SwapFree
conmonVersion, _ := r.GetConmonVersion()
ociruntimeVersion, _ := r.GetOCIRuntimeVersion()
+ hostDistributionInfo := r.GetHostDistributionInfo()
info["Conmon"] = map[string]interface{}{
"path": r.conmonPath,
"package": r.ociRuntime.conmonPackage(),
@@ -49,7 +52,12 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) {
"package": r.ociRuntime.pathPackage(),
"version": ociruntimeVersion,
}
+ info["Distribution"] = map[string]interface{}{
+ "distribution": hostDistributionInfo["Distribution"],
+ "version": hostDistributionInfo["Version"],
+ }
+ info["BuildahVersion"] = buildah.Version
kv, err := readKernelVersion()
if err != nil {
return nil, errors.Wrapf(err, "error reading kernel version")
@@ -178,3 +186,30 @@ func (r *Runtime) GetOCIRuntimeVersion() (string, error) {
}
return strings.TrimSuffix(output, "\n"), nil
}
+
+// GetHostDistributionInfo returns a map containing the host's distribution and version
+func (r *Runtime) GetHostDistributionInfo() map[string]string {
+ dist := make(map[string]string)
+
+ // Populate values in case we cannot find the values
+ // or the file
+ dist["Distribution"] = "unknown"
+ dist["Version"] = "unknown"
+
+ f, err := os.Open("/etc/os-release")
+ if err != nil {
+ return dist
+ }
+ defer f.Close()
+
+ l := bufio.NewScanner(f)
+ for l.Scan() {
+ if strings.HasPrefix(l.Text(), "ID=") {
+ dist["Distribution"] = strings.TrimPrefix(l.Text(), "ID=")
+ }
+ if strings.HasPrefix(l.Text(), "VERSION_ID=") {
+ dist["Version"] = strings.Trim(strings.TrimPrefix(l.Text(), "VERSION_ID="), "\"")
+ }
+ }
+ return dist
+}