Sha256: eafdade1cb94c49de49b00abf467bcf335bac52d69c2f1f0fff5ef3777ae1d8e

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 KB

Contents

module Actions
  module Katello
    module Provider
      class Update < Actions::EntryAction
        def plan(provider, params)
          action_subject(provider)

          update_url(provider, params[:redhat_repository_url]) if params[:redhat_repository_url]
        end

        def humanized_name
          _("Update")
        end

        private

        def update_url(provider, base_url)
          current_base_url = provider.repository_url
          provider.update_attributes!(:repository_url => base_url)

          if provider.redhat_provider?
            provider.products.enabled.each do |product|
              update_repository_urls(product, current_base_url, base_url)
            end
          end
        end

        def update_repository_urls(product, current_base_url, new_base_url)
          product.repositories.each do |repository|
            next unless repository.url
            path = repository.url.split(current_base_url)[1]
            url = "#{new_base_url}#{path}"
            plan_action(::Actions::Katello::Repository::Update, repository.root, :url => url)
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
katello-3.12.3 app/lib/actions/katello/provider/update.rb
katello-3.12.2 app/lib/actions/katello/provider/update.rb
katello-3.12.1 app/lib/actions/katello/provider/update.rb
katello-3.11.2 app/lib/actions/katello/provider/update.rb
katello-3.12.0 app/lib/actions/katello/provider/update.rb
katello-3.12.0.rc2 app/lib/actions/katello/provider/update.rb
katello-3.12.0.rc1 app/lib/actions/katello/provider/update.rb
katello-3.11.1 app/lib/actions/katello/provider/update.rb
katello-3.11.0 app/lib/actions/katello/provider/update.rb
katello-3.11.0.rc2 app/lib/actions/katello/provider/update.rb
katello-3.11.0.rc1 app/lib/actions/katello/provider/update.rb