From 72eb8a06f0f447e93f2d3771a233420f3627cc4c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 26 Apr 2017 18:49:19 -0600 Subject: [PATCH] fix: respond to all review comments --- plugins/common/common.go | 6 +++--- plugins/network/network.go | 6 +++--- .../triggers/network-write-ipaddr/network-write-ipaddr.go | 1 + .../src/triggers/network-write-port/network-write-port.go | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/common/common.go b/plugins/common/common.go index 8bc3309d5..26825054b 100644 --- a/plugins/common/common.go +++ b/plugins/common/common.go @@ -162,7 +162,7 @@ func ContainerIsRunning(containerId string) bool { if err != nil { return false } - return string(b[:]) == "true" + return strings.TrimSpace(string(b[:])) == "true" } // DirectoryExists returns if a path exists and is a directory @@ -234,7 +234,7 @@ func FileExists(filePath string) bool { return fi.Mode().IsRegular() } -// GetAppImageName returnS image identifier for a given app, tag tuple. validate if tag is presented +// GetAppImageName returns image identifier for a given app, tag tuple. validate if tag is presented func GetAppImageName(appName, imageTag, imageRepo string) (imageName string) { err := VerifyAppName(appName) if err != nil { @@ -302,7 +302,7 @@ func LogInfo1(text string) { fmt.Fprintln(os.Stdout, fmt.Sprintf("-----> %s", text)) } -// LogInfo2Quiet is the info1 header formatter (with quiet option) +// LogInfo1Quiet is the info1 header formatter (with quiet option) func LogInfo1Quiet(text string) { if os.Getenv("DOKKU_QUIET_OUTPUT") != "" { LogInfo1(text) diff --git a/plugins/network/network.go b/plugins/network/network.go index 6ef28c3d0..cacb79001 100644 --- a/plugins/network/network.go +++ b/plugins/network/network.go @@ -33,7 +33,7 @@ func GetContainerIpaddress(appName string, procType string, isHerokuishContainer b, err := imageCmd.Output() if err != nil || len(b) == 0 { - // docker < .19 compatibility + // docker < 1.9 compatibility imageCmd = common.NewShellCmd(strings.Join([]string{ "docker", "inspect", @@ -124,7 +124,7 @@ func BuildConfig(appName string) { continue } - procParts := strings.SplitAfterN(line, ":", 2) + procParts := strings.SplitN(line, "=", 2) if len(procParts) != 2 { continue } @@ -135,7 +135,7 @@ func BuildConfig(appName string) { } containerIndex := 0 - for containerIndex <= procCount { + for containerIndex < procCount { containerIndex += 1 containerIdFile := fmt.Sprintf("%v/CONTAINER.%v.%v", appRoot, procType, containerIndex) diff --git a/plugins/network/src/triggers/network-write-ipaddr/network-write-ipaddr.go b/plugins/network/src/triggers/network-write-ipaddr/network-write-ipaddr.go index 9ba30e635..effc303ce 100644 --- a/plugins/network/src/triggers/network-write-ipaddr/network-write-ipaddr.go +++ b/plugins/network/src/triggers/network-write-ipaddr/network-write-ipaddr.go @@ -31,6 +31,7 @@ func main() { if err != nil { common.LogFail(err.Error()) } + defer f.Close() ipBytes := []byte(ip) _, err = f.Write(ipBytes) diff --git a/plugins/network/src/triggers/network-write-port/network-write-port.go b/plugins/network/src/triggers/network-write-port/network-write-port.go index df79e809b..eef3ad488 100644 --- a/plugins/network/src/triggers/network-write-port/network-write-port.go +++ b/plugins/network/src/triggers/network-write-port/network-write-port.go @@ -31,6 +31,7 @@ func main() { if err != nil { common.LogFail(err.Error()) } + defer f.Close() portBytes := []byte(port) _, err = f.Write(portBytes)