debian-mirror-gitlab/app/graphql/mutations/container_repositories/destroy.rb
2022-08-27 11:52:29 +05:30

36 lines
1.1 KiB
Ruby

# frozen_string_literal: true
module Mutations
module ContainerRepositories
class Destroy < ::Mutations::ContainerRepositories::DestroyBase
graphql_name 'DestroyContainerRepository'
authorize :destroy_container_image
argument :id,
::Types::GlobalIDType[::ContainerRepository],
required: true,
description: 'ID of the container repository.'
field :container_repository,
Types::ContainerRepositoryType,
null: false,
description: 'Container repository policy after scheduling the deletion.'
def resolve(id:)
container_repository = authorized_find!(id: id)
container_repository.delete_scheduled!
# rubocop:disable CodeReuse/Worker
DeleteContainerRepositoryWorker.perform_async(current_user.id, container_repository.id)
# rubocop:enable CodeReuse/Worker
track_event(:delete_repository, :container)
{
container_repository: container_repository,
errors: []
}
end
end
end
end