summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorSteve Abrams <sabrams@gitlab.com>2019-08-05 20:00:50 +0000
committerMayra Cabrera <mcabrera@gitlab.com>2019-08-05 20:00:50 +0000
commit3dbf3997bbf51eca8a313c4e152c77c1b038fd5d (patch)
treef6da1d92978e97c53ee951e5b05f9cdbee057efa /app/finders
parente9918b1a949f478f42ebf8daee04cd0cb08977be (diff)
downloadgitlab-ce-3dbf3997bbf51eca8a313c4e152c77c1b038fd5d.tar.gz
Add group level container repository endpoints
API endpoints for requesting container repositories and container repositories with their tag information are enabled for users that want to specify the group containing the repository rather than the specific project.
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/container_repositories_finder.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/finders/container_repositories_finder.rb b/app/finders/container_repositories_finder.rb
new file mode 100644
index 00000000000..eb91d7f825b
--- /dev/null
+++ b/app/finders/container_repositories_finder.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+class ContainerRepositoriesFinder
+ # id: group or project id
+ # container_type: :group or :project
+ def initialize(id:, container_type:)
+ @id = id
+ @type = container_type.to_sym
+ end
+
+ def execute
+ if project_type?
+ project.container_repositories
+ else
+ group.container_repositories
+ end
+ end
+
+ private
+
+ attr_reader :id, :type
+
+ def project_type?
+ type == :project
+ end
+
+ def project
+ Project.find(id)
+ end
+
+ def group
+ Group.find(id)
+ end
+end