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>master
							parent
							
								
									bbd41f40bb
								
							
						
					
					
						commit
						a4cec8ca82
					
				|  | @ -125,7 +125,7 @@ func ParseDockerRef(ref string) (Named, error) { | |||
| // needs to be already validated before.
 | ||||
| func splitDockerDomain(name string) (domain, remainder string) { | ||||
| 	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 | ||||
| 	} else { | ||||
| 		domain, remainder = name[:i], name[i+1:] | ||||
|  |  | |||
|  | @ -19,6 +19,10 @@ const ( | |||
| 	// supported names.
 | ||||
| 	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
 | ||||
| 	// 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])` | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue