aboutsummaryrefslogtreecommitdiff
path: root/opts
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2020-10-30 21:17:34 +0100
committerSebastiaan van Stijn <github@gone.nl>2020-10-30 21:17:34 +0100
commit053962af9259be9a4ce8f50894a1a5ada9387322 (patch)
treecaff65c15f09e09268baac3f63b30b395887f9d8 /opts
parentbb23f1bf61cb49c5aa3f7df934d79c305afb7c8c (diff)
Move HostGatewayName const to opts, and change vars to consts
This prevents consumers of the opts package to also having to depend on daemon/network, and everything related. We can probably change some of the other constants to strings, for easier concatenating, and need to review the windows-specific "127.0.0.1" (instead of "localhost"), which may no longer be needed. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'opts')
-rw-r--r--opts/hosts.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/opts/hosts.go b/opts/hosts.go
index 41caae3072..a3123adefe 100644
--- a/opts/hosts.go
+++ b/opts/hosts.go
@@ -8,11 +8,10 @@ import (
"strconv"
"strings"
- "github.com/docker/docker/daemon/network"
"github.com/docker/docker/pkg/homedir"
)
-var (
+const (
// DefaultHTTPPort Default HTTP Port used if only the protocol is provided to -H flag e.g. dockerd -H tcp://
// These are the IANA registered port numbers for use with Docker
// see http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=docker
@@ -23,11 +22,15 @@ var (
// Docker daemon by default always listens on the default unix socket
DefaultUnixSocket = "/var/run/docker.sock"
// DefaultTCPHost constant defines the default host string used by docker on Windows
- DefaultTCPHost = fmt.Sprintf("tcp://%s:%d", DefaultHTTPHost, DefaultHTTPPort)
+ DefaultTCPHost = "tcp://" + DefaultHTTPHost + ":2375"
// DefaultTLSHost constant defines the default host string used by docker for TLS sockets
- DefaultTLSHost = fmt.Sprintf("tcp://%s:%d", DefaultHTTPHost, DefaultTLSHTTPPort)
+ DefaultTLSHost = "tcp://" + DefaultHTTPHost + ":2376"
// DefaultNamedPipe defines the default named pipe used by docker on Windows
DefaultNamedPipe = `//./pipe/docker_engine`
+ // HostGatewayName is the string value that can be passed
+ // to the IPAddr section in --add-host that is replaced by
+ // the value of HostGatewayIP daemon config value
+ HostGatewayName = "host-gateway"
)
// ValidateHost validates that the specified string is a valid host and returns it.
@@ -171,7 +174,7 @@ func ValidateExtraHost(val string) (string, error) {
return "", fmt.Errorf("bad format for add-host: %q", val)
}
// Skip IPaddr validation for special "host-gateway" string
- if arr[1] != network.HostGatewayName {
+ if arr[1] != HostGatewayName {
if _, err := ValidateIPAddress(arr[1]); err != nil {
return "", fmt.Errorf("invalid IP address in add-host: %q", arr[1])
}