Sha256: d618ec817472c0901ad729638cd3a462a083989791a4353ffc9b204aa611b815

Contents?: true

Size: 1.3 KB

Versions: 19

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require_relative 'base'

module Gitlab
  module Triage
    module Action
      class Delete < Base
        class Dry < Delete
          def act
            puts "The following resources will be deleted by the rule **#{policy.name}**:\n\n"
            super
          end

          private

          def perform(resource)
            puts "DELETE resource with type: #{resource[:type]} and id: #{resource_id(resource)}"
          end
        end

        def act
          return unless policy.type&.to_sym == :branches

          policy.resources.each do |resource|
            perform(resource)
          end
        end

        private

        def perform(resource)
          network.delete_api(build_delete_url(resource))
        end

        def build_delete_url(resource)
          delete_url = UrlBuilders::UrlBuilder.new(
            source: policy.source,
            source_id: network.options.source_id,
            resource_type: policy.type,
            resource_id: resource_id(resource),
            network_options: network.options
          ).build

          puts Gitlab::Triage::UI.debug "delete_url: #{delete_url}" if network.options.debug

          delete_url
        end

        def resource_id(resource)
          resource[:name]
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
gitlab-triage-1.44.1 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.44.0 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.43.2 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.43.1 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.43.0 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.42.2 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.42.1 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.42.0 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.41.0 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.40.0 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.30.0 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.29.0 lib/gitlab/triage/action/delete.rb
payping-gitlab-triage-0.1.3 lib/gitlab/triage/action/delete.rb
payping-gitlab-triage-0.1.2 lib/gitlab/triage/action/delete.rb
payping-gitlab-triage-0.1.1 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.28.0 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.27.0 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.26.0 lib/gitlab/triage/action/delete.rb
gitlab-triage-1.25.0 lib/gitlab/triage/action/delete.rb