Class: Projects::ContainerRepository::Gitlab::DeleteTagsService
- Inherits:
-
Object
- Object
- Projects::ContainerRepository::Gitlab::DeleteTagsService
- Includes:
- BaseServiceUtility, ContainerRegistry::Protection::Concerns::TagRule, Gitlab::Utils::StrongMemoize, Timeoutable
- Defined in:
- app/services/projects/container_repository/gitlab/delete_tags_service.rb
Constant Summary collapse
- PROTECTED_TAGS_ERROR_MESSAGE =
'cannot delete protected tag(s)'
Constants included from Timeoutable
Timeoutable::DISABLED_TIMEOUTS, Timeoutable::TimeoutError
Instance Method Summary collapse
-
#execute ⇒ Object
Delete tags by name with a single DELETE request.
-
#initialize(current_user:, container_repository:, tag_names:) ⇒ DeleteTagsService
constructor
A new instance of DeleteTagsService.
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
Constructor Details
#initialize(current_user:, container_repository:, tag_names:) ⇒ DeleteTagsService
Returns a new instance of DeleteTagsService.
14 15 16 17 18 19 20 |
# File 'app/services/projects/container_repository/gitlab/delete_tags_service.rb', line 14 def initialize(current_user:, container_repository:, tag_names:) @current_user = current_user @container_repository = container_repository @project = container_repository.project @tag_names = tag_names @deleted_tags = [] end |
Instance Method Details
#execute ⇒ Object
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.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/services/projects/container_repository/gitlab/delete_tags_service.rb', line 25 def execute return success(deleted: []) if tag_names.empty? filter_out_protected! return error(PROTECTED_TAGS_ERROR_MESSAGE, pass_back: { deleted: [] }) if tag_names.empty? 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: , exception_class_name: e.class.name }) end |