daemon: fix mirrors validation
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com> (cherry picked from commit 1a0f04e08e2f23a12b8dd2deb7c10c7f4f7d8804) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 5dab6096fb7fcfe94acd9145b24eda8640427bb5 Component: engine
This commit is contained in:
committed by
Sebastiaan van Stijn
parent
d5e6ddb355
commit
41f6c45376
@ -11,6 +11,7 @@ import (
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@ -157,15 +158,18 @@ func (daemon *Daemon) NewResolveOptionsFunc() resolver.ResolveOptionsFunc {
|
||||
)
|
||||
// must trim "https://" or "http://" prefix
|
||||
for i, v := range daemon.configStore.Mirrors {
|
||||
v = strings.TrimPrefix(v, "https://")
|
||||
v = strings.TrimPrefix(v, "http://")
|
||||
if uri, err := url.Parse(v); err == nil {
|
||||
v = uri.Host
|
||||
}
|
||||
mirrors[i] = v
|
||||
}
|
||||
// set "registry-mirrors"
|
||||
m[registryKey] = resolver.RegistryConf{Mirrors: mirrors}
|
||||
// set "insecure-registries"
|
||||
for _, v := range daemon.configStore.InsecureRegistries {
|
||||
v = strings.TrimPrefix(v, "http://")
|
||||
if uri, err := url.Parse(v); err == nil {
|
||||
v = uri.Host
|
||||
}
|
||||
m[v] = resolver.RegistryConf{
|
||||
PlainHTTP: true,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user