reference: introduce const for "localhost"
Localhost is treated special when parsing references, and always considered to be a domain, despite not having a "." nor a ":port". Adding a const for this, to allow documenting this special case (making it more visible). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
bbd41f40bb
commit
a4cec8ca82
2 changed files with 5 additions and 1 deletions
|
@ -125,7 +125,7 @@ func ParseDockerRef(ref string) (Named, error) {
|
||||||
// needs to be already validated before.
|
// needs to be already validated before.
|
||||||
func splitDockerDomain(name string) (domain, remainder string) {
|
func splitDockerDomain(name string) (domain, remainder string) {
|
||||||
i := strings.IndexRune(name, '/')
|
i := strings.IndexRune(name, '/')
|
||||||
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost" && strings.ToLower(name[:i]) == name[:i]) {
|
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != localhost && strings.ToLower(name[:i]) == name[:i]) {
|
||||||
domain, remainder = defaultDomain, name
|
domain, remainder = defaultDomain, name
|
||||||
} else {
|
} else {
|
||||||
domain, remainder = name[:i], name[i+1:]
|
domain, remainder = name[:i], name[i+1:]
|
||||||
|
|
|
@ -19,6 +19,10 @@ const (
|
||||||
// supported names.
|
// supported names.
|
||||||
separator = `(?:[._]|__|[-]*)`
|
separator = `(?:[._]|__|[-]*)`
|
||||||
|
|
||||||
|
// localhost is treated as a special value for domain-name. Any other
|
||||||
|
// domain-name without a "." or a ":port" are considered a path component.
|
||||||
|
localhost = `localhost`
|
||||||
|
|
||||||
// domainNameComponent restricts the registry domain component of a
|
// domainNameComponent restricts the registry domain component of a
|
||||||
// repository name to start with a component as defined by DomainRegexp.
|
// repository name to start with a component as defined by DomainRegexp.
|
||||||
domainNameComponent = `(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])`
|
domainNameComponent = `(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])`
|
||||||
|
|
Loading…
Reference in a new issue