Merge pull request #12679 from adcaes/12607-remove-error-check

Add intValue and use it to get timeout form param in postContainersRestart
This commit is contained in:
Alexander Morozov 2015-05-05 09:38:45 -07:00
Родитель 91fb4d672a a2c76912e0
Коммит e894a901db
3 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -11,7 +11,7 @@ func boolValue(r *http.Request, k string) bool {
return !(s == "" || s == "0" || s == "no" || s == "false" || s == "none")
}
func int64Value(r *http.Request, k string) int64 {
func int64ValueOrZero(r *http.Request, k string) int64 {
val, err := strconv.ParseInt(r.FormValue(k), 10, 64)
if err != nil {
return 0

Просмотреть файл

@ -33,7 +33,7 @@ func TestBoolValue(t *testing.T) {
}
}
func TestInt64Value(t *testing.T) {
func TestInt64ValueOrZero(t *testing.T) {
cases := map[string]int64{
"": 0,
"asdf": 0,
@ -47,7 +47,7 @@ func TestInt64Value(t *testing.T) {
r, _ := http.NewRequest("POST", "", nil)
r.Form = v
a := int64Value(r, "test")
a := int64ValueOrZero(r, "test")
if a != e {
t.Fatalf("Value: %s, expected: %v, actual: %v", c, e, a)
}

Просмотреть файл

@ -1295,10 +1295,10 @@ func (s *Server) postBuild(version version.Version, w http.ResponseWriter, r *ht
buildConfig.ForceRemove = boolValue(r, "forcerm")
buildConfig.AuthConfig = authConfig
buildConfig.ConfigFile = configFile
buildConfig.MemorySwap = int64Value(r, "memswap")
buildConfig.Memory = int64Value(r, "memory")
buildConfig.CpuShares = int64Value(r, "cpushares")
buildConfig.CpuQuota = int64Value(r, "cpuquota")
buildConfig.MemorySwap = int64ValueOrZero(r, "memswap")
buildConfig.Memory = int64ValueOrZero(r, "memory")
buildConfig.CpuShares = int64ValueOrZero(r, "cpushares")
buildConfig.CpuQuota = int64ValueOrZero(r, "cpuquota")
buildConfig.CpuSetCpus = r.FormValue("cpusetcpus")
buildConfig.CpuSetMems = r.FormValue("cpusetmems")