Add namespace query parameter for registry proxying
Proxy registries are designed to serve content from upstreams. However, the proxy hostname will usually not match the hostname of the upstream, requiring the proxy to only use a single upstream or use its own pattern matching to determine the upstream. To solve this issue, the client will pass along the namespace which is being used for the request, allowing mirrors to easily map to multiple upstreams. This query parameter can safely be ignored if multiple upstreams are not supported. Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
		| @@ -98,6 +98,9 @@ func (r dockerFetcher) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.R | ||||
| 			var firstErr error | ||||
| 			for _, host := range r.hosts { | ||||
| 				req := r.request(host, http.MethodGet, "manifests", desc.Digest.String()) | ||||
| 				if err := req.addNamespace(r.refspec.Hostname()); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
|  | ||||
| 				rc, err := r.open(ctx, req, desc.MediaType, offset) | ||||
| 				if err != nil { | ||||
| @@ -118,6 +121,9 @@ func (r dockerFetcher) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.R | ||||
| 		var firstErr error | ||||
| 		for _, host := range r.hosts { | ||||
| 			req := r.request(host, http.MethodGet, "blobs", desc.Digest.String()) | ||||
| 			if err := req.addNamespace(r.refspec.Hostname()); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|  | ||||
| 			rc, err := r.open(ctx, req, desc.MediaType, offset) | ||||
| 			if err != nil { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Derek McGowan
					Derek McGowan