WIP: Accept hostname/port combinations in image names
Specifying a custom hostname and port causes name collisions to occur, preventing clones from occurring due to DNS failures. This happens if the hostname of the registry and the GitLab server are same but on different ports. For example:
-
gitlab.example.com
is the GitLab server -
gitlab.example.com:4567
is the Registry
Previously an image named gitlab.example.com:4567/namespace/project
would be aliased to gitlab.example.com
, since everything after the colon would be stripped.
Closes #1434 (closed)
Merge request reports
Activity
@ayufan @tmaczukin What do you think of this approach?
468 afterSlash := name[i+1:] 469 470 if i >= 0 && strings.IndexRune(afterSlash, '/') >= 0 { 471 hostname, remoteName = name[:i], afterSlash 472 } else { 473 hostname, remoteName = "", name 474 } 475 476 return 477 } 478 465 479 func (s *executor) splitServiceAndVersion(serviceDescription string) (service string, version string, linkNames []string) { 466 splits := strings.SplitN(serviceDescription, ":", 2) 480 hostname, remoteName := splitHostname(serviceDescription) 481 482 splits := strings.SplitN(remoteName, ":", 2) https://github.com/docker/distribution/blob/master/reference/reference.go is the canonical implementation. !301 (merged) makes some use of it here: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/merge_requests/301/diffs#diff-15
Nice. So it seems that simplest to do now is to use this regexp: https://github.com/docker/distribution/blob/master/reference/reference.go#L15
It's defined here: https://github.com/docker/distribution/blob/master/reference/regexp.go#L37
Take a look at !376 (merged); trying to fix the same thing.
Actually, https://github.com/docker/distribution/blob/master/reference/reference.go#L138-L145 was revised since I saw http://stackoverflow.com/a/37867949/1992201.
Mentioned in issue #1868 (closed)
I'll close this in favor of !376 (merged).
Mentioned in merge request !376 (merged)