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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
5c2f2fd2
Commit
5c2f2fd2
authored
May 12, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CI tests
parent
4d84ba43
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
31 additions
and
20 deletions
+31
-20
app/controllers/projects/container_registry_controller.rb
app/controllers/projects/container_registry_controller.rb
+0
-1
app/helpers/gitlab_routing_helper.rb
app/helpers/gitlab_routing_helper.rb
+1
-1
app/models/ability.rb
app/models/ability.rb
+1
-1
app/models/namespace.rb
app/models/namespace.rb
+1
-1
app/models/project.rb
app/models/project.rb
+2
-2
app/services/jwt/container_registry_authentication_service.rb
...services/jwt/container_registry_authentication_service.rb
+1
-1
app/services/projects/destroy_service.rb
app/services/projects/destroy_service.rb
+3
-1
app/services/projects/transfer_service.rb
app/services/projects/transfer_service.rb
+1
-1
app/views/projects/container_registry/_tag.html.haml
app/views/projects/container_registry/_tag.html.haml
+5
-4
app/views/projects/container_registry/index.html.haml
app/views/projects/container_registry/index.html.haml
+3
-2
lib/container_registry/client.rb
lib/container_registry/client.rb
+1
-1
lib/container_registry/repository.rb
lib/container_registry/repository.rb
+3
-1
spec/features/container_registry_spec.rb
spec/features/container_registry_spec.rb
+9
-3
No files found.
app/controllers/projects/container_registry_controller.rb
View file @
5c2f2fd2
class
Projects::ContainerRegistryController
<
Projects
::
ApplicationController
class
Projects::ContainerRegistryController
<
Projects
::
ApplicationController
before_action
:authorize_read_container_registry!
before_action
:authorize_read_container_registry!
before_action
:authorize_update_container_registry!
,
only:
[
:destroy
]
before_action
:authorize_update_container_registry!
,
only:
[
:destroy
]
before_action
:tag
,
except:
[
:index
]
layout
'project'
layout
'project'
def
index
def
index
...
...
app/helpers/gitlab_routing_helper.rb
View file @
5c2f2fd2
...
@@ -34,7 +34,7 @@ module GitlabRoutingHelper
...
@@ -34,7 +34,7 @@ module GitlabRoutingHelper
end
end
def
project_container_registry_path
(
project
,
*
args
)
def
project_container_registry_path
(
project
,
*
args
)
namespace_project_container_registry_index_
url
(
project
.
namespace
,
project
,
*
args
)
namespace_project_container_registry_index_
path
(
project
.
namespace
,
project
,
*
args
)
end
end
def
activity_project_path
(
project
,
*
args
)
def
activity_project_path
(
project
,
*
args
)
...
...
app/models/ability.rb
View file @
5c2f2fd2
...
@@ -291,7 +291,7 @@ class Ability
...
@@ -291,7 +291,7 @@ class Ability
rules
+=
named_abilities
(
'build'
)
rules
+=
named_abilities
(
'build'
)
end
end
unless
project
.
container_registry_enabled
unless
project
.
container_registry_enabled
&&
Gitlab
.
config
.
registry
.
enabled
rules
+=
named_abilities
(
'container_registry'
)
rules
+=
named_abilities
(
'container_registry'
)
end
end
...
...
app/models/namespace.rb
View file @
5c2f2fd2
...
@@ -128,7 +128,7 @@ class Namespace < ActiveRecord::Base
...
@@ -128,7 +128,7 @@ class Namespace < ActiveRecord::Base
gitlab_shell
.
add_namespace
(
path_was
)
gitlab_shell
.
add_namespace
(
path_was
)
if
any_project_has_container_registry_tags?
if
any_project_has_container_registry_tags?
raise
Exception
.
new
(
'
n
amespace cannot be moved, because at least one project has tags in container registry'
)
raise
Exception
.
new
(
'
N
amespace cannot be moved, because at least one project has tags in container registry'
)
end
end
if
gitlab_shell
.
mv_namespace
(
path_was
,
path
)
if
gitlab_shell
.
mv_namespace
(
path_was
,
path
)
...
...
app/models/project.rb
View file @
5c2f2fd2
...
@@ -377,7 +377,7 @@ class Project < ActiveRecord::Base
...
@@ -377,7 +377,7 @@ class Project < ActiveRecord::Base
def
container_registry_repository
def
container_registry_repository
@container_registry_repository
||=
begin
@container_registry_repository
||=
begin
token
=
J
wt
::
ContainerRegistryAuthenticationService
.
full_access_token
(
path_with_namespace
)
token
=
J
WT
::
ContainerRegistryAuthenticationService
.
full_access_token
(
path_with_namespace
)
url
=
Gitlab
.
config
.
registry
.
api_url
url
=
Gitlab
.
config
.
registry
.
api_url
host_port
=
Gitlab
.
config
.
registry
.
host_port
host_port
=
Gitlab
.
config
.
registry
.
host_port
registry
=
ContainerRegistry
::
Registry
.
new
(
url
,
token:
token
,
path:
host_port
)
registry
=
ContainerRegistry
::
Registry
.
new
(
url
,
token:
token
,
path:
host_port
)
...
@@ -814,7 +814,7 @@ class Project < ActiveRecord::Base
...
@@ -814,7 +814,7 @@ class Project < ActiveRecord::Base
if
has_container_registry_tags?
if
has_container_registry_tags?
# we currently doesn't support renaming repository if it contains tags in container registry
# we currently doesn't support renaming repository if it contains tags in container registry
raise
Exception
.
new
(
'
repository cannot be renamed, due to tags in
container registry'
)
raise
Exception
.
new
(
'
Project cannot be renamed, because tags are present in its
container registry'
)
end
end
if
gitlab_shell
.
mv_repository
(
old_path_with_namespace
,
new_path_with_namespace
)
if
gitlab_shell
.
mv_repository
(
old_path_with_namespace
,
new_path_with_namespace
)
...
...
app/services/jwt/container_registry_authentication_service.rb
View file @
5c2f2fd2
...
@@ -14,7 +14,7 @@ module JWT
...
@@ -14,7 +14,7 @@ module JWT
def
self
.
full_access_token
(
*
names
)
def
self
.
full_access_token
(
*
names
)
registry
=
Gitlab
.
config
.
registry
registry
=
Gitlab
.
config
.
registry
token
=
::
J
wt
::
RSAToken
.
new
(
registry
.
key
)
token
=
::
J
WT
::
RSAToken
.
new
(
registry
.
key
)
token
.
issuer
=
registry
.
issuer
token
.
issuer
=
registry
.
issuer
token
.
audience
=
AUDIENCE
token
.
audience
=
AUDIENCE
token
[
:access
]
=
names
.
map
do
|
name
|
token
[
:access
]
=
names
.
map
do
|
name
|
...
...
app/services/projects/destroy_service.rb
View file @
5c2f2fd2
...
@@ -64,7 +64,9 @@ module Projects
...
@@ -64,7 +64,9 @@ module Projects
end
end
def
remove_registry_tags
def
remove_registry_tags
project
.
image_registry
.
delete_tags
return
unless
Gitlab
.
config
.
registry
.
enabled
project
.
container_registry_repository
.
delete_tags
end
end
def
raise_error
(
message
)
def
raise_error
(
message
)
...
...
app/services/projects/transfer_service.rb
View file @
5c2f2fd2
...
@@ -36,7 +36,7 @@ module Projects
...
@@ -36,7 +36,7 @@ module Projects
if
project
.
has_container_registry_tags?
if
project
.
has_container_registry_tags?
# we currently doesn't support renaming repository if it contains tags in container registry
# we currently doesn't support renaming repository if it contains tags in container registry
raise
TransferError
.
new
(
'
Repository cannot be renamed, due to tags in
container registry'
)
raise
TransferError
.
new
(
'
Project cannot be transferred, because tags are present in its
container registry'
)
end
end
project
.
expire_caches_before_rename
(
old_path
)
project
.
expire_caches_before_rename
(
old_path
)
...
...
app/views/projects/container_registry/_tag.html.haml
View file @
5c2f2fd2
...
@@ -14,7 +14,8 @@
...
@@ -14,7 +14,8 @@
=
pluralize
(
tag
.
layers
.
size
,
"layer"
)
=
pluralize
(
tag
.
layers
.
size
,
"layer"
)
%td
%td
=
time_ago_in_words
(
tag
.
created_at
)
=
time_ago_in_words
(
tag
.
created_at
)
%td
.content
-
if
can?
(
current_user
,
:update_container_registry
,
@project
)
.controls.hidden-xs.pull-right
%td
.content
=
link_to
namespace_project_container_registry_path
(
@project
.
namespace
,
@project
,
tag
.
name
),
class:
'btn btn-remove has-tooltip'
,
title:
"Remove"
,
data:
{
confirm:
"Are you sure?"
},
method: :delete
do
.controls.hidden-xs.pull-right
=
icon
(
"trash cred"
)
=
link_to
namespace_project_container_registry_path
(
@project
.
namespace
,
@project
,
tag
.
name
),
class:
'btn btn-remove has-tooltip'
,
title:
"Remove"
,
data:
{
confirm:
"Are you sure?"
},
method: :delete
do
=
icon
(
"trash cred"
)
app/views/projects/container_registry/index.html.haml
View file @
5c2f2fd2
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
%code
%code
docker login
#{
Gitlab
.
config
.
registry
.
host_port
}
docker login
#{
Gitlab
.
config
.
registry
.
host_port
}
%br
%br
Then you are free to create and upload a container image
s
with build and push commands:
Then you are free to create and upload a container image with build and push commands:
%pre
%pre
docker build -t
#{
escape_once
(
@project
.
container_registry_repository_url
)
}
.
docker build -t
#{
escape_once
(
@project
.
container_registry_repository_url
)
}
.
%br
%br
...
@@ -33,7 +33,8 @@
...
@@ -33,7 +33,8 @@
%th
Image ID
%th
Image ID
%th
Size
%th
Size
%th
Created
%th
Created
%th
-
if
can?
(
current_user
,
:update_container_registry
,
@project
)
%th
-
@tags
.
each
do
|
tag
|
-
@tags
.
each
do
|
tag
|
=
render
'tag'
,
tag:
tag
=
render
'tag'
,
tag:
tag
\ No newline at end of file
lib/container_registry/client.rb
View file @
5c2f2fd2
...
@@ -55,7 +55,7 @@ module ContainerRegistry
...
@@ -55,7 +55,7 @@ module ContainerRegistry
conn
.
request
:json
conn
.
request
:json
conn
.
headers
[
'Accept'
]
=
MANIFEST_VERSION
conn
.
headers
[
'Accept'
]
=
MANIFEST_VERSION
conn
.
response
:json
,
:content_type
=>
/\bjson$/
conn
.
response
:json
,
content_type:
/\bjson$/
if
options
[
:user
]
&&
options
[
:password
]
if
options
[
:user
]
&&
options
[
:password
]
conn
.
request
(
:basic_auth
,
options
[
:user
].
to_s
,
options
[
:password
].
to_s
)
conn
.
request
(
:basic_auth
,
options
[
:user
].
to_s
,
options
[
:password
].
to_s
)
...
...
lib/container_registry/repository.rb
View file @
5c2f2fd2
...
@@ -30,19 +30,21 @@ module ContainerRegistry
...
@@ -30,19 +30,21 @@ module ContainerRegistry
def
tags
def
tags
return
@tags
if
defined?
(
@tags
)
return
@tags
if
defined?
(
@tags
)
return
[]
unless
manifest
&&
manifest
[
'tags'
]
return
[]
unless
manifest
&&
manifest
[
'tags'
]
@tags
=
manifest
[
'tags'
].
map
do
|
tag
|
@tags
=
manifest
[
'tags'
].
map
do
|
tag
|
ContainerRegistry
::
Tag
.
new
(
self
,
tag
)
ContainerRegistry
::
Tag
.
new
(
self
,
tag
)
end
end
@tags
||=
[]
end
end
def
delete_tags
def
delete_tags
return
unless
tags
return
unless
tags
tags
.
each
(
:delete
)
tags
.
each
(
:delete
)
end
end
def
mount_blob
(
blob
)
def
mount_blob
(
blob
)
return
unless
blob
return
unless
blob
client
.
repository_mount_blob
(
name
,
blob
.
digest
,
blob
.
repository
.
name
)
client
.
repository_mount_blob
(
name
,
blob
.
digest
,
blob
.
repository
.
name
)
end
end
...
...
spec/features/container_registry_spec.rb
View file @
5c2f2fd2
...
@@ -5,14 +5,18 @@ describe "Container Registry" do
...
@@ -5,14 +5,18 @@ describe "Container Registry" do
let
(
:repository
)
{
project
.
container_registry_repository
}
let
(
:repository
)
{
project
.
container_registry_repository
}
let
(
:tag_name
)
{
'latest'
}
let
(
:tag_name
)
{
'latest'
}
let
(
:tags
)
{
[
tag_name
]
}
let
(
:tags
)
{
[
tag_name
]
}
let
(
:registry_settings
)
do
before
do
{
enabled:
true
}
end
end
before
do
before
do
login_as
(
:user
)
login_as
(
:user
)
project
.
team
<<
[
@user
,
:developer
]
project
.
team
<<
[
@user
,
:developer
]
stub_container_registry
(
*
tags
)
stub_container_registry
(
*
tags
)
allow
(
Gitlab
.
config
.
registry
).
to
receive_messages
(
registry_settings
)
allow
(
JWT
::
ContainerRegistryAuthenticationService
).
to
receive
(
:full_access_token
).
and_return
(
'token'
)
end
end
describe
'GET /:project/container_registry'
do
describe
'GET /:project/container_registry'
do
...
@@ -22,6 +26,7 @@ describe "Container Registry" do
...
@@ -22,6 +26,7 @@ describe "Container Registry" do
context
'when no tags'
do
context
'when no tags'
do
let
(
:tags
)
{
[]
}
let
(
:tags
)
{
[]
}
it
{
expect
(
page
).
to
have_content
(
'No images in Container Registry for this project'
)
}
it
{
expect
(
page
).
to
have_content
(
'No images in Container Registry for this project'
)
}
end
end
...
@@ -37,7 +42,8 @@ describe "Container Registry" do
...
@@ -37,7 +42,8 @@ describe "Container Registry" do
it
do
it
do
expect_any_instance_of
(
::
ContainerRegistry
::
Tag
).
to
receive
(
:delete
).
and_return
(
true
)
expect_any_instance_of
(
::
ContainerRegistry
::
Tag
).
to
receive
(
:delete
).
and_return
(
true
)
click_on
'Remove'
click_on
'Remove'
end
end
end
end
end
end
\ No newline at end of file
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