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 { 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 { func extractProcfile(appName, image string) error {

View File

@@ -75,14 +75,18 @@ func main() {
case "procfile-remove": case "procfile-remove":
appName := flag.Arg(0) appName := flag.Arg(0)
err = ps.TriggerProcfileRemove(appName) 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": case "ps-set-scale":
appName := flag.Arg(0) appName := flag.Arg(0)
appName, args := common.ShiftString(flag.Args()) appName, args := common.ShiftString(flag.Args())
skipDeploy, processTuples := common.ShiftString(args) skipDeploy, processTuples := common.ShiftString(args)
err = ps.TriggerPsSetScale(appName, common.ToBool(skipDeploy), processTuples) err = ps.TriggerPsSetScale(appName, common.ToBool(skipDeploy), processTuples)
case "ps-current-scale":
appName := flag.Arg(0)
err = ps.TriggerPsCurrentScale(appName)
case "report": case "report":
appName := flag.Arg(0) appName := flag.Arg(0)
err = ps.ReportSingleApp(appName, "", "") err = ps.ReportSingleApp(appName, "", "")

View File

@@ -6,6 +6,7 @@ import (
"path" "path"
"path/filepath" "path/filepath"
"sort" "sort"
"strconv"
"strings" "strings"
sh "github.com/codeskyblue/go-sh" sh "github.com/codeskyblue/go-sh"
@@ -265,6 +266,11 @@ func TriggerProcfileRemove(appName string) error {
return removeProcfile(appName) 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 // TriggerPsCurrentScale prints out the current scale contents (process-type=quantity) delimited by newlines
func TriggerPsCurrentScale(appName string) error { func TriggerPsCurrentScale(appName string) error {
formations, err := getFormations(appName) formations, err := getFormations(appName)