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
b21de883
Commit
b21de883
authored
Oct 31, 2019
by
David Fernandez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for container repositories during:
* Group path update * Group transfer Subgroups are included.
parent
f4566cb4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
38 deletions
+66
-38
app/models/group.rb
app/models/group.rb
+2
-2
app/services/groups/transfer_service.rb
app/services/groups/transfer_service.rb
+1
-1
app/services/groups/update_service.rb
app/services/groups/update_service.rb
+3
-2
spec/finders/container_repositories_finder_spec.rb
spec/finders/container_repositories_finder_spec.rb
+1
-1
spec/services/groups/transfer_service_spec.rb
spec/services/groups/transfer_service_spec.rb
+22
-8
spec/services/groups/update_service_spec.rb
spec/services/groups/update_service_spec.rb
+37
-24
No files found.
app/models/group.rb
View file @
b21de883
...
@@ -263,8 +263,8 @@ class Group < Namespace
...
@@ -263,8 +263,8 @@ class Group < Namespace
members_with_parents
.
maintainers
.
exists?
(
user_id:
user
)
members_with_parents
.
maintainers
.
exists?
(
user_id:
user
)
end
end
def
has_container_repositor
ie
s?
def
has_container_repositor
y_including_subgroup
s?
container_repositories
.
exists?
::
ContainerRepository
.
for_group_and_its_subgroups
(
self
)
.
exists?
end
end
# @deprecated
# @deprecated
...
...
app/services/groups/transfer_service.rb
View file @
b21de883
...
@@ -75,7 +75,7 @@ module Groups
...
@@ -75,7 +75,7 @@ module Groups
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
group_projects_contain_registry_images?
def
group_projects_contain_registry_images?
@group
.
has_container_repositor
ie
s?
@group
.
has_container_repositor
y_including_subgroup
s?
end
end
def
update_group_attributes
def
update_group_attributes
...
...
app/services/groups/update_service.rb
View file @
b21de883
...
@@ -43,8 +43,9 @@ module Groups
...
@@ -43,8 +43,9 @@ module Groups
def
renaming_group_with_container_registry_images?
def
renaming_group_with_container_registry_images?
new_path
=
params
[
:path
]
new_path
=
params
[
:path
]
new_path
&&
new_path
!=
group
.
path
&&
new_path
&&
group
.
has_container_repositories?
new_path
!=
group
.
path
&&
group
.
has_container_repository_including_subgroups?
end
end
def
container_images_error
def
container_images_error
...
...
spec/finders/container_repositories_finder_spec.rb
View file @
b21de883
...
@@ -8,7 +8,7 @@ describe ContainerRepositoriesFinder do
...
@@ -8,7 +8,7 @@ describe ContainerRepositoriesFinder do
let
(
:group
)
{
create
(
:group
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:project_repository
)
{
create
(
:container_repository
,
project:
project
)
}
let
!
(
:project_repository
)
{
create
(
:container_repository
,
project:
project
)
}
before
do
before
do
group
.
add_reporter
(
reporter
)
group
.
add_reporter
(
reporter
)
...
...
spec/services/groups/transfer_service_spec.rb
View file @
b21de883
...
@@ -427,20 +427,34 @@ describe Groups::TransferService do
...
@@ -427,20 +427,34 @@ describe Groups::TransferService do
end
end
end
end
context
'when a project
in group
has container images'
do
context
'when a project has container images'
do
let
(
:group
)
{
create
(
:group
,
:public
,
:nested
)
}
let
(
:group
)
{
create
(
:group
,
:public
,
:nested
)
}
let!
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
namespace:
group
)
}
let!
(
:container_repository
)
{
create
(
:container_repository
,
project:
project
)
}
subject
{
transfer_service
.
execute
(
new_parent_group
)
}
before
do
before
do
stub_container_registry_tags
(
repository:
/image/
,
tags:
%w[rc1]
)
group
.
add_owner
(
user
)
create
(
:container_repository
,
project:
project
,
name: :image
)
new_parent_group
.
add_owner
(
user
)
create
(
:group_member
,
:owner
,
group:
new_parent_group
,
user:
user
)
end
end
it
'does not allow group to be transferred'
do
context
'within group'
do
transfer_service
.
execute
(
new_parent_group
)
let
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
namespace:
group
)
}
it
'does not transfer'
do
expect
(
subject
).
to
be
false
expect
(
transfer_service
.
error
).
to
match
(
/Docker images in their Container Registry/
)
end
end
expect
(
transfer_service
.
error
).
to
match
(
/Docker images in their Container Registry/
)
context
'within subgroup'
do
let
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:public
,
namespace:
subgroup
)
}
it
'does not transfer'
do
expect
(
subject
).
to
be
false
expect
(
transfer_service
.
error
).
to
match
(
/Docker images in their Container Registry/
)
end
end
end
end
end
end
end
...
...
spec/services/groups/update_service_spec.rb
View file @
b21de883
...
@@ -32,6 +32,43 @@ describe Groups::UpdateService do
...
@@ -32,6 +32,43 @@ describe Groups::UpdateService do
expect
(
service
.
execute
).
to
be_falsey
expect
(
service
.
execute
).
to
be_falsey
end
end
context
'when a project has container images'
do
let
(
:params
)
{
{
path:
SecureRandom
.
hex
}
}
let!
(
:container_repository
)
{
create
(
:container_repository
,
project:
project
)
}
subject
{
described_class
.
new
(
public_group
,
user
,
params
).
execute
}
context
'within group'
do
let
(
:project
)
{
create
(
:project
,
group:
public_group
)
}
context
'with path updates'
do
it
'does not allow the update'
do
expect
(
subject
).
to
be
false
expect
(
public_group
.
errors
[
:base
].
first
).
to
match
(
/Docker images in their Container Registry/
)
end
end
context
'with name updates'
do
let
(
:params
)
{
{
name:
'new-name'
}
}
it
'allows the update'
do
expect
(
subject
).
to
be
true
expect
(
public_group
.
reload
.
name
).
to
eq
(
'new-name'
)
end
end
end
context
'within subgroup'
do
let
(
:subgroup
)
{
create
(
:group
,
parent:
public_group
)
}
let
(
:project
)
{
create
(
:project
,
group:
subgroup
)
}
it
'does not allow path updates'
do
expect
(
subject
).
to
be
false
expect
(
public_group
.
errors
[
:base
].
first
).
to
match
(
/Docker images in their Container Registry/
)
end
end
end
end
end
context
"internal group with internal project"
do
context
"internal group with internal project"
do
...
@@ -148,30 +185,6 @@ describe Groups::UpdateService do
...
@@ -148,30 +185,6 @@ describe Groups::UpdateService do
end
end
end
end
context
'projects in group have container images'
do
let
(
:service
)
{
described_class
.
new
(
public_group
,
user
,
path:
SecureRandom
.
hex
)
}
let
(
:project
)
{
create
(
:project
,
:internal
,
group:
public_group
)
}
before
do
stub_container_registry_tags
(
repository:
/image/
,
tags:
%w[rc1]
)
create
(
:container_repository
,
project:
project
,
name: :image
)
end
it
'does not allow path to be changed'
do
result
=
described_class
.
new
(
public_group
,
user
,
path:
'new-path'
).
execute
expect
(
result
).
to
eq
false
expect
(
public_group
.
errors
[
:base
].
first
).
to
match
(
/Docker images in their Container Registry/
)
end
it
'allows other settings to be changed'
do
result
=
described_class
.
new
(
public_group
,
user
,
name:
'new-name'
).
execute
expect
(
result
).
to
eq
true
expect
(
public_group
.
reload
.
name
).
to
eq
(
'new-name'
)
end
end
context
'for a subgroup'
do
context
'for a subgroup'
do
let
(
:subgroup
)
{
create
(
:group
,
:private
,
parent:
private_group
)
}
let
(
:subgroup
)
{
create
(
:group
,
:private
,
parent:
private_group
)
}
...
...
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