2020-01-11 10:07:49 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ContainerExpirationPolicyService < BaseService
|
2020-06-16 02:08:27 -04:00
|
|
|
InvalidPolicyError = Class.new(StandardError)
|
|
|
|
|
2020-01-11 10:07:49 -05:00
|
|
|
def execute(container_expiration_policy)
|
|
|
|
container_expiration_policy.schedule_next_run!
|
|
|
|
|
|
|
|
container_expiration_policy.container_repositories.find_each do |container_repository|
|
|
|
|
CleanupContainerRepositoryWorker.perform_async(
|
2020-02-13 10:08:52 -05:00
|
|
|
nil,
|
2020-01-11 10:07:49 -05:00
|
|
|
container_repository.id,
|
2020-10-26 14:08:27 -04:00
|
|
|
container_expiration_policy.policy_params
|
|
|
|
.merge(container_expiration_policy: true)
|
2020-01-11 10:07:49 -05:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|