Move duration and size to units pkg

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby
2014-05-12 17:05:07 -07:00
parent 0d78799db7
commit d33b4655c4
11 changed files with 165 additions and 140 deletions
@@ -8,7 +8,7 @@ import (
"strings"
"github.com/dotcloud/docker/pkg/libcontainer"
"github.com/dotcloud/docker/utils"
"github.com/dotcloud/docker/pkg/units"
)
type Action func(*libcontainer.Container, interface{}, string) error
@@ -75,7 +75,7 @@ func memory(container *libcontainer.Container, context interface{}, value string
return fmt.Errorf("cannot set cgroups when they are disabled")
}
v, err := utils.RAMInBytes(value)
v, err := units.RAMInBytes(value)
if err != nil {
return err
}
@@ -88,7 +88,7 @@ func memoryReservation(container *libcontainer.Container, context interface{}, v
return fmt.Errorf("cannot set cgroups when they are disabled")
}
v, err := utils.RAMInBytes(value)
v, err := units.RAMInBytes(value)
if err != nil {
return err
}
+4 -3
View File
@@ -2,9 +2,10 @@ package daemon
import (
"fmt"
"github.com/dotcloud/docker/utils"
"sync"
"time"
"github.com/dotcloud/docker/pkg/units"
)
type State struct {
@@ -22,12 +23,12 @@ func (s *State) String() string {
defer s.RUnlock()
if s.Running {
return fmt.Sprintf("Up %s", utils.HumanDuration(time.Now().UTC().Sub(s.StartedAt)))
return fmt.Sprintf("Up %s", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt)))
}
if s.FinishedAt.IsZero() {
return ""
}
return fmt.Sprintf("Exited (%d) %s ago", s.ExitCode, utils.HumanDuration(time.Now().UTC().Sub(s.FinishedAt)))
return fmt.Sprintf("Exited (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt)))
}
func (s *State) IsRunning() bool {