Commit 714c408f authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add minor improvements to container registry code

parent 82dea6cf
......@@ -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
......
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment