Skip to content

Commit dad2e67

Browse files
committed
internal/registry: remove PingResponseError
It's not matched anywhere, so we can just return a plain error. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 7cf245d commit dad2e67

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

internal/registry/auth.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,29 +127,19 @@ func v2AuthHTTPClient(endpoint *url.URL, authTransport http.RoundTripper, modifi
127127
}, nil
128128
}
129129

130-
// PingResponseError is used when the response from a ping
131-
// was received but invalid.
132-
type PingResponseError struct {
133-
Err error
134-
}
135-
136-
func (err PingResponseError) Error() string {
137-
return err.Err.Error()
138-
}
139-
140130
// PingV2Registry attempts to ping a v2 registry and on success return a
141131
// challenge manager for the supported authentication types.
142132
// If a response is received but cannot be interpreted, a PingResponseError will be returned.
143133
func PingV2Registry(endpoint *url.URL, authTransport http.RoundTripper) (challenge.Manager, error) {
144-
pingClient := &http.Client{
145-
Transport: authTransport,
146-
Timeout: 15 * time.Second,
147-
}
148134
endpointStr := strings.TrimRight(endpoint.String(), "/") + "/v2/"
149135
req, err := http.NewRequest(http.MethodGet, endpointStr, http.NoBody)
150136
if err != nil {
151137
return nil, err
152138
}
139+
pingClient := &http.Client{
140+
Transport: authTransport,
141+
Timeout: 15 * time.Second,
142+
}
153143
resp, err := pingClient.Do(req)
154144
if err != nil {
155145
return nil, err
@@ -158,9 +148,7 @@ func PingV2Registry(endpoint *url.URL, authTransport http.RoundTripper) (challen
158148

159149
challengeManager := challenge.NewSimpleManager()
160150
if err := challengeManager.AddResponse(resp); err != nil {
161-
return nil, PingResponseError{
162-
Err: err,
163-
}
151+
return nil, err
164152
}
165153

166154
return challengeManager, nil

0 commit comments

Comments
 (0)