Add test for default setup for host configuration

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2020-04-06 14:36:15 -07:00
parent d9a1c3f9e4
commit 067aba732e
2 changed files with 64 additions and 3 deletions

View File

@@ -74,6 +74,7 @@ func ConfigureHosts(ctx context.Context, options HostOptions) docker.RegistryHos
return nil, err
}
if dir != "" {
log.G(ctx).WithField("dir", dir).Debug("loading host directory")
hosts, err = loadHostDir(ctx, dir)
if err != nil {
return nil, err
@@ -88,7 +89,7 @@ func ConfigureHosts(ctx context.Context, options HostOptions) docker.RegistryHos
if hosts == nil {
hosts = make([]hostConfig, 1)
}
if len(hosts) >= 1 && hosts[len(hosts)-1].host == "" {
if len(hosts) > 0 && hosts[len(hosts)-1].host == "" {
if host == "docker.io" {
hosts[len(hosts)-1].scheme = "https"
hosts[len(hosts)-1].host = "registry-1.docker.io"