2015-12-15 20:53:17 -05:00
|
|
|
package opts
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
"net/url"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2020-04-10 08:23:58 -04:00
|
|
|
const (
|
|
|
|
// defaultHTTPPort Default HTTP Port used if only the protocol is provided to -H flag e.g. dockerd -H tcp://
|
2015-12-15 20:53:17 -05:00
|
|
|
// 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
|
2020-04-10 08:23:58 -04:00
|
|
|
defaultHTTPPort = "2375" // Default HTTP Port
|
|
|
|
// defaultTLSHTTPPort Default HTTP Port used when TLS enabled
|
|
|
|
defaultTLSHTTPPort = "2376" // Default TLS encrypted HTTP Port
|
|
|
|
// defaultUnixSocket Path for the unix socket.
|
2015-12-15 20:53:17 -05:00
|
|
|
// Docker daemon by default always listens on the default unix socket
|
2020-04-10 08:23:58 -04:00
|
|
|
defaultUnixSocket = "/var/run/docker.sock"
|
|
|
|
// defaultTCPHost constant defines the default host string used by docker on Windows
|
|
|
|
defaultTCPHost = "tcp://" + defaultHTTPHost + ":" + defaultHTTPPort
|
2015-12-15 20:53:17 -05:00
|
|
|
// DefaultTLSHost constant defines the default host string used by docker for TLS sockets
|
2020-04-10 08:23:58 -04:00
|
|
|
defaultTLSHost = "tcp://" + defaultHTTPHost + ":" + defaultTLSHTTPPort
|
2016-01-30 21:45:49 -05:00
|
|
|
// DefaultNamedPipe defines the default named pipe used by docker on Windows
|
2020-04-10 08:23:58 -04:00
|
|
|
defaultNamedPipe = `//./pipe/docker_engine`
|
2020-02-11 15:00:06 -05:00
|
|
|
// hostGatewayName defines a special string which users can append to --add-host
|
|
|
|
// to add an extra entry in /etc/hosts that maps host.docker.internal to the host IP
|
2020-04-10 08:23:58 -04:00
|
|
|
// TODO Consider moving the hostGatewayName constant defined in docker at
|
2020-02-11 15:00:06 -05:00
|
|
|
// github.com/docker/docker/daemon/network/constants.go outside of the "daemon"
|
|
|
|
// package, so that the CLI can consume it.
|
|
|
|
hostGatewayName = "host-gateway"
|
2015-12-15 20:53:17 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// ValidateHost validates that the specified string is a valid host and returns it.
|
|
|
|
func ValidateHost(val string) (string, error) {
|
2016-01-30 21:45:49 -05:00
|
|
|
host := strings.TrimSpace(val)
|
|
|
|
// The empty string means default and is not handled by parseDockerDaemonHost
|
|
|
|
if host != "" {
|
|
|
|
_, err := parseDockerDaemonHost(host)
|
|
|
|
if err != nil {
|
|
|
|
return val, err
|
|
|
|
}
|
2015-12-15 20:53:17 -05:00
|
|
|
}
|
|
|
|
// Note: unlike most flag validators, we don't return the mutated value here
|
2016-12-20 06:14:41 -05:00
|
|
|
// we need to know what the user entered later (using ParseHost) to adjust for TLS
|
2015-12-15 20:53:17 -05:00
|
|
|
return val, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ParseHost and set defaults for a Daemon host string
|
2016-01-30 21:45:49 -05:00
|
|
|
func ParseHost(defaultToTLS bool, val string) (string, error) {
|
|
|
|
host := strings.TrimSpace(val)
|
|
|
|
if host == "" {
|
|
|
|
if defaultToTLS {
|
2020-04-10 08:23:58 -04:00
|
|
|
host = defaultTLSHost
|
2016-01-30 21:45:49 -05:00
|
|
|
} else {
|
2020-04-10 08:23:58 -04:00
|
|
|
host = defaultHost
|
2016-01-30 21:45:49 -05:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var err error
|
|
|
|
host, err = parseDockerDaemonHost(host)
|
|
|
|
if err != nil {
|
|
|
|
return val, err
|
|
|
|
}
|
2015-12-15 20:53:17 -05:00
|
|
|
}
|
|
|
|
return host, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// parseDockerDaemonHost parses the specified address and returns an address that will be used as the host.
|
2016-01-30 21:45:49 -05:00
|
|
|
// Depending of the address specified, this may return one of the global Default* strings defined in hosts.go.
|
|
|
|
func parseDockerDaemonHost(addr string) (string, error) {
|
2016-06-21 20:14:55 -04:00
|
|
|
addrParts := strings.SplitN(addr, "://", 2)
|
2016-01-30 21:45:49 -05:00
|
|
|
if len(addrParts) == 1 && addrParts[0] != "" {
|
2015-12-15 20:53:17 -05:00
|
|
|
addrParts = []string{"tcp", addrParts[0]}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch addrParts[0] {
|
|
|
|
case "tcp":
|
2020-04-10 08:23:58 -04:00
|
|
|
return ParseTCPAddr(addrParts[1], defaultTCPHost)
|
2015-12-15 20:53:17 -05:00
|
|
|
case "unix":
|
2020-04-10 08:23:58 -04:00
|
|
|
return parseSimpleProtoAddr("unix", addrParts[1], defaultUnixSocket)
|
2016-01-30 21:45:49 -05:00
|
|
|
case "npipe":
|
2020-04-10 08:23:58 -04:00
|
|
|
return parseSimpleProtoAddr("npipe", addrParts[1], defaultNamedPipe)
|
2015-12-15 20:53:17 -05:00
|
|
|
case "fd":
|
|
|
|
return addr, nil
|
2018-10-11 22:30:49 -04:00
|
|
|
case "ssh":
|
|
|
|
return addr, nil
|
2015-12-15 20:53:17 -05:00
|
|
|
default:
|
linting: ST1005: error strings should not be capitalized (stylecheck)
While fixing, also updated errors without placeholders to `errors.New()`, and
updated some code to use pkg/errors if it was already in use in the file.
cli/command/config/inspect.go:59:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/node/inspect.go:61:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/secret/inspect.go:57:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/trust/common.go:77:74: ST1005: error strings should not be capitalized (stylecheck)
return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signatures or cannot access %s", remote)
^
cli/command/trust/common.go:85:73: ST1005: error strings should not be capitalized (stylecheck)
return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signers for %s", remote)
^
cli/command/trust/sign.go:137:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("No tag specified for %s", imgRefAndAuth.Name())
^
cli/command/trust/sign.go:151:19: ST1005: error strings should not be capitalized (stylecheck)
return *target, fmt.Errorf("No tag specified")
^
cli/command/trust/signer_add.go:77:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Failed to add signer to: %s", strings.Join(errRepos, ", "))
^
cli/command/trust/signer_remove.go:52:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Error removing signer from: %s", strings.Join(errRepos, ", "))
^
cli/command/trust/signer_remove.go:67:17: ST1005: error strings should not be capitalized (stylecheck)
return false, fmt.Errorf("All signed tags are currently revoked, use docker trust sign to fix")
^
cli/command/trust/signer_remove.go:108:17: ST1005: error strings should not be capitalized (stylecheck)
return false, fmt.Errorf("No signer %s for repository %s", signerName, repoName)
^
opts/hosts.go:89:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", addr)
^
opts/hosts.go:100:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid proto, expected %s: %s", proto, addr)
^
opts/hosts.go:119:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid proto, expected tcp: %s", tryAddr)
^
opts/hosts.go:144:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
^
opts/hosts.go:155:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-02 18:04:53 -04:00
|
|
|
return "", fmt.Errorf("invalid bind address format: %s", addr)
|
2015-12-15 20:53:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-30 21:45:49 -05:00
|
|
|
// parseSimpleProtoAddr parses and validates that the specified address is a valid
|
|
|
|
// socket address for simple protocols like unix and npipe. It returns a formatted
|
|
|
|
// socket address, either using the address parsed from addr, or the contents of
|
|
|
|
// defaultAddr if addr is a blank string.
|
|
|
|
func parseSimpleProtoAddr(proto, addr, defaultAddr string) (string, error) {
|
|
|
|
addr = strings.TrimPrefix(addr, proto+"://")
|
2015-12-15 20:53:17 -05:00
|
|
|
if strings.Contains(addr, "://") {
|
linting: ST1005: error strings should not be capitalized (stylecheck)
While fixing, also updated errors without placeholders to `errors.New()`, and
updated some code to use pkg/errors if it was already in use in the file.
cli/command/config/inspect.go:59:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/node/inspect.go:61:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/secret/inspect.go:57:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/trust/common.go:77:74: ST1005: error strings should not be capitalized (stylecheck)
return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signatures or cannot access %s", remote)
^
cli/command/trust/common.go:85:73: ST1005: error strings should not be capitalized (stylecheck)
return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signers for %s", remote)
^
cli/command/trust/sign.go:137:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("No tag specified for %s", imgRefAndAuth.Name())
^
cli/command/trust/sign.go:151:19: ST1005: error strings should not be capitalized (stylecheck)
return *target, fmt.Errorf("No tag specified")
^
cli/command/trust/signer_add.go:77:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Failed to add signer to: %s", strings.Join(errRepos, ", "))
^
cli/command/trust/signer_remove.go:52:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Error removing signer from: %s", strings.Join(errRepos, ", "))
^
cli/command/trust/signer_remove.go:67:17: ST1005: error strings should not be capitalized (stylecheck)
return false, fmt.Errorf("All signed tags are currently revoked, use docker trust sign to fix")
^
cli/command/trust/signer_remove.go:108:17: ST1005: error strings should not be capitalized (stylecheck)
return false, fmt.Errorf("No signer %s for repository %s", signerName, repoName)
^
opts/hosts.go:89:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", addr)
^
opts/hosts.go:100:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid proto, expected %s: %s", proto, addr)
^
opts/hosts.go:119:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid proto, expected tcp: %s", tryAddr)
^
opts/hosts.go:144:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
^
opts/hosts.go:155:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-02 18:04:53 -04:00
|
|
|
return "", fmt.Errorf("invalid proto, expected %s: %s", proto, addr)
|
2015-12-15 20:53:17 -05:00
|
|
|
}
|
|
|
|
if addr == "" {
|
|
|
|
addr = defaultAddr
|
|
|
|
}
|
2016-01-30 21:45:49 -05:00
|
|
|
return fmt.Sprintf("%s://%s", proto, addr), nil
|
2015-12-15 20:53:17 -05:00
|
|
|
}
|
|
|
|
|
2016-06-21 17:27:04 -04:00
|
|
|
// ParseTCPAddr parses and validates that the specified address is a valid TCP
|
2015-12-15 20:53:17 -05:00
|
|
|
// address. It returns a formatted TCP address, either using the address parsed
|
|
|
|
// from tryAddr, or the contents of defaultAddr if tryAddr is a blank string.
|
|
|
|
// tryAddr is expected to have already been Trim()'d
|
|
|
|
// defaultAddr must be in the full `tcp://host:port` form
|
2016-06-21 17:27:04 -04:00
|
|
|
func ParseTCPAddr(tryAddr string, defaultAddr string) (string, error) {
|
2015-12-15 20:53:17 -05:00
|
|
|
if tryAddr == "" || tryAddr == "tcp://" {
|
|
|
|
return defaultAddr, nil
|
|
|
|
}
|
|
|
|
addr := strings.TrimPrefix(tryAddr, "tcp://")
|
|
|
|
if strings.Contains(addr, "://") || addr == "" {
|
linting: ST1005: error strings should not be capitalized (stylecheck)
While fixing, also updated errors without placeholders to `errors.New()`, and
updated some code to use pkg/errors if it was already in use in the file.
cli/command/config/inspect.go:59:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/node/inspect.go:61:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/secret/inspect.go:57:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/trust/common.go:77:74: ST1005: error strings should not be capitalized (stylecheck)
return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signatures or cannot access %s", remote)
^
cli/command/trust/common.go:85:73: ST1005: error strings should not be capitalized (stylecheck)
return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signers for %s", remote)
^
cli/command/trust/sign.go:137:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("No tag specified for %s", imgRefAndAuth.Name())
^
cli/command/trust/sign.go:151:19: ST1005: error strings should not be capitalized (stylecheck)
return *target, fmt.Errorf("No tag specified")
^
cli/command/trust/signer_add.go:77:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Failed to add signer to: %s", strings.Join(errRepos, ", "))
^
cli/command/trust/signer_remove.go:52:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Error removing signer from: %s", strings.Join(errRepos, ", "))
^
cli/command/trust/signer_remove.go:67:17: ST1005: error strings should not be capitalized (stylecheck)
return false, fmt.Errorf("All signed tags are currently revoked, use docker trust sign to fix")
^
cli/command/trust/signer_remove.go:108:17: ST1005: error strings should not be capitalized (stylecheck)
return false, fmt.Errorf("No signer %s for repository %s", signerName, repoName)
^
opts/hosts.go:89:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", addr)
^
opts/hosts.go:100:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid proto, expected %s: %s", proto, addr)
^
opts/hosts.go:119:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid proto, expected tcp: %s", tryAddr)
^
opts/hosts.go:144:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
^
opts/hosts.go:155:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-02 18:04:53 -04:00
|
|
|
return "", fmt.Errorf("invalid proto, expected tcp: %s", tryAddr)
|
2015-12-15 20:53:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
defaultAddr = strings.TrimPrefix(defaultAddr, "tcp://")
|
|
|
|
defaultHost, defaultPort, err := net.SplitHostPort(defaultAddr)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
// url.Parse fails for trailing colon on IPv6 brackets on Go 1.5, but
|
|
|
|
// not 1.4. See https://github.com/golang/go/issues/12200 and
|
|
|
|
// https://github.com/golang/go/issues/6530.
|
|
|
|
if strings.HasSuffix(addr, "]:") {
|
|
|
|
addr += defaultPort
|
|
|
|
}
|
|
|
|
|
|
|
|
u, err := url.Parse("tcp://" + addr)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
host, port, err := net.SplitHostPort(u.Host)
|
2016-06-21 17:27:04 -04:00
|
|
|
if err != nil {
|
|
|
|
// try port addition once
|
|
|
|
host, port, err = net.SplitHostPort(net.JoinHostPort(u.Host, defaultPort))
|
|
|
|
}
|
2015-12-15 20:53:17 -05:00
|
|
|
if err != nil {
|
linting: ST1005: error strings should not be capitalized (stylecheck)
While fixing, also updated errors without placeholders to `errors.New()`, and
updated some code to use pkg/errors if it was already in use in the file.
cli/command/config/inspect.go:59:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/node/inspect.go:61:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/secret/inspect.go:57:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/trust/common.go:77:74: ST1005: error strings should not be capitalized (stylecheck)
return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signatures or cannot access %s", remote)
^
cli/command/trust/common.go:85:73: ST1005: error strings should not be capitalized (stylecheck)
return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signers for %s", remote)
^
cli/command/trust/sign.go:137:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("No tag specified for %s", imgRefAndAuth.Name())
^
cli/command/trust/sign.go:151:19: ST1005: error strings should not be capitalized (stylecheck)
return *target, fmt.Errorf("No tag specified")
^
cli/command/trust/signer_add.go:77:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Failed to add signer to: %s", strings.Join(errRepos, ", "))
^
cli/command/trust/signer_remove.go:52:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Error removing signer from: %s", strings.Join(errRepos, ", "))
^
cli/command/trust/signer_remove.go:67:17: ST1005: error strings should not be capitalized (stylecheck)
return false, fmt.Errorf("All signed tags are currently revoked, use docker trust sign to fix")
^
cli/command/trust/signer_remove.go:108:17: ST1005: error strings should not be capitalized (stylecheck)
return false, fmt.Errorf("No signer %s for repository %s", signerName, repoName)
^
opts/hosts.go:89:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", addr)
^
opts/hosts.go:100:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid proto, expected %s: %s", proto, addr)
^
opts/hosts.go:119:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid proto, expected tcp: %s", tryAddr)
^
opts/hosts.go:144:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
^
opts/hosts.go:155:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-02 18:04:53 -04:00
|
|
|
return "", fmt.Errorf("invalid bind address format: %s", tryAddr)
|
2015-12-15 20:53:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if host == "" {
|
|
|
|
host = defaultHost
|
|
|
|
}
|
|
|
|
if port == "" {
|
|
|
|
port = defaultPort
|
|
|
|
}
|
|
|
|
p, err := strconv.Atoi(port)
|
|
|
|
if err != nil && p == 0 {
|
linting: ST1005: error strings should not be capitalized (stylecheck)
While fixing, also updated errors without placeholders to `errors.New()`, and
updated some code to use pkg/errors if it was already in use in the file.
cli/command/config/inspect.go:59:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/node/inspect.go:61:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/secret/inspect.go:57:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Cannot supply extra formatting options to the pretty template")
^
cli/command/trust/common.go:77:74: ST1005: error strings should not be capitalized (stylecheck)
return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signatures or cannot access %s", remote)
^
cli/command/trust/common.go:85:73: ST1005: error strings should not be capitalized (stylecheck)
return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signers for %s", remote)
^
cli/command/trust/sign.go:137:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("No tag specified for %s", imgRefAndAuth.Name())
^
cli/command/trust/sign.go:151:19: ST1005: error strings should not be capitalized (stylecheck)
return *target, fmt.Errorf("No tag specified")
^
cli/command/trust/signer_add.go:77:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Failed to add signer to: %s", strings.Join(errRepos, ", "))
^
cli/command/trust/signer_remove.go:52:10: ST1005: error strings should not be capitalized (stylecheck)
return fmt.Errorf("Error removing signer from: %s", strings.Join(errRepos, ", "))
^
cli/command/trust/signer_remove.go:67:17: ST1005: error strings should not be capitalized (stylecheck)
return false, fmt.Errorf("All signed tags are currently revoked, use docker trust sign to fix")
^
cli/command/trust/signer_remove.go:108:17: ST1005: error strings should not be capitalized (stylecheck)
return false, fmt.Errorf("No signer %s for repository %s", signerName, repoName)
^
opts/hosts.go:89:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", addr)
^
opts/hosts.go:100:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid proto, expected %s: %s", proto, addr)
^
opts/hosts.go:119:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid proto, expected tcp: %s", tryAddr)
^
opts/hosts.go:144:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
^
opts/hosts.go:155:14: ST1005: error strings should not be capitalized (stylecheck)
return "", fmt.Errorf("Invalid bind address format: %s", tryAddr)
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-02 18:04:53 -04:00
|
|
|
return "", fmt.Errorf("invalid bind address format: %s", tryAddr)
|
2015-12-15 20:53:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("tcp://%s%s", net.JoinHostPort(host, port), u.Path), nil
|
|
|
|
}
|
2016-12-23 14:09:12 -05:00
|
|
|
|
|
|
|
// ValidateExtraHost validates that the specified string is a valid extrahost and returns it.
|
|
|
|
// ExtraHost is in the form of name:ip where the ip has to be a valid ip (IPv4 or IPv6).
|
|
|
|
func ValidateExtraHost(val string) (string, error) {
|
|
|
|
// allow for IPv6 addresses in extra hosts by only splitting on first ":"
|
|
|
|
arr := strings.SplitN(val, ":", 2)
|
|
|
|
if len(arr) != 2 || len(arr[0]) == 0 {
|
|
|
|
return "", fmt.Errorf("bad format for add-host: %q", val)
|
|
|
|
}
|
2020-02-11 15:00:06 -05:00
|
|
|
// Skip IPaddr validation for "host-gateway" string
|
|
|
|
if arr[1] != hostGatewayName {
|
|
|
|
if _, err := ValidateIPAddress(arr[1]); err != nil {
|
|
|
|
return "", fmt.Errorf("invalid IP address in add-host: %q", arr[1])
|
|
|
|
}
|
2016-12-23 14:09:12 -05:00
|
|
|
}
|
|
|
|
return val, nil
|
|
|
|
}
|