mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
feat: set the default memory unit type to megabytes
This makes it easier to support all schedulers out of the box - all other schedulers assume megabytes when no unit is specified.
This commit is contained in:
@@ -2,10 +2,27 @@ package resource
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
func addMemorySuffixForDocker(key string, value string) string {
|
||||
if key == "memory" {
|
||||
hasSuffix := false
|
||||
suffixes := []string{"b", "k", "m", "g"}
|
||||
for _, suffix := range suffixes {
|
||||
if strings.HasSuffix(value, suffix) {
|
||||
hasSuffix = true
|
||||
}
|
||||
}
|
||||
if !hasSuffix {
|
||||
value = value + "m"
|
||||
}
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func clearByResourceType(appName string, processType string, resourceType string) {
|
||||
noun := "limits"
|
||||
if resourceType == "reserve" {
|
||||
|
||||
@@ -75,6 +75,7 @@ func TriggerDockerArgsProcessDeploy(appName string, processType string) error {
|
||||
if value == "" {
|
||||
continue
|
||||
}
|
||||
value = addMemorySuffixForDocker(key, value)
|
||||
fmt.Printf(" --%s=%s ", key, value)
|
||||
}
|
||||
|
||||
@@ -82,6 +83,7 @@ func TriggerDockerArgsProcessDeploy(appName string, processType string) error {
|
||||
if value == "" {
|
||||
continue
|
||||
}
|
||||
value = addMemorySuffixForDocker(key, value)
|
||||
fmt.Printf(" --%s-reservation=%s ", key, value)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user