fix: ensure all byte output is trimmed of whitespace

This otherwise causes issues when interpreting the output as part of a variable, such as when constructing the deploying app image.

Closes #4229
This commit is contained in:
Jose Diaz-Gonzalez committed 2020-12-13 02:04:35 -05:00
1 parent ca2de6a4a3
commit 8c14bb9aeb
4 files changed
+10 -8

No files matched your search

+3 -1
View File
@@ -1,6 +1,8 @@
package apps package apps
import ( import (
"strings"
"github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/common"
) )
@@ -12,7 +14,7 @@ func ReportSingleApp(appName, infoFlag string) error {
deploySource := "" deploySource := ""
if b, err := common.PlugnTriggerSetup("deploy-source", []string{appName}...).SetInput("").Output(); err != nil { if b, err := common.PlugnTriggerSetup("deploy-source", []string{appName}...).SetInput("").Output(); err != nil {
deploySource = string(b[:]) deploySource = strings.TrimSpace(string(b[:]))
} }
locked := "false" locked := "false"
+1 -1
View File
@@ -140,7 +140,7 @@ func maybeCreateApp(appName string) error {
} }
b, _ := common.PlugnTriggerOutput("config-get-global", []string{"DOKKU_DISABLE_APP_AUTOCREATION"}...) b, _ := common.PlugnTriggerOutput("config-get-global", []string{"DOKKU_DISABLE_APP_AUTOCREATION"}...)
disableAutocreate := string(b[:]) disableAutocreate := strings.TrimSpace(string(b[:]))
if disableAutocreate == "true" { if disableAutocreate == "true" {
common.LogWarn("App auto-creation disabled.") common.LogWarn("App auto-creation disabled.")
return fmt.Errorf("Re-enable app auto-creation or create an app with 'dokku apps:create %s'", appName) return fmt.Errorf("Re-enable app auto-creation or create an app with 'dokku apps:create %s'", appName)
+5 -5
View File
@@ -69,7 +69,7 @@ func GetAppScheduler(appName string) string {
} }
b, _ := PlugnTriggerOutput("config-get", []string{appName, "DOKKU_SCHEDULER"}...) b, _ := PlugnTriggerOutput("config-get", []string{appName, "DOKKU_SCHEDULER"}...)
value := string(b[:]) value := strings.TrimSpace(string(b[:]))
if value != "" { if value != "" {
return value return value
} }
@@ -80,7 +80,7 @@ func GetAppScheduler(appName string) string {
// GetGlobalScheduler fetchs the global scheduler // GetGlobalScheduler fetchs the global scheduler
func GetGlobalScheduler() string { func GetGlobalScheduler() string {
b, _ := PlugnTriggerOutput("config-get-global", []string{"DOKKU_SCHEDULER"}...) b, _ := PlugnTriggerOutput("config-get-global", []string{"DOKKU_SCHEDULER"}...)
value := string(b[:]) value := strings.TrimSpace(string(b[:]))
if value != "" { if value != "" {
return value return value
} }
@@ -98,19 +98,19 @@ func GetDeployingAppImageName(appName, imageTag, imageRepo string) (string, erro
if err != nil { if err != nil {
return "", err return "", err
} }
imageRemoteRepository := string(b[:]) imageRemoteRepository := strings.TrimSpace(string(b[:]))
b, err = PlugnTriggerOutput("deployed-app-image-tag", []string{appName}...) b, err = PlugnTriggerOutput("deployed-app-image-tag", []string{appName}...)
if err != nil { if err != nil {
return "", err return "", err
} }
newImageTag := string(b[:]) newImageTag := strings.TrimSpace(string(b[:]))
b, err = PlugnTriggerOutput("deployed-app-image-repo", []string{appName}...) b, err = PlugnTriggerOutput("deployed-app-image-repo", []string{appName}...)
if err != nil { if err != nil {
return "", err return "", err
} }
newImageRepo := string(b[:]) newImageRepo := strings.TrimSpace(string(b[:]))
if newImageRepo != "" { if newImageRepo != "" {
imageRepo = newImageRepo imageRepo = newImageRepo
+1 -1
View File
@@ -137,7 +137,7 @@ func DockerCleanup(appName string, forceCleanup bool) error {
skipCleanup := false skipCleanup := false
if appName != "" { if appName != "" {
b, _ := PlugnTriggerOutput("config-get", []string{appName, "DOKKU_SKIP_CLEANUP"}...) b, _ := PlugnTriggerOutput("config-get", []string{appName, "DOKKU_SKIP_CLEANUP"}...)
output := string(b[:]) output := strings.TrimSpace(string(b[:]))
if output == "true" { if output == "true" {
skipCleanup = true skipCleanup = true
} }