diff --git a/plugins/ports/functions.go b/plugins/ports/functions.go index 938cba1dee5..59f62e1bb91 100644 --- a/plugins/ports/functions.go +++ b/plugins/ports/functions.go @@ -33,13 +33,19 @@ func clearPorts(appName string) error { // doesCertExist checks if a cert exists for an app func doesCertExist(appName string) bool { - certsExists, _ := common.PlugnTriggerOutputAsString("certs-exists", []string{appName}...) - if certsExists == "true" { + results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "certs-exists", + Args: []string{appName}, + }) + if results.StdoutContents() == "true" { return true } - certsForce, _ := common.PlugnTriggerOutputAsString("certs-force", []string{appName}...) - return certsForce == "true" + results, _ = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "certs-force", + Args: []string{appName}, + }) + return results.StdoutContents() == "true" } // filterAppPortMaps filters the port mappings for an app @@ -156,8 +162,11 @@ func getDetectedPortMaps(appName string) []PortMap { // getGlobalProxyPort gets the global proxy port func getGlobalProxyPort() int { port := 0 - b, _ := common.PlugnTriggerOutput("config-get-global", []string{"DOKKU_PROXY_PORT"}...) - if intVar, err := strconv.Atoi(strings.TrimSpace(string(b[:]))); err == nil { + results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "config-get-global", + Args: []string{"DOKKU_PROXY_PORT"}, + }) + if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil { port = intVar } @@ -167,8 +176,11 @@ func getGlobalProxyPort() int { // getGlobalProxySSLPort gets the global proxy ssl port func getGlobalProxySSLPort() int { port := 0 - b, _ := common.PlugnTriggerOutput("config-get-global", []string{"DOKKU_PROXY_SSL_PORT"}...) - if intVar, err := strconv.Atoi(strings.TrimSpace(string(b[:]))); err == nil { + results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "config-get-global", + Args: []string{"DOKKU_PROXY_SSL_PORT"}, + }) + if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil { port = intVar } @@ -189,8 +201,11 @@ func getPortMaps(appName string) []PortMap { // getProxyPort gets the proxy port for an app func getProxyPort(appName string) int { port := 0 - b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_PROXY_PORT"}...) - if intVar, err := strconv.Atoi(strings.TrimSpace(string(b[:]))); err == nil { + results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "config-get", + Args: []string{appName, "DOKKU_PROXY_PORT"}, + }) + if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil { port = intVar } @@ -200,8 +215,11 @@ func getProxyPort(appName string) int { // getProxySSLPort gets the proxy ssl port for an app func getProxySSLPort(appName string) int { port := 0 - b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_PROXY_SSL_PORT"}...) - if intVar, err := strconv.Atoi(strings.TrimSpace(string(b[:]))); err == nil { + results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "config-get", + Args: []string{appName, "DOKKU_PROXY_SSL_PORT"}, + }) + if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil { port = intVar } diff --git a/plugins/scheduler-docker-local/functions.go b/plugins/scheduler-docker-local/functions.go index 9b9da83a39f..c9ade0be710 100644 --- a/plugins/scheduler-docker-local/functions.go +++ b/plugins/scheduler-docker-local/functions.go @@ -65,8 +65,11 @@ func generateCronEntries() ([]cron.TemplateCommand, error) { g.Go(func() error { commands := []cron.TemplateCommand{} - b, _ := common.PlugnTriggerOutput("cron-entries", "docker-local") - for _, line := range strings.Split(strings.TrimSpace(string(b[:])), "\n") { + response, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "cron-entries", + Args: []string{"docker-local"}, + }) + for _, line := range strings.Split(response.StdoutContents(), "\n") { if strings.TrimSpace(line) == "" { results <- []cron.TemplateCommand{} return nil @@ -121,7 +124,11 @@ func writeCronEntries() error { return deleteCrontab() } - mailto, _ := common.PlugnTriggerOutputAsString("cron-get-property", []string{"--global", "mailto"}...) + results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "cron-get-property", + Args: []string{"--global", "mailto"}, + }) + mailto := results.StdoutContents() data := map[string]interface{}{ "Commands": commands, diff --git a/plugins/scheduler-k3s/functions.go b/plugins/scheduler-k3s/functions.go index aad634c0eef..20eaa75120b 100644 --- a/plugins/scheduler-k3s/functions.go +++ b/plugins/scheduler-k3s/functions.go @@ -473,10 +473,11 @@ func extractStartCommand(input StartCommandInput) string { } if command == "" { - procfileStartCommand, _ := common.PlugnTriggerOutputAsString("procfile-get-command", []string{input.AppName, input.ProcessType, fmt.Sprint(input.Port)}...) - if procfileStartCommand != "" { - command = procfileStartCommand - } + results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "procfile-get-command", + Args: []string{input.AppName, input.ProcessType, fmt.Sprint(input.Port)}, + }) + command = results.StdoutContents() } return command @@ -1238,7 +1239,11 @@ func getProcessResources(appName string, processType string) (ProcessResourcesMa processResources.Limits.CPU = "" } } - nvidiaGpuLimit, err := common.PlugnTriggerOutputAsString("resource-get-property", []string{appName, processType, "limit", "nvidia-gpu"}...) + response, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "resource-get-property", + Args: []string{appName, processType, "limit", "nvidia-gpu"}, + }) + nvidiaGpuLimit := response.StdoutContents() if err == nil && nvidiaGpuLimit != "" && nvidiaGpuLimit != "0" { _, err := resource.ParseQuantity(nvidiaGpuLimit) if err != nil { diff --git a/plugins/scheduler-k3s/portmap.go b/plugins/scheduler-k3s/portmap.go index 6e012d888d7..e25b09337a7 100644 --- a/plugins/scheduler-k3s/portmap.go +++ b/plugins/scheduler-k3s/portmap.go @@ -29,12 +29,15 @@ func getPortMaps(appName string) (map[string]PortMap, error) { portMaps := []PortMap{} allowedMappings := map[string]PortMap{} - output, err := common.PlugnTriggerOutputAsString("ports-get", []string{appName, "json"}...) + results, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "ports-get", + Args: []string{appName, "json"}, + }) if err != nil { return allowedMappings, err } - err = json.Unmarshal([]byte(output), &portMaps) + err = json.Unmarshal([]byte(results.StdoutContents()), &portMaps) if err != nil { return allowedMappings, err } diff --git a/plugins/scheduler-k3s/triggers.go b/plugins/scheduler-k3s/triggers.go index f0d47120cc9..4fd4d4b3e24 100644 --- a/plugins/scheduler-k3s/triggers.go +++ b/plugins/scheduler-k3s/triggers.go @@ -735,10 +735,21 @@ func TriggerSchedulerEnter(scheduler string, appName string, processType string, command := args if len(args) == 0 { command = []string{"/bin/bash"} - if globalShell, err := common.PlugnTriggerOutputAsString("config-get-global", []string{"DOKKU_APP_SHELL"}...); err == nil && globalShell != "" { + results, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "config-get-global", + Args: []string{"DOKKU_APP_SHELL"}, + }) + globalShell := results.StdoutContents() + if err == nil && globalShell != "" { command = []string{globalShell} } - if appShell, err := common.PlugnTriggerOutputAsString("config-get", []string{appName, "DOKKU_APP_SHELL"}...); err == nil && appShell != "" { + + results, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "config-get", + Args: []string{appName, "DOKKU_APP_SHELL"}, + }) + appShell := results.StdoutContents() + if err == nil && appShell != "" { command = []string{appShell} } } @@ -967,10 +978,21 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args [] command := args if len(args) == 0 { command = []string{"/bin/bash"} - if globalShell, err := common.PlugnTriggerOutputAsString("config-get-global", []string{"DOKKU_APP_SHELL"}...); err == nil && globalShell != "" { + results, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "config-get-global", + Args: []string{"DOKKU_APP_SHELL"}, + }) + globalShell := results.StdoutContents() + if err == nil && globalShell != "" { command = []string{globalShell} } - if appShell, err := common.PlugnTriggerOutputAsString("config-get", []string{appName, "DOKKU_APP_SHELL"}...); err == nil && appShell != "" { + + results, err = common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "config-get", + Args: []string{appName, "DOKKU_APP_SHELL"}, + }) + appShell := results.StdoutContents() + if err == nil && appShell != "" { command = []string{appShell} } } else if len(args) == 1 {