refactor: use CallPlugnTrigger instead of PlugnTriggerOutput

Refs #6422
This commit is contained in:
Jose Diaz-Gonzalez
2024-03-14 01:18:28 -04:00
parent a9933c7f02
commit cdff4ae867
15 changed files with 149 additions and 58 deletions

View File

@@ -69,15 +69,21 @@ func getRestartPolicy(appName string) (string, error) {
func getProcessCount(appName string) (int, error) {
scheduler := common.GetAppScheduler(appName)
b, _ := common.PlugnTriggerOutput("scheduler-app-status", []string{scheduler, appName}...)
count := strings.Split(strings.TrimSpace(string(b[:])), " ")[0]
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
Trigger: "scheduler-app-status",
Args: []string{scheduler, appName},
})
count := strings.Split(results.StdoutContents(), " ")[0]
return strconv.Atoi(count)
}
func getRunningState(appName string) string {
scheduler := common.GetAppScheduler(appName)
b, _ := common.PlugnTriggerOutput("scheduler-app-status", []string{scheduler, appName}...)
return strings.Split(strings.TrimSpace(string(b[:])), " ")[1]
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
Trigger: "scheduler-app-status",
Args: []string{scheduler, appName},
})
return strings.Split(results.StdoutContents(), " ")[1]
}
func hasProcfile(appName string) bool {

View File

@@ -2,7 +2,6 @@ package ps
import (
"fmt"
"strings"
"github.com/dokku/dokku/plugins/common"
)
@@ -129,8 +128,11 @@ func Restore(appName string) error {
return nil
}
b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_APP_RESTORE"}...)
restore := strings.TrimSpace(string(b[:]))
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
Trigger: "config-get",
Args: []string{appName, "DOKKU_APP_RESTORE"},
})
restore := results.StdoutContents()
if restore == "0" {
common.LogWarn(fmt.Sprintf("Skipping ps:restore for %s as DOKKU_APP_RESTORE=%s", appName, restore))
return nil

View File

@@ -129,8 +129,11 @@ func reportRestartPolicy(appName string) string {
}
func reportRestore(appName string) string {
b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_APP_RESTORE"}...)
restore := strings.TrimSpace(string(b[:]))
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
Trigger: "config-get",
Args: []string{appName, "DOKKU_APP_RESTORE"},
})
restore := results.StdoutContents()
if restore == "0" {
restore = "false"
} else {

View File

@@ -72,8 +72,11 @@ func TriggerCorePostExtract(appName string, sourceWorkDir string) error {
}
processSpecificProcfile := fmt.Sprintf("%s.%s", existingProcfile, os.Getenv("DOKKU_PID"))
b, _ := common.PlugnTriggerOutput("git-get-property", []string{appName, "source-image"}...)
appSourceImage := strings.TrimSpace(string(b[:]))
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
Trigger: "git-get-property",
Args: []string{appName, "source-image"},
})
appSourceImage := results.StdoutContents()
repoDefaultProcfilePath := path.Join(sourceWorkDir, "Procfile")
if appSourceImage == "" {