diff options
Diffstat (limited to 'app/services/terraform/states/destroy_service.rb')
-rw-r--r-- | app/services/terraform/states/destroy_service.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/app/services/terraform/states/destroy_service.rb b/app/services/terraform/states/destroy_service.rb new file mode 100644 index 00000000000..728533a60ed --- /dev/null +++ b/app/services/terraform/states/destroy_service.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Terraform + module States + class DestroyService + def initialize(state) + @state = state + end + + def execute + return unless state.deleted_at? + + state.versions.each_batch(column: :version) do |batch| + process_batch(batch) + end + + state.destroy! + end + + private + + attr_reader :state + + # Overridden in EE + def process_batch(batch) + batch.each do |version| + version.file.remove! + end + end + end + end +end + +Terraform::States::DestroyService.prepend_mod |