Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Handle SplitHostPort errors
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Apr 24, 2019
1 parent 9e471d3 commit acd39bb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions registry/client_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,21 @@ attemptChallenge:
}

func (f *RemoteClientFactory) ClientFor(repo image.CanonicalName, creds Credentials) (Client, error) {
repoHost, _, err := net.SplitHostPort(repo.Domain)
if err != nil {
return nil, err
repoHosts := []string{repo.Domain}
// allow the insecure hosts list to contain hosts with or without the port
repoHostWithoutPort, _, err := net.SplitHostPort(repo.Domain)
if err == nil {
// parsing fails if no port is present
repoHosts = append(repoHosts, repoHostWithoutPort)
}
insecure := false
insecureCheckLoop:
for _, h := range f.InsecureHosts {
// allow the insecure hosts list to contain hosts with or without the port
if repoHost == h || repo.Domain == h {
insecure = true
break
for _, repoHost := range repoHosts {
if h == repoHost {
insecure = true
break insecureCheckLoop
}
}
}

Expand Down

0 comments on commit acd39bb

Please sign in to comment.