fix: correct lint errors

This commit is contained in:
Jose Diaz-Gonzalez
2017-07-22 15:26:23 -06:00
committed by Michael Hobbs
parent 92d6e76ea4
commit 3b9f4ba63f
2 changed files with 15 additions and 14 deletions

View File

@@ -7,6 +7,7 @@ import (
common "github.com/dokku/dokku/plugins/common" common "github.com/dokku/dokku/plugins/common"
) )
// GetWithDefault returns the value set for a given key, returning defaultValue if none found
func GetWithDefault(appName string, key string, defaultValue string) string { func GetWithDefault(appName string, key string, defaultValue string) string {
envFile := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName, "ENV"}, "/") envFile := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName, "ENV"}, "/")
lines, err := common.FileToSlice(envFile) lines, err := common.FileToSlice(envFile)

View File

@@ -12,8 +12,8 @@ import (
sh "github.com/codeskyblue/go-sh" sh "github.com/codeskyblue/go-sh"
) )
// return the ipaddr for a given app container // GetContainerIpaddress returns the ipaddr for a given app container
func GetContainerIpaddress(appName string, procType string, isHerokuishContainer bool, containerId string) string { func GetContainerIpaddress(appName string, procType string, isHerokuishContainer bool, containerID string) string {
if procType != "web" { if procType != "web" {
return "" return ""
} }
@@ -23,10 +23,10 @@ func GetContainerIpaddress(appName string, procType string, isHerokuishContainer
return ipAddress return ipAddress
} }
b, err := common.DockerInspect(containerId, "'{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'") b, err := common.DockerInspect(containerID, "'{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'")
if err != nil || len(b) == 0 { if err != nil || len(b) == 0 {
// docker < 1.9 compatibility // docker < 1.9 compatibility
b, err = common.DockerInspect(containerId, "'{{ .NetworkSettings.IPAddress }}'") b, err = common.DockerInspect(containerID, "'{{ .NetworkSettings.IPAddress }}'")
} }
if err == nil { if err == nil {
@@ -36,8 +36,8 @@ func GetContainerIpaddress(appName string, procType string, isHerokuishContainer
return "" return ""
} }
// return the port for a given app container // GetContainerPort returns the port for a given app container
func GetContainerPort(appName string, procType string, isHerokuishContainer bool, containerId string) string { func GetContainerPort(appName string, procType string, isHerokuishContainer bool, containerID string) string {
if procType != "web" { if procType != "web" {
return "" return ""
} }
@@ -67,7 +67,7 @@ func GetContainerPort(appName string, procType string, isHerokuishContainer bool
} }
if !proxy.IsAppProxyEnabled(appName) { if !proxy.IsAppProxyEnabled(appName) {
b, err := sh.Command("docker", "port", containerId, port).Output() b, err := sh.Command("docker", "port", containerID, port).Output()
if err == nil { if err == nil {
port = strings.Split(string(b[:]), ":")[1] port = strings.Split(string(b[:]), ":")[1]
} }
@@ -76,7 +76,7 @@ func GetContainerPort(appName string, procType string, isHerokuishContainer bool
return port return port
} }
// builds network config files // BuildConfig builds network config files
func BuildConfig(appName string) { func BuildConfig(appName string) {
err := common.VerifyAppName(appName) err := common.VerifyAppName(appName)
if err != nil { if err != nil {
@@ -118,16 +118,16 @@ func BuildConfig(appName string) {
containerIndex := 0 containerIndex := 0
for containerIndex < procCount { for containerIndex < procCount {
containerIndex += 1 containerIndex++
containerIdFile := fmt.Sprintf("%v/CONTAINER.%v.%v", appRoot, procType, containerIndex) containerIDFile := fmt.Sprintf("%v/CONTAINER.%v.%v", appRoot, procType, containerIndex)
containerId := common.ReadFirstLine(containerIdFile) containerID := common.ReadFirstLine(containerIDFile)
if containerId == "" || !common.ContainerIsRunning(containerId) { if containerID == "" || !common.ContainerIsRunning(containerID) {
continue continue
} }
ipAddress := GetContainerIpaddress(appName, procType, isHerokuishContainer, containerId) ipAddress := GetContainerIpaddress(appName, procType, isHerokuishContainer, containerID)
port := GetContainerPort(appName, procType, isHerokuishContainer, containerId) port := GetContainerPort(appName, procType, isHerokuishContainer, containerID)
if ipAddress != "" { if ipAddress != "" {
_, err := sh.Command("plugn", "trigger", "network-write-ipaddr", appName, procType, containerIndex, ipAddress).Output() _, err := sh.Command("plugn", "trigger", "network-write-ipaddr", appName, procType, containerIndex, ipAddress).Output()