Change uptime format in `podman info` to human-readable

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #355
Approved by: rhatdan
This commit is contained in:
Matthew Heon 2018-02-19 11:22:23 -05:00 committed by Atomic Bot
parent 32efbbdf8a
commit 635deb6358
1 changed files with 8 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"runtime"
"time"
"github.com/docker/docker/pkg/system"
"github.com/pkg/errors"
@ -44,7 +45,13 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) {
if err != nil {
return nil, errors.Wrapf(err, "error reading up time")
}
info["uptime"] = up
// Convert uptime in seconds to a human-readable format
upSeconds := up + "s"
upDuration, err := time.ParseDuration(upSeconds)
if err != nil {
return nil, errors.Wrapf(err, "error parsing system uptime")
}
info["uptime"] = upDuration.String()
host, err := os.Hostname()
if err != nil {