feat: implement ps-can-scale

This commit is contained in:
Jose Diaz-Gonzalez
2021-08-01 16:27:13 -04:00
parent 70eb751868
commit bd4621070c
3 changed files with 15 additions and 4 deletions

View File

@@ -16,7 +16,8 @@ import (
)
func canScaleApp(appName string) bool {
return !common.FileExists(getScalefileExtractedPath(appName))
canScale := common.PropertyGetDefault("ps", appName, "can-scale", "true")
return common.ToBool(canScale)
}
func extractProcfile(appName, image string) error {

View File

@@ -75,14 +75,18 @@ func main() {
case "procfile-remove":
appName := flag.Arg(0)
err = ps.TriggerProcfileRemove(appName)
case "ps-can-scale":
appName := flag.Arg(0)
canScale := common.ToBool(flag.Arg(1))
err = ps.TriggerPsCanScale(appName, canScale)
case "ps-current-scale":
appName := flag.Arg(0)
err = ps.TriggerPsCurrentScale(appName)
case "ps-set-scale":
appName := flag.Arg(0)
appName, args := common.ShiftString(flag.Args())
skipDeploy, processTuples := common.ShiftString(args)
err = ps.TriggerPsSetScale(appName, common.ToBool(skipDeploy), processTuples)
case "ps-current-scale":
appName := flag.Arg(0)
err = ps.TriggerPsCurrentScale(appName)
case "report":
appName := flag.Arg(0)
err = ps.ReportSingleApp(appName, "", "")

View File

@@ -6,6 +6,7 @@ import (
"path"
"path/filepath"
"sort"
"strconv"
"strings"
sh "github.com/codeskyblue/go-sh"
@@ -265,6 +266,11 @@ func TriggerProcfileRemove(appName string) error {
return removeProcfile(appName)
}
// TriggerPsCanScale sets whether or not a user can scale an app with ps:scale
func TriggerPsCanScale(appName string, canScale bool) error {
return common.PropertyWrite("ps", appName, "can-scale", strconv.FormatBool(canScale))
}
// TriggerPsCurrentScale prints out the current scale contents (process-type=quantity) delimited by newlines
func TriggerPsCurrentScale(appName string) error {
formations, err := getFormations(appName)