2019-10-17 08:07:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
module Groups
|
|
|
|
module Registry
|
|
|
|
class RepositoriesController < Groups::ApplicationController
|
2020-09-30 08:09:53 -04:00
|
|
|
include PackagesHelper
|
|
|
|
|
2019-10-17 08:07:33 -04:00
|
|
|
before_action :verify_container_registry_enabled!
|
|
|
|
before_action :authorize_read_container_image!
|
|
|
|
|
2020-10-06 08:08:38 -04:00
|
|
|
feature_category :package_registry
|
|
|
|
|
2019-10-17 08:07:33 -04:00
|
|
|
def index
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json do
|
2020-04-27 20:09:33 -04:00
|
|
|
@images = ContainerRepositoriesFinder.new(user: current_user, subject: group, params: params.slice(:name))
|
|
|
|
.execute
|
|
|
|
.with_api_entity_associations
|
2019-10-17 08:07:33 -04:00
|
|
|
|
2021-06-07 08:10:00 -04:00
|
|
|
track_package_event(:list_repositories, :container, user: current_user, namespace: group)
|
2020-01-22 13:08:47 -05:00
|
|
|
|
2020-02-06 16:08:48 -05:00
|
|
|
serializer = ContainerRepositoriesSerializer
|
2019-10-17 08:07:33 -04:00
|
|
|
.new(current_user: current_user)
|
2020-02-06 16:08:48 -05:00
|
|
|
|
2020-03-31 14:07:42 -04:00
|
|
|
render json: serializer.with_pagination(request, response)
|
|
|
|
.represent_read_only(@images)
|
2019-10-17 08:07:33 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-02-06 16:08:48 -05:00
|
|
|
# The show action renders index to allow frontend routing to work on page refresh
|
|
|
|
def show
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
|
2019-10-17 08:07:33 -04:00
|
|
|
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
|