summaryrefslogtreecommitdiff
path: root/lib/container_registry
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-29 12:53:02 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-29 12:53:02 +0200
commit06bae00365cda6930063b98fde1a9b804f2ae3bc (patch)
treee65f656cd87e26c56c4274345f71e5376461aaad /lib/container_registry
parent5a7f8cb5d2f9ab7bc7172cedeb220b7d78530f78 (diff)
downloadgitlab-ce-06bae00365cda6930063b98fde1a9b804f2ae3bc.tar.gz
Make container repository path code more readable
Diffstat (limited to 'lib/container_registry')
-rw-r--r--lib/container_registry/path.rb24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/container_registry/path.rb b/lib/container_registry/path.rb
index 0ca51ab3766..d3f8bf74e14 100644
--- a/lib/container_registry/path.rb
+++ b/lib/container_registry/path.rb
@@ -1,10 +1,24 @@
module ContainerRegistry
+ ##
+ # Class reponsible for extracting project and repository name from
+ # image repository path provided by a containers registry API response.
+ #
+ # Example:
+ #
+ # some/group/my_project/my/image ->
+ # project: some/group/my_project
+ # repository: my/image
+ #
class Path
InvalidRegistryPathError = Class.new(StandardError)
- def initialize(name)
- @name = name
- @nodes = name.to_s.split('/')
+ def initialize(path)
+ @path = path
+ @nodes = path.to_s.split('/')
+ end
+
+ def to_s
+ @path
end
def valid?
@@ -20,7 +34,7 @@ module ContainerRegistry
end
def has_repository?
- # ContainerRepository.find_by_full_path(@name).present?
+ # ContainerRepository.find_by_full_path(@path).present?
end
def repository_project
@@ -30,7 +44,7 @@ module ContainerRegistry
def repository_name
return unless repository_project
- @name.remove(%r(^?#{Regexp.escape(repository_project.full_path)}/?))
+ @path.remove(%r(^?#{Regexp.escape(repository_project.full_path)}/?))
end
end
end