Class: Projects::ContainerRepository::CleanupTagsService

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

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) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/services/projects/container_repository/cleanup_tags_service.rb', line 6

def execute(container_repository)
  return error('feature disabled') unless can_use?
  return error('access denied') unless can_destroy?
  return error('invalid regex') unless valid_regex?

  tags = container_repository.tags
  tags = without_latest(tags)
  tags = filter_by_name(tags)
  tags = filter_keep_n(tags)
  tags = filter_by_older_than(tags)

  delete_tags(container_repository, tags)
end