bugfix: add default host config if not set
If there is not specific host config, like ctr does, the resolver will fail to get host path. And this patch is to add default host config if needs. And default config host config should have all caps for pull and push. Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
parent
fe7bfffbf4
commit
d9a1c3f9e4
@ -88,21 +88,20 @@ func ConfigureHosts(ctx context.Context, options HostOptions) docker.RegistryHos
|
|||||||
if hosts == nil {
|
if hosts == nil {
|
||||||
hosts = make([]hostConfig, 1)
|
hosts = make([]hostConfig, 1)
|
||||||
}
|
}
|
||||||
if len(hosts) > 1 {
|
if len(hosts) >= 1 && hosts[len(hosts)-1].host == "" {
|
||||||
if hosts[len(hosts)-1].host == "" {
|
if host == "docker.io" {
|
||||||
if host == "docker.io" {
|
hosts[len(hosts)-1].scheme = "https"
|
||||||
hosts[len(hosts)-1].scheme = "https"
|
hosts[len(hosts)-1].host = "registry-1.docker.io"
|
||||||
hosts[len(hosts)-1].host = "https://registry-1.docker.io"
|
} else {
|
||||||
|
hosts[len(hosts)-1].host = host
|
||||||
|
if options.DefaultScheme != "" {
|
||||||
|
hosts[len(hosts)-1].scheme = options.DefaultScheme
|
||||||
} else {
|
} else {
|
||||||
hosts[len(hosts)-1].host = host
|
hosts[len(hosts)-1].scheme = "https"
|
||||||
if options.DefaultScheme != "" {
|
|
||||||
hosts[len(hosts)-1].scheme = options.DefaultScheme
|
|
||||||
} else {
|
|
||||||
hosts[len(hosts)-1].scheme = "https"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
hosts[len(hosts)-1].path = "/v2"
|
|
||||||
}
|
}
|
||||||
|
hosts[len(hosts)-1].path = "/v2"
|
||||||
|
hosts[len(hosts)-1].capabilities = docker.HostCapabilityPull | docker.HostCapabilityResolve | docker.HostCapabilityPush
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultTransport := &http.Transport{
|
defaultTransport := &http.Transport{
|
||||||
|
Loading…
Reference in New Issue
Block a user