Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a8760172
Commit
a8760172
authored
Jul 25, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
8e2a24eb
29f2903d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
5 deletions
+49
-5
changelogs/unreleased/sh-support-docker-oci-images.yml
changelogs/unreleased/sh-support-docker-oci-images.yml
+5
-0
lib/container_registry/client.rb
lib/container_registry/client.rb
+6
-3
spec/lib/container_registry/client_spec.rb
spec/lib/container_registry/client_spec.rb
+36
-0
spec/lib/container_registry/tag_spec.rb
spec/lib/container_registry/tag_spec.rb
+1
-1
spec/models/container_repository_spec.rb
spec/models/container_repository_spec.rb
+1
-1
No files found.
changelogs/unreleased/sh-support-docker-oci-images.yml
0 → 100644
View file @
a8760172
---
title
:
Support Docker OCI images
merge_request
:
31127
author
:
type
:
fixed
lib/container_registry/client.rb
View file @
a8760172
...
...
@@ -7,7 +7,9 @@ module ContainerRegistry
class
Client
attr_accessor
:uri
MANIFEST_VERSION
=
'application/vnd.docker.distribution.manifest.v2+json'
.
freeze
DOCKER_DISTRIBUTION_MANIFEST_V2_TYPE
=
'application/vnd.docker.distribution.manifest.v2+json'
OCI_MANIFEST_V1_TYPE
=
'application/vnd.oci.image.manifest.v1+json'
ACCEPTED_TYPES
=
[
DOCKER_DISTRIBUTION_MANIFEST_V2_TYPE
,
OCI_MANIFEST_V1_TYPE
].
freeze
# Taken from: FaradayMiddleware::FollowRedirects
REDIRECT_CODES
=
Set
.
new
[
301
,
302
,
303
,
307
]
...
...
@@ -60,12 +62,13 @@ module ContainerRegistry
end
def
accept_manifest
(
conn
)
conn
.
headers
[
'Accept'
]
=
MANIFEST_VERSION
conn
.
headers
[
'Accept'
]
=
ACCEPTED_TYPES
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'
conn
.
response
:json
,
content_type:
DOCKER_DISTRIBUTION_MANIFEST_V2_TYPE
conn
.
response
:json
,
content_type:
OCI_MANIFEST_V1_TYPE
end
def
response_body
(
response
,
allow_redirect:
false
)
...
...
spec/lib/container_registry/client_spec.rb
View file @
a8760172
...
...
@@ -6,6 +6,42 @@ describe ContainerRegistry::Client do
let
(
:options
)
{
{
token:
token
}
}
let
(
:client
)
{
described_class
.
new
(
"http://container-registry"
,
options
)
}
shared_examples
'#repository_manifest'
do
|
manifest_type
|
let
(
:manifest
)
do
{
"schemaVersion"
=>
2
,
"config"
=>
{
"mediaType"
=>
manifest_type
,
"digest"
=>
"sha256:4a3ef0786dd241be6000311e1503869b320be433b9cba84cfafeb512d1720c95"
,
"size"
=>
6608
},
"layers"
=>
[
{
"mediaType"
=>
manifest_type
,
"digest"
=>
"sha256:83ef92b73cf4595aa7fe214ec6747228283d585f373d8f6bc08d66bebab531b7"
,
"size"
=>
2828661
}
]
}
end
it
'GET /v2/:name/manifests/mytag'
do
stub_request
(
:get
,
"http://container-registry/v2/group/test/manifests/mytag"
)
.
with
(
headers:
{
'Accept'
=>
described_class
::
ACCEPTED_TYPES
.
join
(
', '
),
'Authorization'
=>
"bearer
#{
token
}
"
})
.
to_return
(
status:
200
,
body:
manifest
.
to_json
,
headers:
{
content_type:
manifest_type
})
expect
(
client
.
repository_manifest
(
'group/test'
,
'mytag'
)).
to
eq
(
manifest
)
end
end
it_behaves_like
'#repository_manifest'
,
described_class
::
DOCKER_DISTRIBUTION_MANIFEST_V2_TYPE
it_behaves_like
'#repository_manifest'
,
described_class
::
OCI_MANIFEST_V1_TYPE
describe
'#blob'
do
it
'GET /v2/:name/blobs/:digest'
do
stub_request
(
:get
,
"http://container-registry/v2/group/test/blobs/sha256:0123456789012345"
)
...
...
spec/lib/container_registry/tag_spec.rb
View file @
a8760172
...
...
@@ -9,7 +9,7 @@ describe ContainerRegistry::Tag do
end
let
(
:headers
)
do
{
'Accept'
=>
'application/vnd.docker.distribution.manifest.v2+json'
}
{
'Accept'
=>
ContainerRegistry
::
Client
::
ACCEPTED_TYPES
.
join
(
', '
)
}
end
let
(
:tag
)
{
described_class
.
new
(
repository
,
'tag'
)
}
...
...
spec/models/container_repository_spec.rb
View file @
a8760172
...
...
@@ -16,7 +16,7 @@ describe ContainerRepository do
host_port:
'registry.gitlab'
)
stub_request
(
:get
,
'http://registry.gitlab/v2/group/test/my_image/tags/list'
)
.
with
(
headers:
{
'Accept'
=>
'application/vnd.docker.distribution.manifest.v2+json'
})
.
with
(
headers:
{
'Accept'
=>
ContainerRegistry
::
Client
::
ACCEPTED_TYPES
.
join
(
', '
)
})
.
to_return
(
status:
200
,
body:
JSON
.
dump
(
tags:
[
'test_tag'
]),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment