BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9f36012e
Commit
9f36012e
authored
Jul 19, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix docker tag reference routing constraints
parent
9e5c8e5d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
6 deletions
+78
-6
project.rb
config/routes/project.rb
+1
-1
regex.rb
lib/gitlab/regex.rb
+7
-5
tags_controller_spec.rb
spec/controllers/projects/registry/tags_controller_spec.rb
+48
-0
project_routing_spec.rb
spec/routing/project_routing_spec.rb
+22
-0
No files found.
config/routes/project.rb
View file @
9f36012e
...
@@ -272,7 +272,7 @@ constraints(ProjectUrlConstrainer.new) do
...
@@ -272,7 +272,7 @@ constraints(ProjectUrlConstrainer.new) do
namespace
:registry
do
namespace
:registry
do
resources
:repository
,
only:
[]
do
resources
:repository
,
only:
[]
do
resources
:tags
,
only:
[
:destroy
],
resources
:tags
,
only:
[
:destroy
],
constraints:
{
id:
Gitlab
::
Regex
.
container_registry_
reference
_regex
}
constraints:
{
id:
Gitlab
::
Regex
.
container_registry_
tag
_regex
}
end
end
end
end
...
...
lib/gitlab/regex.rb
View file @
9f36012e
...
@@ -19,17 +19,19 @@ module Gitlab
...
@@ -19,17 +19,19 @@ module Gitlab
"It must start with letter, digit, emoji or '_'."
"It must start with letter, digit, emoji or '_'."
end
end
def
container_registry_reference_regex
Gitlab
::
PathRegex
.
git_reference_regex
end
##
##
# Docker Distribution Registry 2.4.1 repository name rules
# Docker Distribution Registry repository / tag name rules
#
# See https://github.com/docker/distribution/blob/master/reference/regexp.go.
#
#
def
container_repository_name_regex
def
container_repository_name_regex
@container_repository_regex
||=
%r{
\A
[a-z0-9]+(?:[-._/][a-z0-9]+)*
\Z
}
@container_repository_regex
||=
%r{
\A
[a-z0-9]+(?:[-._/][a-z0-9]+)*
\Z
}
end
end
def
container_registry_tag_regex
@container_registry_tag_regex
||=
/[\w][\w.-]{0,127}/
end
def
environment_name_regex_chars
def
environment_name_regex_chars
'a-zA-Z0-9_/\\$\\{\\}\\. -'
'a-zA-Z0-9_/\\$\\{\\}\\. -'
end
end
...
...
spec/controllers/projects/registry/tags_controller_spec.rb
0 → 100644
View file @
9f36012e
require
'spec_helper'
describe
Projects
::
Registry
::
TagsController
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:empty_project
,
:private
)
}
before
do
sign_in
(
user
)
stub_container_registry_config
(
enabled:
true
)
end
context
'when user has access to registry'
do
before
do
project
.
add_developer
(
user
)
end
describe
'POST destroy'
do
context
'when there is matching tag present'
do
before
do
stub_container_registry_tags
(
repository:
/image/
,
tags:
%w[rc1 test.]
)
end
let
(
:repository
)
do
create
(
:container_repository
,
name:
'image'
,
project:
project
)
end
it
'makes it possible to delete regular tag'
do
expect_any_instance_of
(
ContainerRegistry
::
Tag
).
to
receive
(
:delete
)
destroy_tag
(
'rc1'
)
end
it
'makes it possible to delete a tag that ends with a dot'
do
expect_any_instance_of
(
ContainerRegistry
::
Tag
).
to
receive
(
:delete
)
destroy_tag
(
'test.'
)
end
end
end
end
def
destroy_tag
(
name
)
post
:destroy
,
namespace_id:
project
.
namespace
,
project_id:
project
,
repository_id:
repository
,
id:
name
end
end
spec/routing/project_routing_spec.rb
View file @
9f36012e
...
@@ -609,4 +609,26 @@ describe 'project routing' do
...
@@ -609,4 +609,26 @@ describe 'project routing' do
expect
(
get
(
'/gitlab/gitlabhq/pages/domains/my.domain.com'
)).
to
route_to
(
'projects/pages_domains#show'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
id:
'my.domain.com'
)
expect
(
get
(
'/gitlab/gitlabhq/pages/domains/my.domain.com'
)).
to
route_to
(
'projects/pages_domains#show'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
id:
'my.domain.com'
)
end
end
end
end
describe
Projects
::
Registry
::
TagsController
,
:routing
do
describe
'#destroy'
do
it
'correctly routes to a destroy action'
do
expect
(
delete
(
'/gitlab/gitlabhq/registry/repository/1/tags/rc1'
))
.
to
route_to
(
'projects/registry/tags#destroy'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
repository_id:
'1'
,
id:
'rc1'
)
end
it
'takes registry tag name constrains into account'
do
expect
(
delete
(
'/gitlab/gitlabhq/registry/repository/1/tags/-rc1'
))
.
not_to
route_to
(
'projects/registry/tags#destroy'
,
namespace_id:
'gitlab'
,
project_id:
'gitlabhq'
,
repository_id:
'1'
,
id:
'-rc1'
)
end
end
end
end
end
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