mirror of https://github.com/containers/podman.git
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:
parent
32efbbdf8a
commit
635deb6358
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue