style tweaks
This commit is contained in:
@@ -5,33 +5,27 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
config "github.com/dokku/dokku/plugins/config"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/config"
|
||||
|
||||
sh "github.com/codeskyblue/go-sh"
|
||||
)
|
||||
|
||||
// ValidProperties is a map of all valid network properties
|
||||
var ValidProperties = map[string]bool{
|
||||
"bind-all-interfaces": true,
|
||||
}
|
||||
|
||||
// DefaultPropertyValues is a map of all valid network properties with corresponding default property values
|
||||
var DefaultPropertyValues = map[string]string{
|
||||
"bind-all-interfaces": "false",
|
||||
}
|
||||
var (
|
||||
// DefaultProperties is a map of all valid network properties with corresponding default property values
|
||||
DefaultProperties = map[string]string{
|
||||
"bind-all-interfaces": "false",
|
||||
}
|
||||
)
|
||||
|
||||
// BuildConfig builds network config files
|
||||
func BuildConfig(appName string) {
|
||||
err := common.VerifyAppName(appName)
|
||||
if err != nil {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
|
||||
if !common.IsDeployed(appName) {
|
||||
return
|
||||
}
|
||||
|
||||
appRoot := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName}, "/")
|
||||
scaleFile := strings.Join([]string{appRoot, "DOKKU_SCALE"}, "/")
|
||||
if !common.FileExists(scaleFile) {
|
||||
@@ -40,7 +34,6 @@ func BuildConfig(appName string) {
|
||||
|
||||
image := common.GetAppImageName(appName, "", "")
|
||||
isHerokuishContainer := common.IsImageHerokuishBased(image)
|
||||
|
||||
common.LogInfo1(fmt.Sprintf("Ensuring network configuration is in sync for %s", appName))
|
||||
lines, err := common.FileToSlice(scaleFile)
|
||||
if err != nil {
|
||||
@@ -93,9 +86,9 @@ func BuildConfig(appName string) {
|
||||
}
|
||||
|
||||
// GetContainerIpaddress returns the ipaddr for a given app container
|
||||
func GetContainerIpaddress(appName string, procType string, containerID string) string {
|
||||
func GetContainerIpaddress(appName, procType, containerID string) (ipAddr string) {
|
||||
if procType != "web" {
|
||||
return ""
|
||||
return
|
||||
}
|
||||
|
||||
b, err := common.DockerInspect(containerID, "'{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'")
|
||||
@@ -108,18 +101,16 @@ func GetContainerIpaddress(appName string, procType string, containerID string)
|
||||
return string(b[:])
|
||||
}
|
||||
|
||||
return ""
|
||||
return
|
||||
}
|
||||
|
||||
// GetContainerPort returns the port for a given app container
|
||||
func GetContainerPort(appName string, procType string, isHerokuishContainer bool, containerID string) string {
|
||||
func GetContainerPort(appName, procType string, isHerokuishContainer bool, containerID string) (port string) {
|
||||
if procType != "web" {
|
||||
return ""
|
||||
return
|
||||
}
|
||||
|
||||
dockerfilePorts := make([]string, 0)
|
||||
port := ""
|
||||
|
||||
if !isHerokuishContainer {
|
||||
configValue := config.GetWithDefault(appName, "DOKKU_DOCKERFILE_PORTS", "")
|
||||
if configValue != "" {
|
||||
@@ -145,15 +136,16 @@ func GetContainerPort(appName string, procType string, isHerokuishContainer bool
|
||||
port = "5000"
|
||||
}
|
||||
|
||||
return port
|
||||
return
|
||||
}
|
||||
|
||||
// GetDefaultValue returns the default value for a given property
|
||||
func GetDefaultValue(property string) string {
|
||||
if ValidProperties[property] {
|
||||
return DefaultPropertyValues[property]
|
||||
func GetDefaultValue(property string) (value string) {
|
||||
value, ok := DefaultProperties[property]
|
||||
if ok {
|
||||
return
|
||||
}
|
||||
return ""
|
||||
return
|
||||
}
|
||||
|
||||
// HasNetworkConfig returns whether the network configuration for a given app exists
|
||||
|
||||
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
|
||||
network "github.com/dokku/dokku/plugins/network"
|
||||
"github.com/dokku/dokku/plugins/network"
|
||||
)
|
||||
|
||||
// rebuilds network settings for an app
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
network "github.com/dokku/dokku/plugins/network"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/network"
|
||||
)
|
||||
|
||||
// rebuilds network settings for all apps
|
||||
|
||||
@@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
network "github.com/dokku/dokku/plugins/network"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/network"
|
||||
)
|
||||
|
||||
// set or clear a network property for an app
|
||||
@@ -18,5 +18,5 @@ func main() {
|
||||
value = "false"
|
||||
}
|
||||
|
||||
common.CommandPropertySet("network", appName, property, value, network.ValidProperties)
|
||||
common.CommandPropertySet("network", appName, property, value, network.DefaultProperties)
|
||||
}
|
||||
|
||||
@@ -3,14 +3,13 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
proxy "github.com/dokku/dokku/plugins/proxy"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/proxy"
|
||||
)
|
||||
|
||||
// runs the install step for the network plugin
|
||||
func main() {
|
||||
err := common.PropertySetup("network")
|
||||
if err != nil {
|
||||
if err := common.PropertySetup("network"); err != nil {
|
||||
common.LogFail(fmt.Sprintf("Unable to install the network plugin: %s", err.Error()))
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
|
||||
network "github.com/dokku/dokku/plugins/network"
|
||||
"github.com/dokku/dokku/plugins/network"
|
||||
)
|
||||
|
||||
// rebuilds network settings for an app
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
config "github.com/dokku/dokku/plugins/config"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/config"
|
||||
)
|
||||
|
||||
// computes the ports for a given app container
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
network "github.com/dokku/dokku/plugins/network"
|
||||
"github.com/dokku/dokku/plugins/network"
|
||||
)
|
||||
|
||||
// write the ipaddress to stdout for a given app container
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
network "github.com/dokku/dokku/plugins/network"
|
||||
"github.com/dokku/dokku/plugins/network"
|
||||
)
|
||||
|
||||
// write the ipaddress to stdout for a given app container
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// returns the listeners (host:port combinations) for a given app container
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
network "github.com/dokku/dokku/plugins/network"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
network "github.com/dokku/dokku/plugins/network"
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// writes the ip to disk
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// writes the port to disk
|
||||
|
||||
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// set bind-all-interfaces to false by default
|
||||
|
||||
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
|
||||
common "github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// write the port to stdout for a given app container
|
||||
|
||||
Reference in New Issue
Block a user