From 2287f1c42f6fa086ea0d1e120f838395f7cd6d74 Mon Sep 17 00:00:00 2001 From: Richard Scothern Date: Thu, 21 Jul 2016 17:16:47 -0700 Subject: [PATCH] Fix the build. Pass the manifestURL directly into the schema2 manifest handler instead of accessing through the repository as it has since the reference is now an interface. Signed-off-by: Richard Scothern --- registry/storage/registry.go | 18 +++++++++++------- registry/storage/schema2manifesthandler.go | 14 +++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/registry/storage/registry.go b/registry/storage/registry.go index a480f70cb..20525ffb3 100644 --- a/registry/storage/registry.go +++ b/registry/storage/registry.go @@ -22,10 +22,13 @@ type registry struct { resumableDigestEnabled bool schema1SigningKey libtrust.PrivateKey blobDescriptorServiceFactory distribution.BlobDescriptorServiceFactory - manifestURLs struct { - allow *regexp.Regexp - deny *regexp.Regexp - } + manifestURLs manifestURLs +} + +// manifestURLs holds regular expressions for controlling manifest URL whitelisting +type manifestURLs struct { + allow *regexp.Regexp + deny *regexp.Regexp } // RegistryOption is the type used for functional options for NewRegistry. @@ -245,9 +248,10 @@ func (repo *repository) Manifests(ctx context.Context, options ...distribution.M blobStore: blobStore, }, schema2Handler: &schema2ManifestHandler{ - ctx: ctx, - repository: repo, - blobStore: blobStore, + ctx: ctx, + repository: repo, + blobStore: blobStore, + manifestURLs: repo.registry.manifestURLs, }, manifestListHandler: &manifestListHandler{ ctx: ctx, diff --git a/registry/storage/schema2manifesthandler.go b/registry/storage/schema2manifesthandler.go index e72cd672e..1d221410e 100644 --- a/registry/storage/schema2manifesthandler.go +++ b/registry/storage/schema2manifesthandler.go @@ -1,12 +1,11 @@ package storage import ( + "encoding/json" "errors" "fmt" "net/url" - "encoding/json" - "github.com/docker/distribution" "github.com/docker/distribution/context" "github.com/docker/distribution/digest" @@ -21,9 +20,10 @@ var ( //schema2ManifestHandler is a ManifestHandler that covers schema2 manifests. type schema2ManifestHandler struct { - repository distribution.Repository - blobStore distribution.BlobStore - ctx context.Context + repository distribution.Repository + blobStore distribution.BlobStore + ctx context.Context + manifestURLs manifestURLs } var _ ManifestHandler = &schema2ManifestHandler{} @@ -97,8 +97,8 @@ func (ms *schema2ManifestHandler) verifyManifest(ctx context.Context, mnfst sche if len(fsLayer.URLs) == 0 { err = errMissingURL } - allow := ms.repository.manifestURLs.allow - deny := ms.repository.manifestURLs.deny + allow := ms.manifestURLs.allow + deny := ms.manifestURLs.deny for _, u := range fsLayer.URLs { var pu *url.URL pu, err = url.Parse(u)