refactor: allow specifying clearExisting when calling ps-set-scale

This commit is contained in:
Jose Diaz-Gonzalez
2021-08-01 17:53:57 -04:00
parent 7502cbd13d
commit a7593db0c3
4 changed files with 8 additions and 5 deletions

View File

@@ -1833,7 +1833,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
- Description: Sets the scale for an app based on a specified formation (process-type=quantity). Any unspecified process types will be left as is. - Description: Sets the scale for an app based on a specified formation (process-type=quantity). Any unspecified process types will be left as is.
- Invoked by: - Invoked by:
- Arguments: `$APP $SKIP_DEPLOY [$PROCESS_TUPLE...]` - Arguments: `$APP $SKIP_DEPLOY $CLEAR_EXISTING [$PROCESS_TUPLE...]`
- Example: - Example:
```shell ```shell

View File

@@ -496,7 +496,9 @@ func setScale(appName string, image string) error {
return err return err
} }
args := []string{appName, "true"} skipDeploy := true
clearExisting := false
args := []string{appName, strconv.FormatBool(skipDeploy), strconv.FormatBool(clearExisting)}
for processType, formation := range appJSON.Formation { for processType, formation := range appJSON.Formation {
args = append(args, fmt.Sprintf("%s=%d", processType, formation.Quantity)) args = append(args, fmt.Sprintf("%s=%d", processType, formation.Quantity))
} }

View File

@@ -86,7 +86,8 @@ func main() {
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) clearExisting, processTuples := common.ShiftString(args)
err = ps.TriggerPsSetScale(appName, common.ToBool(skipDeploy), common.ToBool(clearExisting), processTuples)
case "report": case "report":
appName := flag.Arg(0) appName := flag.Arg(0)
err = ps.ReportSingleApp(appName, "", "") err = ps.ReportSingleApp(appName, "", "")

View File

@@ -315,6 +315,6 @@ func TriggerPsCurrentScale(appName string) error {
} }
// TriggerPsSetScale configures the scale parameters for a given app // TriggerPsSetScale configures the scale parameters for a given app
func TriggerPsSetScale(appName string, skipDeploy bool, processTuples []string) error { func TriggerPsSetScale(appName string, skipDeploy bool, clearExisting bool, processTuples []string) error {
return scaleSet(appName, skipDeploy, true, processTuples) return scaleSet(appName, skipDeploy, clearExisting, processTuples)
} }