Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-06 11:23:51 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-06 11:23:51 +0300
commit714c408f222cc3bfef577b477f7bab0556f50599 (patch)
treef387bc1f5e2f6fbab5df8ecd8ad88fa863f3a082
parent82dea6cffe339456c5ba0fd090464926e970dccf (diff)
Add minor improvements to container registry code
-rw-r--r--app/controllers/projects/registry/tags_controller.rb6
-rw-r--r--lib/container_registry/path.rb8
2 files changed, 8 insertions, 6 deletions
diff --git a/app/controllers/projects/registry/tags_controller.rb b/app/controllers/projects/registry/tags_controller.rb
index 7a9f290e946..d689cade3ab 100644
--- a/app/controllers/projects/registry/tags_controller.rb
+++ b/app/controllers/projects/registry/tags_controller.rb
@@ -15,15 +15,13 @@ module Projects
private
- def repository
+ def image
@image ||= project.container_repositories
.find(params[:repository_id])
end
def tag
- return render_404 unless params[:id].present?
-
- @tag ||= repository.tag(params[:id])
+ @tag ||= image.tag(params[:id])
end
end
end
diff --git a/lib/container_registry/path.rb b/lib/container_registry/path.rb
index 89973b2e7b8..a4b5f2aba6c 100644
--- a/lib/container_registry/path.rb
+++ b/lib/container_registry/path.rb
@@ -1,6 +1,6 @@
module ContainerRegistry
##
- # Class reponsible for extracting project and repository name from
+ # Class responsible for extracting project and repository name from
# image repository path provided by a containers registry API response.
#
# Example:
@@ -12,6 +12,8 @@ module ContainerRegistry
class Path
InvalidRegistryPathError = Class.new(StandardError)
+ LEVELS_SUPPORTED = 3
+
def initialize(path)
@path = path
end
@@ -50,7 +52,9 @@ module ContainerRegistry
end
def repository_project
- @project ||= Project.where_full_path_in(nodes.first(3)).first
+ @project ||= Project
+ .where_full_path_in(nodes.first(LEVELS_SUPPORTED))
+ .first
end
def repository_name