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
0426d15c
Commit
0426d15c
authored
5 years ago
by
Giorgenes Gelatti
Committed by
Nathan Friend
5 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support bulk registry tag delete
parent
15bda06c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
1 deletion
+53
-1
app/controllers/projects/registry/tags_controller.rb
app/controllers/projects/registry/tags_controller.rb
+15
-0
config/routes/project.rb
config/routes/project.rb
+5
-1
spec/controllers/projects/registry/tags_controller_spec.rb
spec/controllers/projects/registry/tags_controller_spec.rb
+33
-0
No files found.
app/controllers/projects/registry/tags_controller.rb
View file @
0426d15c
...
...
@@ -28,6 +28,21 @@ module Projects
end
end
def
bulk_destroy
@tags
=
(
params
[
:ids
]
||
[]).
map
{
|
tag_name
|
image
.
tag
(
tag_name
)
}
success_count
=
0
@tags
.
each
do
|
tag
|
if
tag
.
delete
success_count
+=
1
end
end
respond_to
do
|
format
|
format
.
json
{
head
(
success_count
==
@tags
.
size
?
:no_content
:
:bad_request
)
}
end
end
private
def
tags
...
...
This diff is collapsed.
Click to expand it.
config/routes/project.rb
View file @
0426d15c
...
...
@@ -474,7 +474,11 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
# in JSON format, or a request for tag named `latest.json`.
scope
format:
false
do
resources
:tags
,
only:
[
:index
,
:destroy
],
constraints:
{
id:
Gitlab
::
Regex
.
container_registry_tag_regex
}
constraints:
{
id:
Gitlab
::
Regex
.
container_registry_tag_regex
}
do
collection
do
delete
:bulk_destroy
end
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
spec/controllers/projects/registry/tags_controller_spec.rb
View file @
0426d15c
...
...
@@ -113,4 +113,37 @@ describe Projects::Registry::TagsController do
format: :json
end
end
describe
'POST bulk_destroy'
do
context
'when user has access to registry'
do
before
do
project
.
add_developer
(
user
)
end
context
'when there is matching tag present'
do
before
do
stub_container_registry_tags
(
repository:
repository
.
path
,
tags:
%w[rc1 test.]
)
end
it
'makes it possible to delete tags in bulk'
do
allow_any_instance_of
(
ContainerRegistry
::
Tag
).
to
receive
(
:delete
)
{
|*
args
|
ContainerRegistry
::
Tag
.
delete
(
*
args
)
}
expect
(
ContainerRegistry
::
Tag
).
to
receive
(
:delete
).
exactly
(
2
).
times
bulk_destroy_tags
([
'rc1'
,
'test.'
])
end
end
end
private
def
bulk_destroy_tags
(
names
)
post
:bulk_destroy
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
repository_id:
repository
,
ids:
names
},
format: :json
end
end
end
This diff is collapsed.
Click to expand it.
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