Commit d44bf7e3 authored by Rémy Coutable's avatar Rémy Coutable Committed by Robert Speicher

Merge branch 'registry-500-fix' into 'master'

Properly support application/json in Container Registry

## What does this MR do?
When requesting tags a `application/json` is used by `docker/distribution`.

## Why was this MR needed?
Fixes regression introduced by https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4669

## What are the relevant issue numbers?
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/18736


See merge request !4742
parent cdd533cc
......@@ -15,11 +15,11 @@ module ContainerRegistry
end
def repository_tags(name)
@faraday.get("/v2/#{name}/tags/list").body
response_body @faraday.get("/v2/#{name}/tags/list")
end
def repository_manifest(name, reference)
@faraday.get("/v2/#{name}/manifests/#{reference}").body
response_body @faraday.get("/v2/#{name}/manifests/#{reference}")
end
def repository_tag_digest(name, reference)
......@@ -34,7 +34,7 @@ module ContainerRegistry
def blob(name, digest, type = nil)
headers = {}
headers['Accept'] = type if type
@faraday.get("/v2/#{name}/blobs/#{digest}", nil, headers).body
response_body @faraday.get("/v2/#{name}/blobs/#{digest}", nil, headers)
end
def delete_blob(name, digest)
......@@ -47,6 +47,7 @@ module ContainerRegistry
conn.request :json
conn.headers['Accept'] = MANIFEST_VERSION
conn.response :json, content_type: 'application/json'
conn.response :json, content_type: 'application/vnd.docker.distribution.manifest.v1+prettyjws'
conn.response :json, content_type: 'application/vnd.docker.distribution.manifest.v1+json'
conn.response :json, content_type: 'application/vnd.docker.distribution.manifest.v2+json'
......@@ -59,5 +60,9 @@ module ContainerRegistry
conn.adapter :net_http
end
def response_body(response)
response.body if response.success?
end
end
end
......@@ -21,7 +21,7 @@ describe ContainerRegistry::Repository do
to_return(
status: 200,
body: JSON.dump(tags: ['test']),
headers: { 'Content-Type' => 'application/vnd.docker.distribution.manifest.v2+json' })
headers: { 'Content-Type' => 'application/json' })
end
context '#manifest' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment