Skip to content

Commit

Permalink
Update host resolver to use containerd host config
Browse files Browse the repository at this point in the history
Signed-off-by: Derek McGowan <derek@mcg.dev>
  • Loading branch information
dmcgowan committed Feb 29, 2024
1 parent 949d461 commit 11ed7f8
Show file tree
Hide file tree
Showing 7 changed files with 841 additions and 230 deletions.
15 changes: 5 additions & 10 deletions daemon/containerd/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,20 @@ func (i *ImageService) newResolverFromAuthConfig(ctx context.Context, authConfig
}

func hostsWrapper(hostsFn docker.RegistryHosts, optAuthConfig *registrytypes.AuthConfig, ref reference.Named, regService registryResolver) docker.RegistryHosts {
var authorizer docker.Authorizer
if optAuthConfig != nil {
authorizer = authorizerFromAuthConfig(*optAuthConfig, ref)
if optAuthConfig == nil {
return hostsFn
}

authorizer := authorizerFromAuthConfig(*optAuthConfig, ref)

return func(n string) ([]docker.RegistryHost, error) {
hosts, err := hostsFn(n)
if err != nil {
return nil, err
}

for i := range hosts {
if hosts[i].Authorizer == nil {
hosts[i].Authorizer = authorizer
isInsecure := regService.IsInsecureRegistry(hosts[i].Host)
if hosts[i].Client.Transport != nil && isInsecure {
hosts[i].Client.Transport = httpFallback{super: hosts[i].Client.Transport}
}
}
hosts[i].Authorizer = authorizer
}
return hosts, nil
}
Expand Down

0 comments on commit 11ed7f8

Please sign in to comment.