Skip to content

Commit

Permalink
fix: ensure all byte output is trimmed of whitespace
Browse files Browse the repository at this point in the history
This otherwise causes issues when interpreting the output as part of a variable, such as when constructing the deploying app image.

Closes dokku#4229
  • Loading branch information
josegonzalez committed Dec 13, 2020
1 parent ca2de6a commit 8c14bb9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion plugins/apps/apps.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package apps

import (
"strings"

"github.com/dokku/dokku/plugins/common"
)

Expand All @@ -12,7 +14,7 @@ func ReportSingleApp(appName, infoFlag string) error {

deploySource := ""
if b, err := common.PlugnTriggerSetup("deploy-source", []string{appName}...).SetInput("").Output(); err != nil {
deploySource = string(b[:])
deploySource = strings.TrimSpace(string(b[:]))
}

locked := "false"
Expand Down
2 changes: 1 addition & 1 deletion plugins/apps/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func maybeCreateApp(appName string) error {
}

b, _ := common.PlugnTriggerOutput("config-get-global", []string{"DOKKU_DISABLE_APP_AUTOCREATION"}...)
disableAutocreate := string(b[:])
disableAutocreate := strings.TrimSpace(string(b[:]))
if disableAutocreate == "true" {
common.LogWarn("App auto-creation disabled.")
return fmt.Errorf("Re-enable app auto-creation or create an app with 'dokku apps:create %s'", appName)
Expand Down
10 changes: 5 additions & 5 deletions plugins/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func GetAppScheduler(appName string) string {
}

b, _ := PlugnTriggerOutput("config-get", []string{appName, "DOKKU_SCHEDULER"}...)
value := string(b[:])
value := strings.TrimSpace(string(b[:]))
if value != "" {
return value
}
Expand All @@ -80,7 +80,7 @@ func GetAppScheduler(appName string) string {
// GetGlobalScheduler fetchs the global scheduler
func GetGlobalScheduler() string {
b, _ := PlugnTriggerOutput("config-get-global", []string{"DOKKU_SCHEDULER"}...)
value := string(b[:])
value := strings.TrimSpace(string(b[:]))
if value != "" {
return value
}
Expand All @@ -98,19 +98,19 @@ func GetDeployingAppImageName(appName, imageTag, imageRepo string) (string, erro
if err != nil {
return "", err
}
imageRemoteRepository := string(b[:])
imageRemoteRepository := strings.TrimSpace(string(b[:]))

b, err = PlugnTriggerOutput("deployed-app-image-tag", []string{appName}...)
if err != nil {
return "", err
}
newImageTag := string(b[:])
newImageTag := strings.TrimSpace(string(b[:]))

b, err = PlugnTriggerOutput("deployed-app-image-repo", []string{appName}...)
if err != nil {
return "", err
}
newImageRepo := string(b[:])
newImageRepo := strings.TrimSpace(string(b[:]))

if newImageRepo != "" {
imageRepo = newImageRepo
Expand Down
2 changes: 1 addition & 1 deletion plugins/common/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func DockerCleanup(appName string, forceCleanup bool) error {
skipCleanup := false
if appName != "" {
b, _ := PlugnTriggerOutput("config-get", []string{appName, "DOKKU_SKIP_CLEANUP"}...)
output := string(b[:])
output := strings.TrimSpace(string(b[:]))
if output == "true" {
skipCleanup = true
}
Expand Down

0 comments on commit 8c14bb9

Please sign in to comment.