From a1cfd267c8ff193d8b6a00a9c83a56faa346f89c Mon Sep 17 00:00:00 2001 From: MATSUMOTO TAKEAKI Date: Fri, 17 Jul 2020 13:58:06 +0900 Subject: [PATCH] Make redirect middleware can use path Signed-off-by: MATSUMOTO TAKEAKI --- registry/storage/driver/middleware/redirect/middleware.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/registry/storage/driver/middleware/redirect/middleware.go b/registry/storage/driver/middleware/redirect/middleware.go index 8f63674c6..dca6584a3 100644 --- a/registry/storage/driver/middleware/redirect/middleware.go +++ b/registry/storage/driver/middleware/redirect/middleware.go @@ -13,6 +13,7 @@ type redirectStorageMiddleware struct { storagedriver.StorageDriver scheme string host string + path string } var _ storagedriver.StorageDriver = &redirectStorageMiddleware{} @@ -37,10 +38,13 @@ func newRedirectStorageMiddleware(sd storagedriver.StorageDriver, options map[st return nil, fmt.Errorf("no host specified for redirect baseurl") } - return &redirectStorageMiddleware{StorageDriver: sd, scheme: u.Scheme, host: u.Host}, nil + return &redirectStorageMiddleware{StorageDriver: sd, scheme: u.Scheme, host: u.Host, path: u.Path}, nil } func (r *redirectStorageMiddleware) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) { + if r.path != "" { + path = r.path + path + } u := &url.URL{Scheme: r.scheme, Host: r.host, Path: path} return u.String(), nil }