diff --git a/plugins/app-json/functions.go b/plugins/app-json/functions.go index 3d1ef3eab..99527666d 100644 --- a/plugins/app-json/functions.go +++ b/plugins/app-json/functions.go @@ -442,7 +442,11 @@ func createdContainerID(appName string, dockerArgs []string, image string, comma } containerID := result.StdoutContents() - err = common.PlugnTrigger("post-container-create", []string{"app", containerID, appName, phase}...) + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-container-create", + Args: []string{"app", containerID, appName, phase}, + StreamStdio: true, + }) return containerID, err } @@ -462,12 +466,27 @@ func setScale(appName string, image string) error { } if len(args) == 3 { - return common.PlugnTrigger("ps-can-scale", []string{appName, "true"}...) - } - - if err := common.PlugnTrigger("ps-can-scale", []string{appName, "false"}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "ps-can-scale", + Args: []string{appName, "true"}, + StreamStdio: true, + }) return err } - return common.PlugnTrigger("ps-set-scale", args...) + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "ps-can-scale", + Args: []string{appName, "false"}, + StreamStdio: true, + }) + if err != nil { + return err + } + + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "ps-set-scale", + Args: args, + StreamStdio: true, + }) + return err } diff --git a/plugins/apps/functions.go b/plugins/apps/functions.go index 3f9af9559..96a3e04f0 100644 --- a/plugins/apps/functions.go +++ b/plugins/apps/functions.go @@ -38,11 +38,12 @@ func createApp(appName string) error { return err } - if err := common.PlugnTrigger("post-create", []string{appName}...); err != nil { - return err - } - - return nil + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-create", + Args: []string{appName}, + StreamStdio: true, + }) + return err } // destroys an app @@ -56,19 +57,41 @@ func destroyApp(appName string) error { common.LogInfo1(fmt.Sprintf("Destroying %s (including all add-ons)", appName)) imageTag, _ := common.GetRunningImageTag(appName, "") - if err := common.PlugnTrigger("pre-delete", []string{appName, imageTag}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "pre-delete", + Args: []string{appName, imageTag}, + StreamStdio: true, + }) + if err != nil { return err } scheduler := common.GetAppScheduler(appName) removeContainers := "true" - if err := common.PlugnTrigger("scheduler-stop", []string{scheduler, appName, removeContainers}...); err != nil { + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "scheduler-stop", + Args: []string{scheduler, appName, removeContainers}, + StreamStdio: true, + }) + if err != nil { return err } - if err := common.PlugnTrigger("scheduler-post-delete", []string{scheduler, appName, imageTag}...); err != nil { + + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "scheduler-post-delete", + Args: []string{scheduler, appName, imageTag}, + StreamStdio: true, + }) + if err != nil { return err } - if err := common.PlugnTrigger("post-delete", []string{appName, imageTag}...); err != nil { + + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-delete", + Args: []string{appName, imageTag}, + StreamStdio: true, + }) + if err != nil { return err } @@ -76,7 +99,12 @@ func destroyApp(appName string) error { common.DockerCleanup(appName, forceCleanup) common.LogInfo1("Retiring old containers and images") - if err := common.PlugnTrigger("scheduler-retire", []string{scheduler, appName}...); err != nil { + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "scheduler-retire", + Args: []string{scheduler, appName}, + StreamStdio: true, + }) + if err != nil { return err } diff --git a/plugins/apps/subcommands.go b/plugins/apps/subcommands.go index de74cefb3..56e6f7cc4 100644 --- a/plugins/apps/subcommands.go +++ b/plugins/apps/subcommands.go @@ -40,7 +40,12 @@ func CommandClone(oldAppName string, newAppName string, skipDeploy bool, ignoreE return err } - if err := common.PlugnTrigger("post-app-clone-setup", []string{oldAppName, newAppName}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-app-clone-setup", + Args: []string{oldAppName, newAppName}, + StreamStdio: true, + }) + if err != nil { return err } @@ -48,15 +53,21 @@ func CommandClone(oldAppName string, newAppName string, skipDeploy bool, ignoreE os.Setenv("SKIP_REBUILD", "true") } - if err := common.PlugnTrigger("git-has-code", []string{newAppName}...); err != nil { + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "git-has-code", + Args: []string{newAppName}, + StreamStdio: true, + }) + if err != nil { os.Setenv("SKIP_REBUILD", "true") } - if err := common.PlugnTrigger("post-app-clone", []string{oldAppName, newAppName}...); err != nil { - return err - } - - return nil + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-app-clone", + Args: []string{oldAppName, newAppName}, + StreamStdio: true, + }) + return err } // CommandCreate creates app via command line @@ -158,7 +169,12 @@ func CommandRename(oldAppName string, newAppName string, skipDeploy bool) error return err } - if err := common.PlugnTrigger("post-app-rename-setup", []string{oldAppName, newAppName}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-app-rename-setup", + Args: []string{oldAppName, newAppName}, + StreamStdio: true, + }) + if err != nil { return err } @@ -171,15 +187,21 @@ func CommandRename(oldAppName string, newAppName string, skipDeploy bool) error os.Setenv("SKIP_REBUILD", "true") } - if err := common.PlugnTrigger("git-has-code", []string{newAppName}...); err != nil { + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "git-has-code", + Args: []string{newAppName}, + StreamStdio: true, + }) + if err != nil { os.Setenv("SKIP_REBUILD", "true") } - if err := common.PlugnTrigger("post-app-rename", []string{oldAppName, newAppName}...); err != nil { - return err - } - - return nil + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-app-rename", + Args: []string{oldAppName, newAppName}, + StreamStdio: true, + }) + return err } // CommandReport displays an app report for one or more apps diff --git a/plugins/buildpacks/subcommands.go b/plugins/buildpacks/subcommands.go index c52bd9b4c..24d3125ef 100644 --- a/plugins/buildpacks/subcommands.go +++ b/plugins/buildpacks/subcommands.go @@ -149,7 +149,12 @@ func CommandSetProperty(appName string, property string, value string) error { common.CommandPropertySet("buildpacks", appName, property, value, DefaultProperties, GlobalProperties) if property == "stack" && oldStack != value { if appName != "--global" { - return common.PlugnTrigger("post-stack-set", []string{appName, value}...) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-stack-set", + Args: []string{appName, value}, + StreamStdio: true, + }) + return err } apps, err := common.DokkuApps() @@ -157,7 +162,12 @@ func CommandSetProperty(appName string, property string, value string) error { return err } for _, app := range apps { - if err := common.PlugnTrigger("post-stack-set", []string{app, value}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-stack-set", + Args: []string{app, value}, + StreamStdio: true, + }) + if err != nil { return err } } diff --git a/plugins/common/subprocess.go b/plugins/common/subprocess.go index be67da2f1..ce0fda345 100644 --- a/plugins/common/subprocess.go +++ b/plugins/common/subprocess.go @@ -1,60 +1,15 @@ package common import ( - "fmt" - "io" - "os" "path/filepath" "strings" "github.com/codeskyblue/go-sh" ) -// PlugnTrigger fire the given plugn trigger with the given args -// -// Deprecated: use CallPlugnTrigger instead -func PlugnTrigger(triggerName string, args ...string) error { - LogDebug(fmt.Sprintf("plugn trigger %s %v", triggerName, args)) - return PlugnTriggerSetup(triggerName, args...).Run() -} - -// PlugnTriggerOutput fire the given plugn trigger with the given args -// -// Deprecated: use CallPlugnTrigger with CaptureOutput=true instead -func PlugnTriggerOutput(triggerName string, args ...string) ([]byte, error) { - LogDebug(fmt.Sprintf("plugn trigger %s %v", triggerName, args)) - rE, wE, _ := os.Pipe() - rO, wO, _ := os.Pipe() - session := PlugnTriggerSetup(triggerName, args...) - session.Stderr = wE - session.Stdout = wO - err := session.Run() - wE.Close() - wO.Close() - - readStderr, _ := io.ReadAll(rE) - readStdout, _ := io.ReadAll(rO) - - stderr := string(readStderr[:]) - if err != nil { - err = fmt.Errorf(stderr) - } - - if os.Getenv("DOKKU_TRACE") == "1" { - for _, line := range strings.Split(stderr, "\n") { - LogDebug(fmt.Sprintf("plugn trigger %s stderr: %s", triggerName, line)) - } - for _, line := range strings.Split(string(readStdout[:]), "\n") { - LogDebug(fmt.Sprintf("plugn trigger %s stdout: %s", triggerName, line)) - } - } - - return readStdout, err -} - // PlugnTriggerSetup sets up a plugn trigger call // -// Deprecated: use CallPlugnTrigger instead +// Deprecated: use CallPlugnTrigger with Stdin instead func PlugnTriggerSetup(triggerName string, args ...string) *sh.Session { shellArgs := make([]interface{}, len(args)+2) shellArgs[0] = "trigger" diff --git a/plugins/config/config.go b/plugins/config/config.go index 3bfbf59d6..90f04039d 100644 --- a/plugins/config/config.go +++ b/plugins/config/config.go @@ -129,14 +129,24 @@ func UnsetAll(appName string, restart bool) (err error) { func triggerRestart(appName string) { common.LogInfo1(fmt.Sprintf("Restarting app %s", appName)) - if err := common.PlugnTrigger("release-and-deploy", appName); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "release-and-deploy", + Args: []string{appName}, + StreamStdio: true, + }) + if err != nil { common.LogWarn(fmt.Sprintf("Failure while restarting app: %s", err)) } } func triggerUpdate(appName string, operation string, args []string) { args = append([]string{appName, operation}, args...) - if err := common.PlugnTrigger("post-config-update", args...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-config-update", + Args: args, + StreamStdio: true, + }) + if err != nil { common.LogWarn(fmt.Sprintf("Failure while triggering post-config-update: %s", err)) } } diff --git a/plugins/cron/subcommands.go b/plugins/cron/subcommands.go index 4a85a01e3..981f1deab 100644 --- a/plugins/cron/subcommands.go +++ b/plugins/cron/subcommands.go @@ -110,7 +110,12 @@ func CommandRun(appName string, cronID string, detached bool) error { os.Setenv("DOKKU_RM_CONTAINER", "1") scheduler := common.GetAppScheduler(appName) args := append([]string{scheduler, appName, "0", "--"}, fields...) - return common.PlugnTrigger("scheduler-run", args...) + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "scheduler-run", + Args: args, + StreamStdio: true, + }) + return err } // CommandSet set or clear a cron property for an app @@ -120,5 +125,9 @@ func CommandSet(appName string, property string, value string) error { } common.CommandPropertySet("cron", appName, property, value, DefaultProperties, GlobalProperties) - return common.PlugnTrigger("cron-write") + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "cron-write", + StreamStdio: true, + }) + return err } diff --git a/plugins/logs/logs.go b/plugins/logs/logs.go index d0122957e..6d24d8755 100644 --- a/plugins/logs/logs.go +++ b/plugins/logs/logs.go @@ -40,9 +40,11 @@ var templates embed.FS // GetFailedLogs outputs failed deploy logs for a given app func GetFailedLogs(appName string) error { common.LogInfo2Quiet(fmt.Sprintf("%s failed deploy logs", appName)) - s := common.GetAppScheduler(appName) - if err := common.PlugnTrigger("scheduler-logs-failed", s, appName); err != nil { - return err - } - return nil + scheduler := common.GetAppScheduler(appName) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "scheduler-logs-failed", + Args: []string{scheduler, appName}, + StreamStdio: true, + }) + return err } diff --git a/plugins/network/triggers.go b/plugins/network/triggers.go index 3f5bd99ff..6ad20bd0c 100644 --- a/plugins/network/triggers.go +++ b/plugins/network/triggers.go @@ -40,7 +40,12 @@ func TriggerInstall() error { if common.PropertyExists("network", appName, "bind-all-interfaces") { continue } - if err := common.PlugnTrigger("proxy-is-enabled", []string{appName}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "proxy-is-enabled", + Args: []string{appName}, + StreamStdio: true, + }) + if err != nil { common.LogVerboseQuiet("Setting network property 'bind-all-interfaces' to false") if err := common.PropertyWrite("network", appName, "bind-all-interfaces", "false"); err != nil { common.LogWarn(err.Error()) diff --git a/plugins/ports/functions.go b/plugins/ports/functions.go index 59f62e1bb..29ca80b0d 100644 --- a/plugins/ports/functions.go +++ b/plugins/ports/functions.go @@ -286,10 +286,12 @@ func inRange(value int, min int, max int) bool { // isAppVhostEnabled checks if the app vhost is enabled func isAppVhostEnabled(appName string) bool { - if err := common.PlugnTrigger("domains-vhost-enabled", []string{appName}...); err != nil { - return false - } - return true + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "domains-vhost-enabled", + Args: []string{appName}, + StreamStdio: true, + }) + return err == nil } // listAppPortMaps lists the port mappings for an app diff --git a/plugins/ports/subcommands.go b/plugins/ports/subcommands.go index 51f9564f8..6f4f3793f 100644 --- a/plugins/ports/subcommands.go +++ b/plugins/ports/subcommands.go @@ -46,7 +46,12 @@ func CommandAdd(appName string, portMapStrings []string) error { return err } - return common.PlugnTrigger("post-proxy-ports-update", []string{appName, "add"}...) + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-proxy-ports-update", + Args: []string{appName, "add"}, + StreamStdio: true, + }) + return err } // CommandClear clears all port mappings for an app @@ -59,7 +64,12 @@ func CommandClear(appName string) error { return err } - return common.PlugnTrigger("post-proxy-ports-update", []string{appName, "clear"}...) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-proxy-ports-update", + Args: []string{appName, "clear"}, + StreamStdio: true, + }) + return err } // CommandRemove removes specific port mappings from an app @@ -81,7 +91,12 @@ func CommandRemove(appName string, portMapStrings []string) error { return err } - return common.PlugnTrigger("post-proxy-ports-update", []string{appName, "remove"}...) + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-proxy-ports-update", + Args: []string{appName, "remove"}, + StreamStdio: true, + }) + return err } // CommandSet sets port mappings for an app @@ -107,7 +122,12 @@ func CommandSet(appName string, portMapStrings []string) error { return err } - return common.PlugnTrigger("post-proxy-ports-update", []string{appName, "set"}...) + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-proxy-ports-update", + Args: []string{appName, "set"}, + StreamStdio: true, + }) + return err } // CommandReport displays a ports report for one or more apps diff --git a/plugins/proxy/proxy.go b/plugins/proxy/proxy.go index 26cfee2ff..57a7bfba6 100644 --- a/plugins/proxy/proxy.go +++ b/plugins/proxy/proxy.go @@ -11,12 +11,22 @@ const RunInSerial = 0 // BuildConfig rebuilds the proxy config for the specified app func BuildConfig(appName string) error { - return common.PlugnTrigger("proxy-build-config", []string{appName}...) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "proxy-build-config", + Args: []string{appName}, + StreamStdio: true, + }) + return err } // ClearConfig clears the proxy config for the specified app func ClearConfig(appName string) error { - return common.PlugnTrigger("proxy-clear-config", []string{appName}...) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "proxy-clear-config", + Args: []string{appName}, + StreamStdio: true, + }) + return err } // Disable disables proxy implementations for the specified app @@ -35,7 +45,12 @@ func Disable(appName string) error { return err } - return common.PlugnTrigger("proxy-disable", []string{appName}...) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "proxy-disable", + Args: []string{appName}, + StreamStdio: true, + }) + return err } // Enable enables proxy implementations for the specified app @@ -50,8 +65,12 @@ func Enable(appName string) error { if err := config.UnsetMany(appName, keys, false); err != nil { return err } - - return common.PlugnTrigger("proxy-enable", []string{appName}...) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "proxy-enable", + Args: []string{appName}, + StreamStdio: true, + }) + return err } // IsAppProxyEnabled returns true if proxy is enabled; otherwise return false diff --git a/plugins/ps/functions.go b/plugins/ps/functions.go index de6d9aa86..3bb7f1235 100644 --- a/plugins/ps/functions.go +++ b/plugins/ps/functions.go @@ -210,7 +210,12 @@ func getFormations(appName string) (FormationSlice, error) { } func restorePrep() error { - if err := common.PlugnTrigger("proxy-clear-config", []string{"--all"}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "proxy-clear-config", + Args: []string{"--all"}, + StreamStdio: true, + }) + if err != nil { return fmt.Errorf("Error clearing proxy config: %s", err) } @@ -266,7 +271,12 @@ func scaleSet(appName string, skipDeploy bool, clearExisting bool, processTuples } for _, formation := range formations { - if err := common.PlugnTrigger("deploy", []string{appName, imageTag, formation.ProcessType}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "deploy", + Args: []string{appName, imageTag, formation.ProcessType}, + StreamStdio: true, + }) + if err != nil { return err } } diff --git a/plugins/ps/ps.go b/plugins/ps/ps.go index a0b937e83..7e1e2f4d9 100644 --- a/plugins/ps/ps.go +++ b/plugins/ps/ps.go @@ -68,7 +68,12 @@ func (d FormationSlice) Less(i, j int) bool { // Rebuild rebuilds app from base image func Rebuild(appName string) error { - return common.PlugnTrigger("receive-app", []string{appName}...) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "receive-app", + Args: []string{appName}, + StreamStdio: true, + }) + return err } // Restart restarts the app @@ -85,10 +90,20 @@ func Restart(appName string) error { if imageTag == "" { common.LogWarn("No deployed-image-tag property saved, falling back to full release-and-deploy") - return common.PlugnTrigger("release-and-deploy", []string{appName}...) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "release-and-deploy", + Args: []string{appName}, + StreamStdio: true, + }) + return err } - return common.PlugnTrigger("deploy", []string{appName, imageTag}...) + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "deploy", + Args: []string{appName, imageTag}, + StreamStdio: true, + }) + return err } // RestartProcess restarts a process type within an app @@ -105,21 +120,41 @@ func RestartProcess(appName string, processName string) error { if imageTag == "" { common.LogWarn("No deployed-image-tag property saved, falling back to full release-and-deploy") - return common.PlugnTrigger("release-and-deploy", []string{appName}...) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "release-and-deploy", + Args: []string{appName}, + StreamStdio: true, + }) + return err } - return common.PlugnTrigger("deploy", []string{appName, imageTag, processName}...) + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "deploy", + Args: []string{appName, imageTag, processName}, + StreamStdio: true, + }) + return err } // Restore ensures an app that should be running is running on boot func Restore(appName string) error { scheduler := common.GetAppScheduler(appName) - if err := common.PlugnTrigger("scheduler-pre-restore", []string{scheduler, appName}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "scheduler-pre-restore", + Args: []string{scheduler, appName}, + StreamStdio: true, + }) + if err != nil { return fmt.Errorf("Error running scheduler-pre-restore: %s", err) } common.LogInfo1("Clearing potentially invalid proxy configuration") - if err := common.PlugnTrigger("proxy-clear-config", []string{appName}...); err != nil { + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "proxy-clear-config", + Args: []string{appName}, + StreamStdio: true, + }) + if err != nil { common.LogWarn(fmt.Sprintf("Error clearing proxy config: %s", err)) } @@ -151,7 +186,12 @@ func Start(appName string) error { return nil } - if err := common.PlugnTrigger("pre-start", []string{appName}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "pre-start", + Args: []string{appName}, + StreamStdio: true, + }) + if err != nil { return fmt.Errorf("Failure in pre-start hook: %s", err) } @@ -164,18 +204,24 @@ func Start(appName string) error { } if runningState != "true" { - if err := common.PlugnTrigger("release-and-deploy", []string{appName, imageTag}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "release-and-deploy", + Args: []string{appName, imageTag}, + StreamStdio: true, + }) + if err != nil { return err } } else { common.LogWarn(fmt.Sprintf("App %s already running", appName)) } - if err := common.PlugnTrigger("proxy-build-config", []string{appName}...); err != nil { - return err - } - - return nil + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "proxy-build-config", + Args: []string{appName}, + StreamStdio: true, + }) + return err } // Stop stops the app @@ -188,13 +234,19 @@ func Stop(appName string) error { common.LogInfo1Quiet(fmt.Sprintf("Stopping %s", appName)) scheduler := common.GetAppScheduler(appName) - if err := common.PlugnTrigger("scheduler-stop", []string{scheduler, appName}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "scheduler-stop", + Args: []string{scheduler, appName}, + StreamStdio: true, + }) + if err != nil { return err } - if err := common.PlugnTrigger("post-stop", []string{appName}...); err != nil { - return err - } - - return nil + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "post-stop", + Args: []string{appName}, + StreamStdio: true, + }) + return err } diff --git a/plugins/ps/subcommands.go b/plugins/ps/subcommands.go index f818d8140..2d5302403 100644 --- a/plugins/ps/subcommands.go +++ b/plugins/ps/subcommands.go @@ -18,7 +18,12 @@ func CommandInspect(appName string) error { } scheduler := common.GetAppScheduler(appName) - return common.PlugnTrigger("scheduler-inspect", []string{scheduler, appName}...) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "scheduler-inspect", + Args: []string{scheduler, appName}, + StreamStdio: true, + }) + return err } // CommandRebuild rebuilds an app from source @@ -74,7 +79,11 @@ func CommandRestart(appName string, processName string, allApps bool, parallelCo // CommandRestore starts previously running apps e.g. after reboot func CommandRestore(appName string, allApps bool, parallelCount int) error { - if err := common.PlugnTrigger("pre-restore", []string{}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "pre-restore", + StreamStdio: true, + }) + if err != nil { return fmt.Errorf("Error running pre-restore: %s", err) } @@ -124,7 +133,12 @@ func CommandRetire(appName string) error { } common.LogInfo1("Retiring old containers and images") - return common.PlugnTrigger("scheduler-retire", []string{scheduler, appName}...) + _, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "scheduler-retire", + Args: []string{scheduler, appName}, + StreamStdio: true, + }) + return err } // CommandScale gets or sets how many instances of a given process to run diff --git a/plugins/registry/triggers.go b/plugins/registry/triggers.go index fa8cb5f07..5579a8b74 100644 --- a/plugins/registry/triggers.go +++ b/plugins/registry/triggers.go @@ -90,7 +90,12 @@ func TriggerPostDelete(appName string) error { func TriggerPostReleaseBuilder(appName string, image string) error { parts := strings.Split(image, ":") imageTag := parts[len(parts)-1] - if err := common.PlugnTrigger("pre-deploy", []string{appName, imageTag}...); err != nil { + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "pre-deploy", + Args: []string{appName, imageTag}, + StreamStdio: true, + }) + if err != nil { return err } diff --git a/plugins/scheduler-k3s/triggers.go b/plugins/scheduler-k3s/triggers.go index 4ea74b512..86a5cb6c6 100644 --- a/plugins/scheduler-k3s/triggers.go +++ b/plugins/scheduler-k3s/triggers.go @@ -227,7 +227,11 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e domains := []string{} if _, ok := processes["web"]; ok { - err = common.PlugnTrigger("domains-vhost-enabled", []string{appName}...) + _, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "domains-vhost-enabled", + Args: []string{appName}, + StreamStdio: true, + }) if err == nil { results, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ Trigger: "domains-list",