mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Rename int64Value to int64ValueOrZero.
Signed-off-by: Adria Casas <adriacasas88@gmail.com>
This commit is contained in:
parent
91fb4d672a
commit
a2c76912e0
3 changed files with 7 additions and 7 deletions
|
@ -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")
|
||||
|
||||
|
|
Loading…
Reference in a new issue