这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions plugins/ports/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand Down
13 changes: 10 additions & 3 deletions plugins/scheduler-docker-local/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 10 additions & 5 deletions plugins/scheduler-k3s/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 5 additions & 2 deletions plugins/scheduler-k3s/portmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
30 changes: 26 additions & 4 deletions plugins/scheduler-k3s/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}
Expand Down Expand Up @@ -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 {
Expand Down