debian-mirror-gitlab/app/controllers/projects/registry/repositories_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.6 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module Projects
module Registry
class RepositoriesController < ::Projects::Registry::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
2017-08-17 22:00:37 +05:30
before_action :authorize_update_container_image!, only: [:destroy]
2022-08-13 15:12:31 +05:30
before_action do
push_frontend_feature_flag(:container_registry_show_shortened_path, project)
end
2017-08-17 22:00:37 +05:30
def index
2018-03-17 18:26:18 +05:30
respond_to do |format|
2021-04-29 21:17:54 +05:30
format.html { ensure_root_container_repository! }
format.json { render_404 }
2018-03-17 18:26:18 +05:30
end
2017-08-17 22:00:37 +05:30
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
2017-08-17 22:00:37 +05:30
def destroy
2020-04-22 19:07:51 +05:30
image.delete_scheduled!
2020-03-13 15:44:24 +05:30
DeleteContainerRepositoryWorker.perform_async(current_user.id, image.id) # rubocop:disable CodeReuse/Worker
2021-01-03 14:25:43 +05:30
track_package_event(:delete_repository, :container)
2018-11-20 20:47:30 +05:30
respond_to do |format|
format.json { head :no_content }
2017-08-17 22:00:37 +05:30
end
end
private
def image
@image ||= project.container_repositories.find(params[:id])
end
##
# Container repository object for root project path.
#
# Needed to maintain a backwards compatibility.
#
def ensure_root_container_repository!
2018-11-20 20:47:30 +05:30
::ContainerRegistry::Path.new(@project.full_path).tap do |path|
2017-08-17 22:00:37 +05:30
break if path.has_repository?
2018-11-20 20:47:30 +05:30
::ContainerRepository.build_from_path(path).tap do |repository|
2017-08-17 22:00:37 +05:30
repository.save! if repository.has_tags?
end
end
end
end
end
end