Sha256: 330d959e53e860f6341a2a5435d06fe5ecfff154fdca74219d795fbb441cf32d

Contents?: true

Size: 1.98 KB

Versions: 8

Compression:

Stored size: 1.98 KB

Contents

module Actions
  module Katello
    module Product
      class ContentCreate < Actions::Base
        middleware.use Actions::Middleware::RemoteAction

        def plan(repository)
          sequence do
            if repository.content.nil?
              content_create = plan_action(Candlepin::Product::ContentCreate,
                                           name:        repository.name,
                                           type:        repository.content_type,
                                           label:       repository.custom_content_label,
                                           content_url: content_url(repository))
              content_id = content_create.output[:response][:id]
              plan_action(Candlepin::Product::ContentAdd,
                                    product_id: repository.product.cp_id,
                                    content_id: content_id)

            else
              content_id = repository.content_id
            end

            if repository.gpg_key
              plan_action(Candlepin::Product::ContentUpdate,
                          content_id:  content_id,
                          name:        repository.name,
                          type:        repository.content_type,
                          label:       repository.custom_content_label,
                          content_url: content_url(repository),
                          gpg_key_url: repository.yum_gpg_key_url)
            end

            plan_self(repository_id: repository.id,
                      content_id: content_id)
          end
        end

        def finalize
          repository = ::Katello::Repository.find(input[:repository_id])
          repository.content_id = input[:content_id]
          repository.save!
        end

        private

        def content_url(repository)
          ::Katello::Glue::Pulp::Repos.custom_content_path(repository.product,
                                                           repository.label)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
katello-3.3.2 app/lib/actions/katello/product/content_create.rb
katello-3.3.1.1 app/lib/actions/katello/product/content_create.rb
katello-3.3.1 app/lib/actions/katello/product/content_create.rb
katello-3.3.0.1 app/lib/actions/katello/product/content_create.rb
katello-3.3.0 app/lib/actions/katello/product/content_create.rb
katello-3.3.0.rc2 app/lib/actions/katello/product/content_create.rb
katello-3.3.0.rc1.1 app/lib/actions/katello/product/content_create.rb
katello-3.3.0.rc1 app/lib/actions/katello/product/content_create.rb