diff options
author | Steve Abrams <sabrams@gitlab.com> | 2019-08-05 20:00:50 +0000 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2019-08-05 20:00:50 +0000 |
commit | 3dbf3997bbf51eca8a313c4e152c77c1b038fd5d (patch) | |
tree | f6da1d92978e97c53ee951e5b05f9cdbee057efa /app/finders | |
parent | e9918b1a949f478f42ebf8daee04cd0cb08977be (diff) | |
download | gitlab-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.rb | 34 |
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 |