Skip to content

Commit 6849394

Browse files
authored
pkg/registry: export RedirectError (#2177)
Custom BlobStatHandler implementations need access to this error. Otherwise it's impossible for them to signal redirects.
1 parent ebd9e4a commit 6849394

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

pkg/registry/blobs.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type BlobHandler interface {
5959
// backend that can serve metadata about blobs.
6060
type BlobStatHandler interface {
6161
// Stat returns the size of the blob, or errNotFound if the blob wasn't
62-
// found, or redirectError if the blob can be found elsewhere.
62+
// found, or RedirectError if the blob can be found elsewhere.
6363
Stat(ctx context.Context, repo string, h v1.Hash) (int64, error)
6464
}
6565

@@ -82,10 +82,10 @@ type BlobDeleteHandler interface {
8282
Delete(ctx context.Context, repo string, h v1.Hash) error
8383
}
8484

85-
// redirectError represents a signal that the blob handler doesn't have the blob
85+
// RedirectError represents a signal that the blob handler doesn't have the blob
8686
// contents, but that those contents are at another location which registry
8787
// clients should redirect to.
88-
type redirectError struct {
88+
type RedirectError struct {
8989
// Location is the location to find the contents.
9090
Location string
9191

@@ -101,7 +101,7 @@ func (r *bytesCloser) Close() error {
101101
return nil
102102
}
103103

104-
func (e redirectError) Error() string { return fmt.Sprintf("redirecting (%d): %s", e.Code, e.Location) }
104+
func (e RedirectError) Error() string { return fmt.Sprintf("redirecting (%d): %s", e.Code, e.Location) }
105105

106106
// ErrNotFound represents an error locating the blob.
107107
var ErrNotFound = errors.New("not found")
@@ -209,7 +209,7 @@ func (b *blobs) handle(resp http.ResponseWriter, req *http.Request) *regError {
209209
if errors.Is(err, ErrNotFound) {
210210
return regErrBlobUnknown
211211
} else if err != nil {
212-
var rerr redirectError
212+
var rerr RedirectError
213213
if errors.As(err, &rerr) {
214214
http.Redirect(resp, req, rerr.Location, rerr.Code)
215215
return nil
@@ -221,7 +221,7 @@ func (b *blobs) handle(resp http.ResponseWriter, req *http.Request) *regError {
221221
if errors.Is(err, ErrNotFound) {
222222
return regErrBlobUnknown
223223
} else if err != nil {
224-
var rerr redirectError
224+
var rerr RedirectError
225225
if errors.As(err, &rerr) {
226226
http.Redirect(resp, req, rerr.Location, rerr.Code)
227227
return nil
@@ -257,7 +257,7 @@ func (b *blobs) handle(resp http.ResponseWriter, req *http.Request) *regError {
257257
if errors.Is(err, ErrNotFound) {
258258
return regErrBlobUnknown
259259
} else if err != nil {
260-
var rerr redirectError
260+
var rerr RedirectError
261261
if errors.As(err, &rerr) {
262262
http.Redirect(resp, req, rerr.Location, rerr.Code)
263263
return nil
@@ -269,7 +269,7 @@ func (b *blobs) handle(resp http.ResponseWriter, req *http.Request) *regError {
269269
if errors.Is(err, ErrNotFound) {
270270
return regErrBlobUnknown
271271
} else if err != nil {
272-
var rerr redirectError
272+
var rerr RedirectError
273273
if errors.As(err, &rerr) {
274274
http.Redirect(resp, req, rerr.Location, rerr.Code)
275275
return nil
@@ -286,7 +286,7 @@ func (b *blobs) handle(resp http.ResponseWriter, req *http.Request) *regError {
286286
if errors.Is(err, ErrNotFound) {
287287
return regErrBlobUnknown
288288
} else if err != nil {
289-
var rerr redirectError
289+
var rerr RedirectError
290290
if errors.As(err, &rerr) {
291291
http.Redirect(resp, req, rerr.Location, rerr.Code)
292292
return nil

0 commit comments

Comments
 (0)