2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
module Groups
|
|
|
|
module Registry
|
|
|
|
class RepositoriesController < Groups::ApplicationController
|
2021-01-03 14:25:43 +05:30
|
|
|
include PackagesHelper
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
before_action :verify_container_registry_enabled!
|
|
|
|
before_action :authorize_read_container_image!
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
feature_category :package_registry
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
def index
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json do
|
2020-05-24 23:13:21 +05:30
|
|
|
@images = ContainerRepositoriesFinder.new(user: current_user, subject: group, params: params.slice(:name))
|
|
|
|
.execute
|
|
|
|
.with_api_entity_associations
|
2019-12-21 20:55:43 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
track_package_event(:list_repositories, :container)
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
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
|