2020-03-13 15:44:24 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ContainerExpirationPolicyService < BaseService
|
2020-06-23 00:09:42 +05:30
|
|
|
InvalidPolicyError = Class.new(StandardError)
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
def execute(container_expiration_policy)
|
|
|
|
container_expiration_policy.schedule_next_run!
|
|
|
|
|
|
|
|
container_expiration_policy.container_repositories.find_each do |container_repository|
|
|
|
|
CleanupContainerRepositoryWorker.perform_async(
|
|
|
|
nil,
|
|
|
|
container_repository.id,
|
2021-01-29 00:20:46 +05:30
|
|
|
container_expiration_policy.policy_params
|
|
|
|
.merge(container_expiration_policy: true)
|
2020-03-13 15:44:24 +05:30
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|