mirror of https://github.com/docker/cli.git
internal/registry: remove PingResponseError
It's not matched anywhere, so we can just return a plain error. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
7cf245d2f7
commit
dad2e67860
|
|
@ -127,29 +127,19 @@ func v2AuthHTTPClient(endpoint *url.URL, authTransport http.RoundTripper, modifi
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PingResponseError is used when the response from a ping
|
|
||||||
// was received but invalid.
|
|
||||||
type PingResponseError struct {
|
|
||||||
Err error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (err PingResponseError) Error() string {
|
|
||||||
return err.Err.Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// PingV2Registry attempts to ping a v2 registry and on success return a
|
// PingV2Registry attempts to ping a v2 registry and on success return a
|
||||||
// challenge manager for the supported authentication types.
|
// challenge manager for the supported authentication types.
|
||||||
// If a response is received but cannot be interpreted, a PingResponseError will be returned.
|
// If a response is received but cannot be interpreted, a PingResponseError will be returned.
|
||||||
func PingV2Registry(endpoint *url.URL, authTransport http.RoundTripper) (challenge.Manager, error) {
|
func PingV2Registry(endpoint *url.URL, authTransport http.RoundTripper) (challenge.Manager, error) {
|
||||||
pingClient := &http.Client{
|
|
||||||
Transport: authTransport,
|
|
||||||
Timeout: 15 * time.Second,
|
|
||||||
}
|
|
||||||
endpointStr := strings.TrimRight(endpoint.String(), "/") + "/v2/"
|
endpointStr := strings.TrimRight(endpoint.String(), "/") + "/v2/"
|
||||||
req, err := http.NewRequest(http.MethodGet, endpointStr, http.NoBody)
|
req, err := http.NewRequest(http.MethodGet, endpointStr, http.NoBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
pingClient := &http.Client{
|
||||||
|
Transport: authTransport,
|
||||||
|
Timeout: 15 * time.Second,
|
||||||
|
}
|
||||||
resp, err := pingClient.Do(req)
|
resp, err := pingClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -158,9 +148,7 @@ func PingV2Registry(endpoint *url.URL, authTransport http.RoundTripper) (challen
|
||||||
|
|
||||||
challengeManager := challenge.NewSimpleManager()
|
challengeManager := challenge.NewSimpleManager()
|
||||||
if err := challengeManager.AddResponse(resp); err != nil {
|
if err := challengeManager.AddResponse(resp); err != nil {
|
||||||
return nil, PingResponseError{
|
return nil, err
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return challengeManager, nil
|
return challengeManager, nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue