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
This commit is contained in:
Rémy Coutable 2016-06-17 17:06:55 +00:00
commit 1ca1ebc09b
2 changed files with 9 additions and 4 deletions

View File

@ -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

View File

@ -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