Signed-off-by: Adria Casas <adriacasas88@gmail.com>
| ... | ... |
@@ -11,7 +11,7 @@ func boolValue(r *http.Request, k string) bool {
|
| 11 | 11 |
return !(s == "" || s == "0" || s == "no" || s == "false" || s == "none") |
| 12 | 12 |
} |
| 13 | 13 |
|
| 14 |
-func int64Value(r *http.Request, k string) int64 {
|
|
| 14 |
+func int64ValueOrZero(r *http.Request, k string) int64 {
|
|
| 15 | 15 |
val, err := strconv.ParseInt(r.FormValue(k), 10, 64) |
| 16 | 16 |
if err != nil {
|
| 17 | 17 |
return 0 |
| ... | ... |
@@ -33,7 +33,7 @@ func TestBoolValue(t *testing.T) {
|
| 33 | 33 |
} |
| 34 | 34 |
} |
| 35 | 35 |
|
| 36 |
-func TestInt64Value(t *testing.T) {
|
|
| 36 |
+func TestInt64ValueOrZero(t *testing.T) {
|
|
| 37 | 37 |
cases := map[string]int64{
|
| 38 | 38 |
"": 0, |
| 39 | 39 |
"asdf": 0, |
| ... | ... |
@@ -47,7 +47,7 @@ func TestInt64Value(t *testing.T) {
|
| 47 | 47 |
r, _ := http.NewRequest("POST", "", nil)
|
| 48 | 48 |
r.Form = v |
| 49 | 49 |
|
| 50 |
- a := int64Value(r, "test") |
|
| 50 |
+ a := int64ValueOrZero(r, "test") |
|
| 51 | 51 |
if a != e {
|
| 52 | 52 |
t.Fatalf("Value: %s, expected: %v, actual: %v", c, e, a)
|
| 53 | 53 |
} |
| ... | ... |
@@ -1295,10 +1295,10 @@ func (s *Server) postBuild(version version.Version, w http.ResponseWriter, r *ht |
| 1295 | 1295 |
buildConfig.ForceRemove = boolValue(r, "forcerm") |
| 1296 | 1296 |
buildConfig.AuthConfig = authConfig |
| 1297 | 1297 |
buildConfig.ConfigFile = configFile |
| 1298 |
- buildConfig.MemorySwap = int64Value(r, "memswap") |
|
| 1299 |
- buildConfig.Memory = int64Value(r, "memory") |
|
| 1300 |
- buildConfig.CpuShares = int64Value(r, "cpushares") |
|
| 1301 |
- buildConfig.CpuQuota = int64Value(r, "cpuquota") |
|
| 1298 |
+ buildConfig.MemorySwap = int64ValueOrZero(r, "memswap") |
|
| 1299 |
+ buildConfig.Memory = int64ValueOrZero(r, "memory") |
|
| 1300 |
+ buildConfig.CpuShares = int64ValueOrZero(r, "cpushares") |
|
| 1301 |
+ buildConfig.CpuQuota = int64ValueOrZero(r, "cpuquota") |
|
| 1302 | 1302 |
buildConfig.CpuSetCpus = r.FormValue("cpusetcpus")
|
| 1303 | 1303 |
buildConfig.CpuSetMems = r.FormValue("cpusetmems")
|
| 1304 | 1304 |
|