From 4f1c9597d8ae7f32b002fae693566ebd9bb0d07f Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Thu, 7 May 2015 15:40:48 -0700 Subject: [PATCH] godeps: Update dockerclient. Signed-off-by: Andrea Luzzardi --- Godeps/Godeps.json | 2 +- .../github.com/samalba/dockerclient/types.go | 94 ++++++++++++++----- 2 files changed, 74 insertions(+), 22 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 51d647a50e..d4066de1e0 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -60,7 +60,7 @@ }, { "ImportPath": "github.com/samalba/dockerclient", - "Rev": "5e5020b90dd4657c33d446356556481182d2d66b" + "Rev": "4e6f4a21c07510dd6446d28053351a275591f08d" }, { "ImportPath": "github.com/samuel/go-zookeeper/zk", diff --git a/Godeps/_workspace/src/github.com/samalba/dockerclient/types.go b/Godeps/_workspace/src/github.com/samalba/dockerclient/types.go index 14f69bd007..09b118e20e 100644 --- a/Godeps/_workspace/src/github.com/samalba/dockerclient/types.go +++ b/Godeps/_workspace/src/github.com/samalba/dockerclient/types.go @@ -1,6 +1,11 @@ package dockerclient -import "time" +import ( + "fmt" + "time" + + "github.com/docker/docker/pkg/units" +) type ContainerConfig struct { Hostname string @@ -78,27 +83,74 @@ type PortBinding struct { HostPort string } -type ContainerInfo struct { - Id string - Created string - Path string - Name string - Args []string - ExecIDs []string - Config *ContainerConfig - State struct { - Running bool - Paused bool - Restarting bool - OOMKilled bool - Dead bool - Pid int - ExitCode int - Error string // contains last known error when starting the container - StartedAt time.Time - FinishedAt time.Time - Ghost bool +type State struct { + Running bool + Paused bool + Restarting bool + OOMKilled bool + Dead bool + Pid int + ExitCode int + Error string // contains last known error when starting the container + StartedAt time.Time + FinishedAt time.Time + Ghost bool +} + +// String returns a human-readable description of the state +// Stoken from docker/docker/daemon/state.go +func (s *State) String() string { + if s.Running { + if s.Paused { + return fmt.Sprintf("Up %s (Paused)", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt))) + } + if s.Restarting { + return fmt.Sprintf("Restarting (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt))) + } + + return fmt.Sprintf("Up %s", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt))) } + + if s.Dead { + return "Dead" + } + + if s.FinishedAt.IsZero() { + return "" + } + + return fmt.Sprintf("Exited (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt))) +} + +// StateString returns a single string to describe state +// Stoken from docker/docker/daemon/state.go +func (s *State) StateString() string { + if s.Running { + if s.Paused { + return "paused" + } + if s.Restarting { + return "restarting" + } + return "running" + } + + if s.Dead { + return "dead" + } + + return "exited" +} + +type ContainerInfo struct { + Id string + Created string + Path string + Name string + Args []string + ExecIDs []string + Config *ContainerConfig + State *State Image string NetworkSettings struct { IPAddress string `json:"IpAddress"`