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

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

Constant Summary

Constants included from Timeoutable

Timeoutable::DISABLED_TIMEOUTS, Timeoutable::TimeoutError

Instance Method Summary collapse

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.



11
12
13
14
15
# File 'app/services/projects/container_repository/gitlab/delete_tags_service.rb', line 11

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.



20
21
22
23
24
25
26
27
# File 'app/services/projects/container_repository/gitlab/delete_tags_service.rb', line 20

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