Class: Projects::ContainerRepository::Gitlab::DeleteTagsService

Inherits:
Object
  • Object
show all
Includes:
BaseServiceUtility, Gitlab::Utils::StrongMemoize
Defined in:
app/services/projects/container_repository/gitlab/delete_tags_service.rb

Constant Summary collapse

DISABLED_TIMEOUTS =
[nil, 0].freeze
TimeoutError =
Class.new(StandardError)

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(container_repository, tag_names) ⇒ DeleteTagsService

Returns a new instance of DeleteTagsService.


14
15
16
17
18
# File 'app/services/projects/container_repository/gitlab/delete_tags_service.rb', line 14

def initialize(container_repository, tag_names)
  @container_repository = container_repository
  @tag_names = tag_names
  @deleted_tags = []
end

Instance Method Details

#executeObject

Delete tags by name with a single DELETE request. This is only supported by the GitLab Container Registry fork. See gitlab.com/gitlab-org/gitlab/-/merge_requests/23325 for details.


23
24
25
26
27
28
29
30
# File 'app/services/projects/container_repository/gitlab/delete_tags_service.rb', line 23

def execute
  return success(deleted: []) if @tag_names.empty?

  delete_tags
rescue TimeoutError, ::Faraday::Error => e
  ::Gitlab::ErrorTracking.track_exception(e, tags_count: @tag_names&.size, container_repository_id: @container_repository&.id)
  error('error while deleting tags', nil, pass_back: { deleted: @deleted_tags, exception_class_name: e.class.name })
end