Fix nil pointer errors
Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
parent
4e08c2de67
commit
06b0cd45ba
@ -105,6 +105,13 @@ func ConfigureHosts(ctx context.Context, options HostOptions) docker.RegistryHos
|
|||||||
hosts[len(hosts)-1].capabilities = docker.HostCapabilityPull | docker.HostCapabilityResolve | docker.HostCapabilityPush
|
hosts[len(hosts)-1].capabilities = docker.HostCapabilityPull | docker.HostCapabilityResolve | docker.HostCapabilityPush
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var defaultTLSConfig *tls.Config
|
||||||
|
if options.DefaultTLS != nil {
|
||||||
|
defaultTLSConfig = options.DefaultTLS
|
||||||
|
} else {
|
||||||
|
defaultTLSConfig = &tls.Config{}
|
||||||
|
}
|
||||||
|
|
||||||
defaultTransport := &http.Transport{
|
defaultTransport := &http.Transport{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
DialContext: (&net.Dialer{
|
DialContext: (&net.Dialer{
|
||||||
@ -115,7 +122,7 @@ func ConfigureHosts(ctx context.Context, options HostOptions) docker.RegistryHos
|
|||||||
MaxIdleConns: 10,
|
MaxIdleConns: 10,
|
||||||
IdleConnTimeout: 30 * time.Second,
|
IdleConnTimeout: 30 * time.Second,
|
||||||
TLSHandshakeTimeout: 10 * time.Second,
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
TLSClientConfig: options.DefaultTLS,
|
TLSClientConfig: defaultTLSConfig,
|
||||||
ExpectContinueTimeout: 5 * time.Second,
|
ExpectContinueTimeout: 5 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,12 +145,8 @@ func ConfigureHosts(ctx context.Context, options HostOptions) docker.RegistryHos
|
|||||||
rhosts[i].Capabilities = host.capabilities
|
rhosts[i].Capabilities = host.capabilities
|
||||||
|
|
||||||
if host.caCerts != nil || host.clientPairs != nil || host.skipVerify != nil {
|
if host.caCerts != nil || host.clientPairs != nil || host.skipVerify != nil {
|
||||||
var tlsConfig *tls.Config
|
tr := defaultTransport.Clone()
|
||||||
if options.DefaultTLS != nil {
|
tlsConfig := tr.TLSClientConfig
|
||||||
tlsConfig = options.DefaultTLS.Clone()
|
|
||||||
} else {
|
|
||||||
tlsConfig = &tls.Config{}
|
|
||||||
}
|
|
||||||
if host.skipVerify != nil {
|
if host.skipVerify != nil {
|
||||||
tlsConfig.InsecureSkipVerify = *host.skipVerify
|
tlsConfig.InsecureSkipVerify = *host.skipVerify
|
||||||
}
|
}
|
||||||
@ -190,8 +193,7 @@ func ConfigureHosts(ctx context.Context, options HostOptions) docker.RegistryHos
|
|||||||
tlsConfig.Certificates = append(tlsConfig.Certificates, cert)
|
tlsConfig.Certificates = append(tlsConfig.Certificates, cert)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tr := defaultTransport.Clone()
|
|
||||||
tr.TLSClientConfig = tlsConfig
|
|
||||||
c := *client
|
c := *client
|
||||||
c.Transport = tr
|
c.Transport = tr
|
||||||
|
|
||||||
@ -306,6 +308,9 @@ func parseHostsFile(ctx context.Context, baseDir string, b []byte) ([]hostConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.HostConfigs == nil {
|
||||||
|
c.HostConfigs = map[string]hostFileConfig{}
|
||||||
|
}
|
||||||
if c.Server != "" {
|
if c.Server != "" {
|
||||||
c.HostConfigs[c.Server] = c.hostFileConfig
|
c.HostConfigs[c.Server] = c.hostFileConfig
|
||||||
orderedHosts = append(orderedHosts, c.Server)
|
orderedHosts = append(orderedHosts, c.Server)
|
||||||
|
Loading…
Reference in New Issue
Block a user