2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
module Groups
|
|
|
|
module Registry
|
|
|
|
class RepositoriesController < Groups::ApplicationController
|
|
|
|
before_action :verify_container_registry_enabled!
|
|
|
|
before_action :authorize_read_container_image!
|
|
|
|
|
|
|
|
def index
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json do
|
2020-04-22 19:07:51 +05:30
|
|
|
@images = ContainerRepositoriesFinder.new(user: current_user, subject: group).execute.with_api_entity_associations
|
2019-12-21 20:55:43 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
track_event(:list_repositories)
|
|
|
|
|
|
|
|
serializer = ContainerRepositoriesSerializer
|
2019-12-21 20:55:43 +05:30
|
|
|
.new(current_user: current_user)
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
render json: serializer.with_pagination(request, response)
|
|
|
|
.represent_read_only(@images)
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
# The show action renders index to allow frontend routing to work on page refresh
|
|
|
|
def show
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def verify_container_registry_enabled!
|
|
|
|
render_404 unless Gitlab.config.registry.enabled
|
|
|
|
end
|
|
|
|
|
|
|
|
def authorize_read_container_image!
|
|
|
|
return render_404 unless can?(current_user, :read_container_image, group)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|