refactor: use CallPlugnTrigger instead of PlugnTriggerOutputAsString
Refs #6422
This commit is contained in:
1 parent
a9933c7f02
commit
f34fd277b3
5 files changed
+81
-26
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user