From 46d333df4b92bb586674f5d042c1bf98c591c28d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 1 Aug 2021 16:11:09 -0400 Subject: [PATCH] feat: implement ps-set-scale trigger --- docs/development/plugin-triggers.md | 15 +++++++++++++++ plugins/app-json/functions.go | 4 ++-- plugins/ps/src/triggers/triggers.go | 5 +++++ plugins/ps/triggers.go | 4 ++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index 1f2c8c6a5..95a552aa1 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -1815,6 +1815,21 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x # TODO ``` +### `ps-set-scale` + +- 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: +- Arguments: `$APP $SKIP_DEPLOY [$PROCESS_TUPLE...]` +- Example: + +```shell +#!/usr/bin/env bash + +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +# TODO +``` + ### `receive-app` - Description: Allows you to customize what occurs when an app is received. Normally just triggers an app build. diff --git a/plugins/app-json/functions.go b/plugins/app-json/functions.go index 6958046a9..fdde679c2 100644 --- a/plugins/app-json/functions.go +++ b/plugins/app-json/functions.go @@ -496,7 +496,7 @@ func setScale(appName string, image string) error { return err } - args := []string{appName} + args := []string{appName, "true"} for processType, formation := range appJSON.Formation { args = append(args, fmt.Sprintf("%s=%d", processType, formation.Quantity)) } @@ -509,7 +509,7 @@ func setScale(appName string, image string) error { return err } - return common.PlugnTrigger("ps-scale-set", args...) + return common.PlugnTrigger("ps-set-scale", args...) } func injectDokkuScale(appName string, image string) error { diff --git a/plugins/ps/src/triggers/triggers.go b/plugins/ps/src/triggers/triggers.go index 161521ea9..e3a365fbd 100644 --- a/plugins/ps/src/triggers/triggers.go +++ b/plugins/ps/src/triggers/triggers.go @@ -75,6 +75,11 @@ func main() { case "procfile-remove": appName := flag.Arg(0) err = ps.TriggerProcfileRemove(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) diff --git a/plugins/ps/triggers.go b/plugins/ps/triggers.go index 4e0fa47ed..5b5d6280b 100644 --- a/plugins/ps/triggers.go +++ b/plugins/ps/triggers.go @@ -282,3 +282,7 @@ func TriggerPsCurrentScale(appName string) error { return nil } + +func TriggerPsSetScale(appName string, skipDeploy bool, processTuples []string) error { + return scaleSet(appName, skipDeploy, processTuples) +}