зеркало из https://github.com/microsoft/docker.git
changed default value of getenvint to 0. fix tests
Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
This commit is contained in:
Родитель
7ced204372
Коммит
28b5ae8cc4
8
api.go
8
api.go
|
@ -584,7 +584,11 @@ func postContainersRestart(srv *Server, version float64, w http.ResponseWriter,
|
|||
return fmt.Errorf("Missing parameter")
|
||||
}
|
||||
job := srv.Eng.Job("restart", vars["name"])
|
||||
if r.Form.Get("t") == "" {
|
||||
job.Setenv("t", "-1")
|
||||
} else {
|
||||
job.Setenv("t", r.Form.Get("t"))
|
||||
}
|
||||
if err := job.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -652,7 +656,11 @@ func postContainersStop(srv *Server, version float64, w http.ResponseWriter, r *
|
|||
return fmt.Errorf("Missing parameter")
|
||||
}
|
||||
job := srv.Eng.Job("stop", vars["name"])
|
||||
if r.Form.Get("t") == "" {
|
||||
job.Setenv("t", "-1")
|
||||
} else {
|
||||
job.Setenv("t", r.Form.Get("t"))
|
||||
}
|
||||
if err := job.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ func DaemonConfigFromJob(job *engine.Job) *DaemonConfig {
|
|||
} else {
|
||||
config.BridgeIface = DefaultNetworkBridge
|
||||
}
|
||||
if mtu := job.GetenvInt("Mtu"); mtu != -1 {
|
||||
if mtu := job.GetenvInt("Mtu"); mtu != 0 {
|
||||
config.Mtu = mtu
|
||||
} else {
|
||||
config.Mtu = DefaultNetworkMtu
|
||||
|
|
|
@ -60,7 +60,7 @@ func (env *Env) GetInt64(key string) int64 {
|
|||
s := strings.Trim(env.Get(key), " \t")
|
||||
val, err := strconv.ParseInt(s, 10, 64)
|
||||
if err != nil {
|
||||
return -1
|
||||
return 0
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ func TestSetenvInt(t *testing.T) {
|
|||
if val := job.GetenvInt("bar"); val != 42 {
|
||||
t.Fatalf("GetenvInt returns incorrect value: %d", val)
|
||||
}
|
||||
if val := job.GetenvInt("nonexistent"); val != -1 {
|
||||
if val := job.GetenvInt("nonexistent"); val != 0 {
|
||||
t.Fatalf("GetenvInt returns incorrect value: %d", val)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1083,7 +1083,7 @@ func (srv *Server) Containers(job *engine.Job) engine.Status {
|
|||
}, -1)
|
||||
|
||||
for _, container := range srv.runtime.List() {
|
||||
if !container.State.IsRunning() && !all && n == -1 && since == "" && before == "" {
|
||||
if !container.State.IsRunning() && !all && n <= 0 && since == "" && before == "" {
|
||||
continue
|
||||
}
|
||||
if before != "" && !foundBefore {
|
||||
|
@ -1092,7 +1092,7 @@ func (srv *Server) Containers(job *engine.Job) engine.Status {
|
|||
}
|
||||
continue
|
||||
}
|
||||
if displayed == n {
|
||||
if n > 0 && displayed == n {
|
||||
break
|
||||
}
|
||||
if container.ID == since || utils.TruncateID(container.ID) == since {
|
||||
|
@ -1742,7 +1742,7 @@ func (srv *Server) ContainerCreate(job *engine.Job) engine.Status {
|
|||
return engine.StatusErr
|
||||
}
|
||||
config := ContainerConfigFromJob(job)
|
||||
if config.Memory > 0 && config.Memory < 524288 {
|
||||
if config.Memory != 0 && config.Memory < 524288 {
|
||||
job.Errorf("Minimum memory limit allowed is 512k")
|
||||
return engine.StatusErr
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче