Sha256: c9f8cd16df125e5d97fd4c56860ed077a047cc2191f07b6881af6334e24324ab

Contents?: true

Size: 1.96 KB

Versions: 10

Compression:

Stored size: 1.96 KB

Contents

module Actions
  module Katello
    module Repository
      class Destroy < Actions::EntryAction
        middleware.use ::Actions::Middleware::RemoteAction

        # options:
        #   skip_environment_update - defaults to false. skips updating the CP environment
        #   planned_destroy - default to false.  destroy the AR object in plan phase instead of finalize
        def plan(repository, options = {})
          planned_destroy = options.fetch(:planned_destroy, false)

          skip_environment_update = options.fetch(:organization_destroy, false)
          action_subject(repository)

          if !planned_destroy && !repository.assert_deletable
            # The repository is going to be deleted in finalize, but it cannot be deleted.
            # Stop now and inform the user.
            fail repository.errors.messages.values.join("\n")
          end

          plan_action(ContentViewPuppetModule::Destroy, repository) if repository.puppet?
          plan_action(Pulp::Repository::Destroy, pulp_id: repository.pulp_id)
          plan_action(Product::ContentDestroy, repository)
          plan_action(Repository::DestroyMedium, repository)

          view_env = repository.content_view.content_view_environment(repository.environment)

          repository.destroy! if planned_destroy

          if !skip_environment_update && ::SETTINGS[:katello][:use_cp] && view_env
            plan_action(ContentView::UpdateEnvironment, repository.content_view, repository.environment)
          end

          plan_self(:user_id => ::User.current.id, :planned_destroy => planned_destroy)
        end

        def finalize
          unless input[:planned_destroy]
            ::User.current = ::User.find(input[:user_id])
            repository = ::Katello::Repository.find(input[:repository][:id])
            repository.destroy!
          end
        ensure
          ::User.current = nil
        end

        def humanized_name
          _("Delete")
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
katello-2.4.5 app/lib/actions/katello/repository/destroy.rb
katello-2.4.4 app/lib/actions/katello/repository/destroy.rb
katello-2.4.3 app/lib/actions/katello/repository/destroy.rb
katello-2.4.2 app/lib/actions/katello/repository/destroy.rb
katello-3.0.0.rc1 app/lib/actions/katello/repository/destroy.rb
katello-2.4.1 app/lib/actions/katello/repository/destroy.rb
katello-2.4.0 app/lib/actions/katello/repository/destroy.rb
katello-2.4.0.rc3 app/lib/actions/katello/repository/destroy.rb
katello-2.4.0.rc2 app/lib/actions/katello/repository/destroy.rb
katello-2.4.0.rc1 app/lib/actions/katello/repository/destroy.rb