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
|
2021-11-18 22:05:49 +05:30
|
|
|
include ::Registry::ConnectionErrorsHandler
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
before_action :verify_container_registry_enabled!
|
|
|
|
before_action :authorize_read_container_image!
|
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
before_action do
|
|
|
|
push_frontend_feature_flag(:container_registry_show_shortened_path, group)
|
|
|
|
end
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
feature_category :container_registry
|
|
|
|
urgency :low
|
2021-01-03 14:25:43 +05:30
|
|
|
|
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-09-04 01:27:46 +05:30
|
|
|
track_package_event(:list_repositories, :container, user: current_user, namespace: group)
|
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
|