diff --git a/hack/vendor.sh b/hack/vendor.sh index c41b917d..502d53dc 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -10,7 +10,7 @@ clone git github.com/Sirupsen/logrus v0.8.7 # logrus is a common dependency amon clone git github.com/docker/docker master clone git golang.org/x/net master https://github.com/golang/net.git clone git github.com/docker/engine-api master -clone git github.com/docker/distribution master +clone git github.com/docker/distribution v2.3.0-rc.1 clone git github.com/docker/go-connections master clone git github.com/docker/go-units master clone git github.com/docker/libtrust master diff --git a/vendor/github.com/docker/distribution/manifest/schema1/config_builder.go b/vendor/github.com/docker/distribution/manifest/schema1/config_builder.go index b3d1e554..e9fe81be 100644 --- a/vendor/github.com/docker/distribution/manifest/schema1/config_builder.go +++ b/vendor/github.com/docker/distribution/manifest/schema1/config_builder.go @@ -9,7 +9,6 @@ import ( "github.com/docker/distribution" "github.com/docker/distribution/context" - "github.com/docker/distribution/reference" "github.com/docker/libtrust" "github.com/docker/distribution/digest" @@ -40,8 +39,10 @@ type configManifestBuilder struct { // configJSON is configuration supplied when the ManifestBuilder was // created. configJSON []byte - // ref contains the name and optional tag provided to NewConfigManifestBuilder. - ref reference.Named + // name is the name provided to NewConfigManifestBuilder + name string + // tag is the tag provided to NewConfigManifestBuilder + tag string // descriptors is the set of descriptors referencing the layers. descriptors []distribution.Descriptor // emptyTarDigest is set to a valid digest if an empty tar has been @@ -53,12 +54,13 @@ type configManifestBuilder struct { // schema version from an image configuration and a set of descriptors. // It takes a BlobService so that it can add an empty tar to the blob store // if the resulting manifest needs empty layers. -func NewConfigManifestBuilder(bs distribution.BlobService, pk libtrust.PrivateKey, ref reference.Named, configJSON []byte) distribution.ManifestBuilder { +func NewConfigManifestBuilder(bs distribution.BlobService, pk libtrust.PrivateKey, name, tag string, configJSON []byte) distribution.ManifestBuilder { return &configManifestBuilder{ bs: bs, pk: pk, configJSON: configJSON, - ref: ref, + name: name, + tag: tag, } } @@ -188,17 +190,12 @@ func (mb *configManifestBuilder) Build(ctx context.Context) (m distribution.Mani history[0].V1Compatibility = string(transformedConfig) - tag := "" - if tagged, isTagged := mb.ref.(reference.Tagged); isTagged { - tag = tagged.Tag() - } - mfst := Manifest{ Versioned: manifest.Versioned{ SchemaVersion: 1, }, - Name: mb.ref.Name(), - Tag: tag, + Name: mb.name, + Tag: mb.tag, Architecture: img.Architecture, FSLayers: fsLayerList, History: history, diff --git a/vendor/github.com/docker/distribution/manifest/schema1/reference_builder.go b/vendor/github.com/docker/distribution/manifest/schema1/reference_builder.go index fc1045f9..36209e34 100644 --- a/vendor/github.com/docker/distribution/manifest/schema1/reference_builder.go +++ b/vendor/github.com/docker/distribution/manifest/schema1/reference_builder.go @@ -8,7 +8,6 @@ import ( "github.com/docker/distribution/context" "github.com/docker/distribution/digest" "github.com/docker/distribution/manifest" - "github.com/docker/distribution/reference" "github.com/docker/libtrust" ) @@ -21,18 +20,13 @@ type referenceManifestBuilder struct { // NewReferenceManifestBuilder is used to build new manifests for the current // schema version using schema1 dependencies. -func NewReferenceManifestBuilder(pk libtrust.PrivateKey, ref reference.Named, architecture string) distribution.ManifestBuilder { - tag := "" - if tagged, isTagged := ref.(reference.Tagged); isTagged { - tag = tagged.Tag() - } - +func NewReferenceManifestBuilder(pk libtrust.PrivateKey, name, tag, architecture string) distribution.ManifestBuilder { return &referenceManifestBuilder{ Manifest: Manifest{ Versioned: manifest.Versioned{ SchemaVersion: 1, }, - Name: ref.Name(), + Name: name, Tag: tag, Architecture: architecture, }, diff --git a/vendor/github.com/docker/distribution/manifests.go b/vendor/github.com/docker/distribution/manifests.go index 1acb0500..222916b8 100644 --- a/vendor/github.com/docker/distribution/manifests.go +++ b/vendor/github.com/docker/distribution/manifests.go @@ -2,7 +2,7 @@ package distribution import ( "fmt" - "mime" + "strings" "github.com/docker/distribution/context" "github.com/docker/distribution/digest" @@ -84,23 +84,19 @@ var mappings = make(map[string]UnmarshalFunc, 0) // UnmarshalManifest looks up manifest unmarshall functions based on // MediaType func UnmarshalManifest(ctHeader string, p []byte) (Manifest, Descriptor, error) { - // Need to look up by the actual media type, not the raw contents of + // Need to look up by the actual content type, not the raw contents of // the header. Strip semicolons and anything following them. var mediatype string - if ctHeader != "" { - var err error - mediatype, _, err = mime.ParseMediaType(ctHeader) - if err != nil { - return nil, Descriptor{}, err - } + semicolonIndex := strings.Index(ctHeader, ";") + if semicolonIndex != -1 { + mediatype = ctHeader[:semicolonIndex] + } else { + mediatype = ctHeader } unmarshalFunc, ok := mappings[mediatype] if !ok { - unmarshalFunc, ok = mappings[""] - if !ok { - return nil, Descriptor{}, fmt.Errorf("unsupported manifest mediatype and no default available: %s", mediatype) - } + return nil, Descriptor{}, fmt.Errorf("unsupported manifest mediatype: %s", mediatype) } return unmarshalFunc(p) diff --git a/vendor/github.com/docker/distribution/registry.go b/vendor/github.com/docker/distribution/registry.go index dcb35c37..ce5d7779 100644 --- a/vendor/github.com/docker/distribution/registry.go +++ b/vendor/github.com/docker/distribution/registry.go @@ -2,7 +2,6 @@ package distribution import ( "github.com/docker/distribution/context" - "github.com/docker/distribution/reference" ) // Scope defines the set of items that match a namespace. @@ -33,7 +32,7 @@ type Namespace interface { // Repository should return a reference to the named repository. The // registry may or may not have the repository but should always return a // reference. - Repository(ctx context.Context, name reference.Named) (Repository, error) + Repository(ctx context.Context, name string) (Repository, error) // Repositories fills 'repos' with a lexigraphically sorted catalog of repositories // up to the size of 'repos' and returns the value 'n' for the number of entries @@ -50,7 +49,7 @@ type ManifestServiceOption interface { // Repository is a named collection of manifests and layers. type Repository interface { // Name returns the name of the repository. - Name() reference.Named + Name() string // Manifests returns a reference to this repository's manifest service. // with the supplied options applied. diff --git a/vendor/github.com/docker/distribution/registry/api/v2/urls.go b/vendor/github.com/docker/distribution/registry/api/v2/urls.go index 408c7b74..6ba39cc9 100644 --- a/vendor/github.com/docker/distribution/registry/api/v2/urls.go +++ b/vendor/github.com/docker/distribution/registry/api/v2/urls.go @@ -5,7 +5,7 @@ import ( "net/url" "strings" - "github.com/docker/distribution/reference" + "github.com/docker/distribution/digest" "github.com/gorilla/mux" ) @@ -113,10 +113,10 @@ func (ub *URLBuilder) BuildCatalogURL(values ...url.Values) (string, error) { } // BuildTagsURL constructs a url to list the tags in the named repository. -func (ub *URLBuilder) BuildTagsURL(name reference.Named) (string, error) { +func (ub *URLBuilder) BuildTagsURL(name string) (string, error) { route := ub.cloneRoute(RouteNameTags) - tagsURL, err := route.URL("name", name.Name()) + tagsURL, err := route.URL("name", name) if err != nil { return "", err } @@ -126,18 +126,10 @@ func (ub *URLBuilder) BuildTagsURL(name reference.Named) (string, error) { // BuildManifestURL constructs a url for the manifest identified by name and // reference. The argument reference may be either a tag or digest. -func (ub *URLBuilder) BuildManifestURL(ref reference.Named) (string, error) { +func (ub *URLBuilder) BuildManifestURL(name, reference string) (string, error) { route := ub.cloneRoute(RouteNameManifest) - tagOrDigest := "" - switch v := ref.(type) { - case reference.Tagged: - tagOrDigest = v.Tag() - case reference.Digested: - tagOrDigest = v.Digest().String() - } - - manifestURL, err := route.URL("name", ref.Name(), "reference", tagOrDigest) + manifestURL, err := route.URL("name", name, "reference", reference) if err != nil { return "", err } @@ -146,10 +138,10 @@ func (ub *URLBuilder) BuildManifestURL(ref reference.Named) (string, error) { } // BuildBlobURL constructs the url for the blob identified by name and dgst. -func (ub *URLBuilder) BuildBlobURL(ref reference.Canonical) (string, error) { +func (ub *URLBuilder) BuildBlobURL(name string, dgst digest.Digest) (string, error) { route := ub.cloneRoute(RouteNameBlob) - layerURL, err := route.URL("name", ref.Name(), "digest", ref.Digest().String()) + layerURL, err := route.URL("name", name, "digest", dgst.String()) if err != nil { return "", err } @@ -159,10 +151,10 @@ func (ub *URLBuilder) BuildBlobURL(ref reference.Canonical) (string, error) { // BuildBlobUploadURL constructs a url to begin a blob upload in the // repository identified by name. -func (ub *URLBuilder) BuildBlobUploadURL(name reference.Named, values ...url.Values) (string, error) { +func (ub *URLBuilder) BuildBlobUploadURL(name string, values ...url.Values) (string, error) { route := ub.cloneRoute(RouteNameBlobUpload) - uploadURL, err := route.URL("name", name.Name()) + uploadURL, err := route.URL("name", name) if err != nil { return "", err } @@ -174,10 +166,10 @@ func (ub *URLBuilder) BuildBlobUploadURL(name reference.Named, values ...url.Val // including any url values. This should generally not be used by clients, as // this url is provided by server implementations during the blob upload // process. -func (ub *URLBuilder) BuildBlobUploadChunkURL(name reference.Named, uuid string, values ...url.Values) (string, error) { +func (ub *URLBuilder) BuildBlobUploadChunkURL(name, uuid string, values ...url.Values) (string, error) { route := ub.cloneRoute(RouteNameBlobUploadChunk) - uploadURL, err := route.URL("name", name.Name(), "uuid", uuid) + uploadURL, err := route.URL("name", name, "uuid", uuid) if err != nil { return "", err } diff --git a/vendor/github.com/docker/distribution/registry/client/repository.go b/vendor/github.com/docker/distribution/registry/client/repository.go index 1f777add..d6521211 100644 --- a/vendor/github.com/docker/distribution/registry/client/repository.go +++ b/vendor/github.com/docker/distribution/registry/client/repository.go @@ -98,7 +98,11 @@ func (r *registry) Repositories(ctx context.Context, entries []string, last stri } // NewRepository creates a new Repository for the given repository name and base URL. -func NewRepository(ctx context.Context, name reference.Named, baseURL string, transport http.RoundTripper) (distribution.Repository, error) { +func NewRepository(ctx context.Context, name, baseURL string, transport http.RoundTripper) (distribution.Repository, error) { + if _, err := reference.ParseNamed(name); err != nil { + return nil, err + } + ub, err := v2.NewURLBuilderFromString(baseURL) if err != nil { return nil, err @@ -121,21 +125,21 @@ type repository struct { client *http.Client ub *v2.URLBuilder context context.Context - name reference.Named + name string } -func (r *repository) Name() reference.Named { +func (r *repository) Name() string { return r.name } func (r *repository) Blobs(ctx context.Context) distribution.BlobStore { statter := &blobStatter{ - name: r.name, + name: r.Name(), ub: r.ub, client: r.client, } return &blobs{ - name: r.name, + name: r.Name(), ub: r.ub, client: r.client, statter: cache.NewCachedBlobStatter(memory.NewInMemoryBlobDescriptorCacheProvider(), statter), @@ -145,7 +149,7 @@ func (r *repository) Blobs(ctx context.Context) distribution.BlobStore { func (r *repository) Manifests(ctx context.Context, options ...distribution.ManifestServiceOption) (distribution.ManifestService, error) { // todo(richardscothern): options should be sent over the wire return &manifests{ - name: r.name, + name: r.Name(), ub: r.ub, client: r.client, etags: make(map[string]string), @@ -166,7 +170,7 @@ type tags struct { client *http.Client ub *v2.URLBuilder context context.Context - name reference.Named + name string } // All returns all tags @@ -249,11 +253,7 @@ func descriptorFromResponse(response *http.Response) (distribution.Descriptor, e // to construct a descriptor for the tag. If the registry doesn't support HEADing // a manifest, fallback to GET. func (t *tags) Get(ctx context.Context, tag string) (distribution.Descriptor, error) { - ref, err := reference.WithTag(t.name, tag) - if err != nil { - return distribution.Descriptor{}, err - } - u, err := t.ub.BuildManifestURL(ref) + u, err := t.ub.BuildManifestURL(t.name, tag) if err != nil { return distribution.Descriptor{}, err } @@ -293,18 +293,14 @@ func (t *tags) Untag(ctx context.Context, tag string) error { } type manifests struct { - name reference.Named + name string ub *v2.URLBuilder client *http.Client etags map[string]string } func (ms *manifests) Exists(ctx context.Context, dgst digest.Digest) (bool, error) { - ref, err := reference.WithDigest(ms.name, dgst) - if err != nil { - return false, err - } - u, err := ms.ub.BuildManifestURL(ref) + u, err := ms.ub.BuildManifestURL(ms.name, dgst.String()) if err != nil { return false, err } @@ -341,19 +337,11 @@ func (o etagOption) Apply(ms distribution.ManifestService) error { } func (ms *manifests) Get(ctx context.Context, dgst digest.Digest, options ...distribution.ManifestServiceOption) (distribution.Manifest, error) { - var ( - digestOrTag string - ref reference.Named - err error - ) + var tag string for _, option := range options { if opt, ok := option.(withTagOption); ok { - digestOrTag = opt.tag - ref, err = reference.WithTag(ms.name, opt.tag) - if err != nil { - return nil, err - } + tag = opt.tag } else { err := option.Apply(ms) if err != nil { @@ -362,15 +350,14 @@ func (ms *manifests) Get(ctx context.Context, dgst digest.Digest, options ...dis } } - if digestOrTag == "" { - digestOrTag = dgst.String() - ref, err = reference.WithDigest(ms.name, dgst) - if err != nil { - return nil, err - } + var ref string + if tag != "" { + ref = tag + } else { + ref = dgst.String() } - u, err := ms.ub.BuildManifestURL(ref) + u, err := ms.ub.BuildManifestURL(ms.name, ref) if err != nil { return nil, err } @@ -384,8 +371,8 @@ func (ms *manifests) Get(ctx context.Context, dgst digest.Digest, options ...dis req.Header.Add("Accept", t) } - if _, ok := ms.etags[digestOrTag]; ok { - req.Header.Set("If-None-Match", ms.etags[digestOrTag]) + if _, ok := ms.etags[ref]; ok { + req.Header.Set("If-None-Match", ms.etags[ref]) } resp, err := ms.client.Do(req) @@ -429,15 +416,11 @@ func (o withTagOption) Apply(m distribution.ManifestService) error { // Put puts a manifest. A tag can be specified using an options parameter which uses some shared state to hold the // tag name in order to build the correct upload URL. This state is written and read under a lock. func (ms *manifests) Put(ctx context.Context, m distribution.Manifest, options ...distribution.ManifestServiceOption) (digest.Digest, error) { - ref := ms.name + var tag string for _, option := range options { if opt, ok := option.(withTagOption); ok { - var err error - ref, err = reference.WithTag(ref, opt.tag) - if err != nil { - return "", err - } + tag = opt.tag } else { err := option.Apply(ms) if err != nil { @@ -446,7 +429,7 @@ func (ms *manifests) Put(ctx context.Context, m distribution.Manifest, options . } } - manifestURL, err := ms.ub.BuildManifestURL(ref) + manifestURL, err := ms.ub.BuildManifestURL(ms.name, tag) if err != nil { return "", err } @@ -483,11 +466,7 @@ func (ms *manifests) Put(ctx context.Context, m distribution.Manifest, options . } func (ms *manifests) Delete(ctx context.Context, dgst digest.Digest) error { - ref, err := reference.WithDigest(ms.name, dgst) - if err != nil { - return err - } - u, err := ms.ub.BuildManifestURL(ref) + u, err := ms.ub.BuildManifestURL(ms.name, dgst.String()) if err != nil { return err } @@ -514,7 +493,7 @@ func (ms *manifests) Delete(ctx context.Context, dgst digest.Digest) error { }*/ type blobs struct { - name reference.Named + name string ub *v2.URLBuilder client *http.Client @@ -552,11 +531,7 @@ func (bs *blobs) Get(ctx context.Context, dgst digest.Digest) ([]byte, error) { } func (bs *blobs) Open(ctx context.Context, dgst digest.Digest) (distribution.ReadSeekCloser, error) { - ref, err := reference.WithDigest(bs.name, dgst) - if err != nil { - return nil, err - } - blobURL, err := bs.ub.BuildBlobURL(ref) + blobURL, err := bs.ub.BuildBlobURL(bs.name, dgst) if err != nil { return nil, err } @@ -691,17 +666,13 @@ func (bs *blobs) Delete(ctx context.Context, dgst digest.Digest) error { } type blobStatter struct { - name reference.Named + name string ub *v2.URLBuilder client *http.Client } func (bs *blobStatter) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) { - ref, err := reference.WithDigest(bs.name, dgst) - if err != nil { - return distribution.Descriptor{}, err - } - u, err := bs.ub.BuildBlobURL(ref) + u, err := bs.ub.BuildBlobURL(bs.name, dgst) if err != nil { return distribution.Descriptor{}, err } @@ -749,11 +720,7 @@ func buildCatalogValues(maxEntries int, last string) url.Values { } func (bs *blobStatter) Clear(ctx context.Context, dgst digest.Digest) error { - ref, err := reference.WithDigest(bs.name, dgst) - if err != nil { - return err - } - blobURL, err := bs.ub.BuildBlobURL(ref) + blobURL, err := bs.ub.BuildBlobURL(bs.name, dgst) if err != nil { return err }