Merge pull request #6711 from dokku/6422-remove-plugin-trigger-output-as-string
Use CallPlugnTrigger instead of PlugnTriggerOutputAsString
This commit is contained in:
5 files changed
+81
-26
No files matched your search
+30
-12
@@ -33,13 +33,19 @@ func clearPorts(appName string) error {
|
|||||||
|
|
||||||
// doesCertExist checks if a cert exists for an app
|
// doesCertExist checks if a cert exists for an app
|
||||||
func doesCertExist(appName string) bool {
|
func doesCertExist(appName string) bool {
|
||||||
certsExists, _ := common.PlugnTriggerOutputAsString("certs-exists", []string{appName}...)
|
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||||
if certsExists == "true" {
|
Trigger: "certs-exists",
|
||||||
|
Args: []string{appName},
|
||||||
|
})
|
||||||
|
if results.StdoutContents() == "true" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
certsForce, _ := common.PlugnTriggerOutputAsString("certs-force", []string{appName}...)
|
results, _ = common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||||
return certsForce == "true"
|
Trigger: "certs-force",
|
||||||
|
Args: []string{appName},
|
||||||
|
})
|
||||||
|
return results.StdoutContents() == "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
// filterAppPortMaps filters the port mappings for an app
|
// filterAppPortMaps filters the port mappings for an app
|
||||||
@@ -156,8 +162,11 @@ func getDetectedPortMaps(appName string) []PortMap {
|
|||||||
// getGlobalProxyPort gets the global proxy port
|
// getGlobalProxyPort gets the global proxy port
|
||||||
func getGlobalProxyPort() int {
|
func getGlobalProxyPort() int {
|
||||||
port := 0
|
port := 0
|
||||||
b, _ := common.PlugnTriggerOutput("config-get-global", []string{"DOKKU_PROXY_PORT"}...)
|
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||||
if intVar, err := strconv.Atoi(strings.TrimSpace(string(b[:]))); err == nil {
|
Trigger: "config-get-global",
|
||||||
|
Args: []string{"DOKKU_PROXY_PORT"},
|
||||||
|
})
|
||||||
|
if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil {
|
||||||
port = intVar
|
port = intVar
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,8 +176,11 @@ func getGlobalProxyPort() int {
|
|||||||
// getGlobalProxySSLPort gets the global proxy ssl port
|
// getGlobalProxySSLPort gets the global proxy ssl port
|
||||||
func getGlobalProxySSLPort() int {
|
func getGlobalProxySSLPort() int {
|
||||||
port := 0
|
port := 0
|
||||||
b, _ := common.PlugnTriggerOutput("config-get-global", []string{"DOKKU_PROXY_SSL_PORT"}...)
|
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||||
if intVar, err := strconv.Atoi(strings.TrimSpace(string(b[:]))); err == nil {
|
Trigger: "config-get-global",
|
||||||
|
Args: []string{"DOKKU_PROXY_SSL_PORT"},
|
||||||
|
})
|
||||||
|
if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil {
|
||||||
port = intVar
|
port = intVar
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,8 +201,11 @@ func getPortMaps(appName string) []PortMap {
|
|||||||
// getProxyPort gets the proxy port for an app
|
// getProxyPort gets the proxy port for an app
|
||||||
func getProxyPort(appName string) int {
|
func getProxyPort(appName string) int {
|
||||||
port := 0
|
port := 0
|
||||||
b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_PROXY_PORT"}...)
|
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||||
if intVar, err := strconv.Atoi(strings.TrimSpace(string(b[:]))); err == nil {
|
Trigger: "config-get",
|
||||||
|
Args: []string{appName, "DOKKU_PROXY_PORT"},
|
||||||
|
})
|
||||||
|
if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil {
|
||||||
port = intVar
|
port = intVar
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,8 +215,11 @@ func getProxyPort(appName string) int {
|
|||||||
// getProxySSLPort gets the proxy ssl port for an app
|
// getProxySSLPort gets the proxy ssl port for an app
|
||||||
func getProxySSLPort(appName string) int {
|
func getProxySSLPort(appName string) int {
|
||||||
port := 0
|
port := 0
|
||||||
b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_PROXY_SSL_PORT"}...)
|
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||||
if intVar, err := strconv.Atoi(strings.TrimSpace(string(b[:]))); err == nil {
|
Trigger: "config-get",
|
||||||
|
Args: []string{appName, "DOKKU_PROXY_SSL_PORT"},
|
||||||
|
})
|
||||||
|
if intVar, err := strconv.Atoi(results.StdoutContents()); err == nil {
|
||||||
port = intVar
|
port = intVar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,8 +65,11 @@ func generateCronEntries() ([]cron.TemplateCommand, error) {
|
|||||||
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
commands := []cron.TemplateCommand{}
|
commands := []cron.TemplateCommand{}
|
||||||
b, _ := common.PlugnTriggerOutput("cron-entries", "docker-local")
|
response, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||||
for _, line := range strings.Split(strings.TrimSpace(string(b[:])), "\n") {
|
Trigger: "cron-entries",
|
||||||
|
Args: []string{"docker-local"},
|
||||||
|
})
|
||||||
|
for _, line := range strings.Split(response.StdoutContents(), "\n") {
|
||||||
if strings.TrimSpace(line) == "" {
|
if strings.TrimSpace(line) == "" {
|
||||||
results <- []cron.TemplateCommand{}
|
results <- []cron.TemplateCommand{}
|
||||||
return nil
|
return nil
|
||||||
@@ -121,7 +124,11 @@ func writeCronEntries() error {
|
|||||||
return deleteCrontab()
|
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{}{
|
data := map[string]interface{}{
|
||||||
"Commands": commands,
|
"Commands": commands,
|
||||||
|
|||||||
@@ -473,10 +473,11 @@ func extractStartCommand(input StartCommandInput) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if command == "" {
|
if command == "" {
|
||||||
procfileStartCommand, _ := common.PlugnTriggerOutputAsString("procfile-get-command", []string{input.AppName, input.ProcessType, fmt.Sprint(input.Port)}...)
|
results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{
|
||||||
if procfileStartCommand != "" {
|
Trigger: "procfile-get-command",
|
||||||
command = procfileStartCommand
|
Args: []string{input.AppName, input.ProcessType, fmt.Sprint(input.Port)},
|
||||||
}
|
})
|
||||||
|
command = results.StdoutContents()
|
||||||
}
|
}
|
||||||
|
|
||||||
return command
|
return command
|
||||||
@@ -1238,7 +1239,11 @@ func getProcessResources(appName string, processType string) (ProcessResourcesMa
|
|||||||
processResources.Limits.CPU = ""
|
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" {
|
if err == nil && nvidiaGpuLimit != "" && nvidiaGpuLimit != "0" {
|
||||||
_, err := resource.ParseQuantity(nvidiaGpuLimit)
|
_, err := resource.ParseQuantity(nvidiaGpuLimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -29,12 +29,15 @@ func getPortMaps(appName string) (map[string]PortMap, error) {
|
|||||||
portMaps := []PortMap{}
|
portMaps := []PortMap{}
|
||||||
|
|
||||||
allowedMappings := map[string]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 {
|
if err != nil {
|
||||||
return allowedMappings, err
|
return allowedMappings, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(output), &portMaps)
|
err = json.Unmarshal([]byte(results.StdoutContents()), &portMaps)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return allowedMappings, err
|
return allowedMappings, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -735,10 +735,21 @@ func TriggerSchedulerEnter(scheduler string, appName string, processType string,
|
|||||||
command := args
|
command := args
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
command = []string{"/bin/bash"}
|
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}
|
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}
|
command = []string{appShell}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -967,10 +978,21 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args []
|
|||||||
command := args
|
command := args
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
command = []string{"/bin/bash"}
|
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}
|
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}
|
command = []string{appShell}
|
||||||
}
|
}
|
||||||
} else if len(args) == 1 {
|
} else if len(args) == 1 {
|
||||||
|
|||||||
Reference in new issue
Block a user