mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
cmd: Fix disk "size" handling
commit bdf9b1f31a
introduced a bug with disk size handling
where GB was not handled correctly. Fix it.
Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
b3bb4d02e6
commit
ce8de92978
@ -109,16 +109,17 @@ func getDiskSizeMB(s string) (int, error) {
|
|||||||
}
|
}
|
||||||
sz := len(s)
|
sz := len(s)
|
||||||
if strings.HasSuffix(s, "M") {
|
if strings.HasSuffix(s, "M") {
|
||||||
i, err := strconv.Atoi(s[:sz-1])
|
return strconv.Atoi(s[:sz-1])
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return i, nil
|
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(s, "G") {
|
if strings.HasSuffix(s, "G") {
|
||||||
s = s[:sz-1]
|
s = s[:sz-1]
|
||||||
}
|
}
|
||||||
return strconv.Atoi(s)
|
|
||||||
|
i, err := strconv.Atoi(s)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return 1024 * i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskConfig is the config for a disk
|
// DiskConfig is the config for a disk
|
||||||
|
Loading…
Reference in New Issue
Block a user