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
Jérome Perrin
gitlab-ce
Commits
896b13b9
Commit
896b13b9
authored
Mar 22, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor splitting container image full path
[ci skip]
parent
95e2c019
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
16 deletions
+8
-16
app/models/container_image.rb
app/models/container_image.rb
+7
-10
app/services/auth/container_registry_authentication_service.rb
...ervices/auth/container_registry_authentication_service.rb
+1
-6
No files found.
app/models/container_image.rb
View file @
896b13b9
class
ContainerImage
<
ActiveRecord
::
Base
include
Routable
belongs_to
:project
delegate
:container_registry
,
to: :project
...
...
@@ -45,14 +43,13 @@ class ContainerImage < ActiveRecord::Base
end
end
# rubocop:disable RedundantReturn
def
self
.
from_path
(
full_path
)
return
unless
full_path
.
include?
(
'/'
)
def
self
.
split_namespace
(
full_path
)
image_name
=
full_path
.
split
(
'/'
).
last
namespace
=
full_path
.
gsub
(
/(.*)(
#{
Regexp
.
escape
(
'/'
+
image_name
)
}
)/
,
'\1'
)
if
namespace
.
count
(
'/'
)
<
1
namespace
,
image_name
=
full_path
,
""
end
return
namespace
,
image_name
path
=
full_path
[
0
...
full_path
.
rindex
(
'/'
)]
name
=
full_path
[
full_path
.
rindex
(
'/'
)
+
1
..-
1
]
project
=
Project
.
find_by_full_path
(
path
)
self
.
new
(
name:
name
,
path:
path
,
project:
project
)
end
end
app/services/auth/container_registry_authentication_service.rb
View file @
896b13b9
...
...
@@ -62,12 +62,7 @@ module Auth
end
def
process_repository_access
(
type
,
name
,
actions
)
# Strips image name due to lack of
# per image authentication.
# Removes only last occurence in light
# of future nested groups
namespace
,
a
=
ContainerImage
::
split_namespace
(
name
)
requested_project
=
Project
.
find_by_full_path
(
namespace
)
requested_project
=
ContainerImage
.
from_path
(
name
).
project
return
unless
requested_project
actions
=
actions
.
select
do
|
action
|
...
...
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