summaryrefslogtreecommitdiff
path: root/libpod/info.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-09-27 12:45:01 -0500
committerbaude <bbaude@redhat.com>2018-09-28 10:48:16 -0500
commit6db7027e975029bc8c50fef958452d502620edea (patch)
tree3b55f94a0f2d1deb82431abfc59476b07a91dafb /libpod/info.go
parentca8469aace64d71fdb1849607d8227c31a3cf4da (diff)
downloadpodman-6db7027e975029bc8c50fef958452d502620edea.tar.gz
podman-6db7027e975029bc8c50fef958452d502620edea.tar.bz2
podman-6db7027e975029bc8c50fef958452d502620edea.zip
Add buildah version and distribution to info
For the sake of debug and problem reporting, we would benefit from knowing what buildah version was vendored into podman. Also, knowing the distribution and distribution version would also be handy. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/info.go')
-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
+}