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:
Jose Diaz-Gonzalez
2022-02-25 22:20:59 -05:00
parent 2a11723496
commit 068b3c9adb
4 changed files with 33 additions and 2 deletions

View File

@@ -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" {

View File

@@ -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)
}