From dad2e67860ee4685e46a4664457d071de5b5ec86 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 24 Jul 2025 18:49:43 +0200 Subject: [PATCH] internal/registry: remove PingResponseError It's not matched anywhere, so we can just return a plain error. Signed-off-by: Sebastiaan van Stijn --- internal/registry/auth.go | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/internal/registry/auth.go b/internal/registry/auth.go index 72192e5ad7..be6f2c2c74 100644 --- a/internal/registry/auth.go +++ b/internal/registry/auth.go @@ -127,29 +127,19 @@ func v2AuthHTTPClient(endpoint *url.URL, authTransport http.RoundTripper, modifi }, 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 // challenge manager for the supported authentication types. // 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) { - pingClient := &http.Client{ - Transport: authTransport, - Timeout: 15 * time.Second, - } endpointStr := strings.TrimRight(endpoint.String(), "/") + "/v2/" req, err := http.NewRequest(http.MethodGet, endpointStr, http.NoBody) if err != nil { return nil, err } + pingClient := &http.Client{ + Transport: authTransport, + Timeout: 15 * time.Second, + } resp, err := pingClient.Do(req) if err != nil { return nil, err @@ -158,9 +148,7 @@ func PingV2Registry(endpoint *url.URL, authTransport http.RoundTripper) (challen challengeManager := challenge.NewSimpleManager() if err := challengeManager.AddResponse(resp); err != nil { - return nil, PingResponseError{ - Err: err, - } + return nil, err } return challengeManager, nil