ソースを参照

Rename int64Value to int64ValueOrZero.

Signed-off-by: Adria Casas <adriacasas88@gmail.com>
Adria Casas 10 年 前
コミット
a2c76912e0
3 ファイル変更7 行追加7 行削除
  1. 1 1
      api/server/form.go
  2. 2 2
      api/server/form_test.go
  3. 4 4
      api/server/server.go

+ 1 - 1
api/server/form.go

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

+ 2 - 2
api/server/form_test.go

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

+ 4 - 4
api/server/server.go

@@ -1295,10 +1295,10 @@ func (s *Server) postBuild(version version.Version, w http.ResponseWriter, r *ht
 	buildConfig.ForceRemove = boolValue(r, "forcerm")
 	buildConfig.ForceRemove = boolValue(r, "forcerm")
 	buildConfig.AuthConfig = authConfig
 	buildConfig.AuthConfig = authConfig
 	buildConfig.ConfigFile = configFile
 	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.CpuSetCpus = r.FormValue("cpusetcpus")
 	buildConfig.CpuSetMems = r.FormValue("cpusetmems")
 	buildConfig.CpuSetMems = r.FormValue("cpusetmems")