Class: Projects::ContainerRepository::DestroyService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/projects/container_repository/destroy_service.rb

Constant Summary collapse

CLEANUP_TAGS_SERVICE_PARAMS =
{
  'name_regex_delete' => '.*',
  'container_expiration_policy' => true, # to avoid permissions checks
  'keep_latest' => false
}.freeze

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

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

This class inherits a constructor from BaseService

Instance Method Details

#execute(container_repository, disable_timeout: true) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/projects/container_repository/destroy_service.rb', line 12

def execute(container_repository, disable_timeout: true)
  return error('Unauthorized access') unless can_destroy?

  # Delete tags outside of the transaction to avoid hitting an idle-in-transaction timeout
  if delete_tags(container_repository, disable_timeout) &&
      destroy_container_repository(container_repository)
    success
  else
    container_repository.delete_failed!
    error('Deletion failed for container repository')
  end
end