1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

registry: inline newV1Endpoint() into newV1EndpointFromStr()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-10-05 20:49:33 +02:00
parent c8754f44d7
commit 542edf0c21
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -34,7 +34,8 @@ func NewV1Endpoint(index *registrytypes.IndexInfo, userAgent string, metaHeaders
return nil, err
}
if err := validateEndpoint(endpoint); err != nil {
err = validateEndpoint(endpoint)
if err != nil {
return nil, err
}
@ -68,20 +69,6 @@ func validateEndpoint(endpoint *V1Endpoint) error {
return nil
}
func newV1Endpoint(address url.URL, tlsConfig *tls.Config, userAgent string, metaHeaders http.Header) *V1Endpoint {
endpoint := &V1Endpoint{
IsSecure: tlsConfig == nil || !tlsConfig.InsecureSkipVerify,
URL: new(url.URL),
}
*endpoint.URL = address
// TODO(tiborvass): make sure a ConnectTimeout transport is used
tr := NewTransport(tlsConfig)
endpoint.client = HTTPClient(transport.NewTransport(tr, Headers(userAgent, metaHeaders)...))
return endpoint
}
// trimV1Address trims the version off the address and returns the
// trimmed address or an error if there is a non-V1 version.
func trimV1Address(address string) (string, error) {
@ -124,9 +111,14 @@ func newV1EndpointFromStr(address string, tlsConfig *tls.Config, userAgent strin
return nil, err
}
endpoint := newV1Endpoint(*uri, tlsConfig, userAgent, metaHeaders)
// TODO(tiborvass): make sure a ConnectTimeout transport is used
tr := NewTransport(tlsConfig)
return endpoint, nil
return &V1Endpoint{
IsSecure: tlsConfig == nil || !tlsConfig.InsecureSkipVerify,
URL: uri,
client: HTTPClient(transport.NewTransport(tr, Headers(userAgent, metaHeaders)...)),
}, nil
}
// Get the formatted URL for the root of this registry Endpoint