Skip to content

Commit

Permalink
Ruby 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ofedoren authored and evgeni committed Feb 14, 2024
1 parent 095f4ce commit d2302e1
Show file tree
Hide file tree
Showing 32 changed files with 166 additions and 153 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ AllCops:
- '**/*.rb'
- app/views/**/*.rabl
- '**/*.rake'
TargetRubyVersion: 2.5
TargetRubyVersion: 2.7

Metrics/MethodLength:
Description: 'Avoid methods longer than 30 lines of code.'
Expand Down
6 changes: 3 additions & 3 deletions app/lib/actions/katello/content_view/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Publish < Actions::EntryAction
def plan(content_view, description = "", options = {importing: false, syncable: false}) # rubocop:disable Metrics/PerceivedComplexity
action_subject(content_view)

content_view.check_ready_to_publish!(options.slice(:importing, :syncable))
content_view.check_ready_to_publish!(**options.slice(:importing, :syncable))
unless options[:importing] || options[:syncable]
::Katello::Util::CandlepinRepositoryChecker.check_repositories_for_publish!(content_view)
end
Expand Down Expand Up @@ -57,7 +57,7 @@ def plan(content_view, description = "", options = {importing: false, syncable:
separated_repo_map = separated_repo_mapping(repository_mapping, content_view.solve_dependencies)

if options[:importing]
handle_import(version, options.slice(:path, :metadata))
handle_import(version, **options.slice(:path, :metadata))
elsif separated_repo_map[:pulp3_yum_multicopy].keys.flatten.present?
plan_action(Repository::MultiCloneToVersion, separated_repo_map[:pulp3_yum_multicopy], version)
end
Expand Down Expand Up @@ -203,7 +203,7 @@ def find_environments(environment_ids)

def handle_import(version, path:, metadata:)
sequence do
plan_action(::Actions::Pulp3::Orchestration::ContentViewVersion::Import, version, path: path, metadata: metadata)
plan_action(::Actions::Pulp3::Orchestration::ContentViewVersion::Import, version, { path: path, metadata: metadata })
concurrence do
version.importable_repositories.pluck(:id).each do |id|
# need to force full_indexing for these version repositories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ module Actions
module Katello
module ContentViewVersion
class AutoCreateProducts < Actions::Base
def plan(import:)
def plan(opts = {})
helper = ::Katello::Pulp3::ContentViewVersion::ImportableProducts.
new(organization: import.organization,
metadata_products: import.metadata_map.products)
new(organization: opts[:import].organization,
metadata_products: opts[:import].metadata_map.products)
helper.generate!
concurrence do
helper.creatable.each do |product|
plan_action(::Actions::Katello::Product::Create, product[:product], import.organization)
plan_action(::Actions::Katello::Product::Create, product[:product], opts[:import].organization)
end
helper.updatable.each do |product|
plan_action(::Actions::Katello::Product::Update, product[:product], product[:options])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ module Actions
module Katello
module ContentViewVersion
class AutoCreateRedhatRepositories < Actions::Base
def plan(import:, path:)
def plan(opts = {})
helper = ::Katello::Pulp3::ContentViewVersion::ImportableRepositories.new(
organization: import.organization,
metadata_repositories: import.metadata_map.repositories.select { |r| r.redhat },
syncable_format: import.metadata_map.syncable_format?,
path: path
organization: opts[:import].organization,
metadata_repositories: opts[:import].metadata_map.repositories.select { |r| r.redhat },
syncable_format: opts[:import].metadata_map.syncable_format?,
path: opts[:path]
)
helper.generate!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ module Actions
module Katello
module ContentViewVersion
class AutoCreateRepositories < Actions::Base
def plan(import:, path:)
def plan(opts = {})
helper = ::Katello::Pulp3::ContentViewVersion::ImportableRepositories.new(
organization: import.organization,
metadata_repositories: import.metadata_map.repositories.select { |r| !r.redhat },
syncable_format: import.metadata_map.syncable_format?,
path: path
organization: opts[:import].organization,
metadata_repositories: opts[:import].metadata_map.repositories.select { |r| !r.redhat },
syncable_format: opts[:import].metadata_map.syncable_format?,
path: opts[:path]
)
helper.generate!

Expand Down
27 changes: 14 additions & 13 deletions app/lib/actions/katello/content_view_version/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,46 @@ module Actions
module Katello
module ContentViewVersion
class Import < Actions::EntryAction
def plan(organization:, path:, metadata:)
metadata_map = ::Katello::Pulp3::ContentViewVersion::MetadataMap.new(metadata: metadata)
def plan(opts = {})
metadata_map = ::Katello::Pulp3::ContentViewVersion::MetadataMap.new(metadata: opts[:metadata])

import = ::Katello::Pulp3::ContentViewVersion::Import.new(
organization: organization,
organization: opts[:organization],
metadata_map: metadata_map,
path: path,
path: opts[:path],
smart_proxy: SmartProxy.pulp_primary!
)

import.check!

gpg_helper = ::Katello::Pulp3::ContentViewVersion::ImportGpgKeys.
new(organization: organization,
new(organization: opts[:organization],
metadata_gpg_keys: metadata_map.gpg_keys)
gpg_helper.import!

sequence do
plan_action(AutoCreateProducts, import: import)
plan_action(AutoCreateRepositories, import: import, path: path)
plan_action(AutoCreateRedhatRepositories, import: import, path: path)
plan_action(AutoCreateProducts, { import: import })
plan_action(AutoCreateRepositories, { import: import, path: opts[:path] })
plan_action(AutoCreateRedhatRepositories, { import: import, path: opts[:path] })

if metadata_map.syncable_format?
plan_action(::Actions::BulkAction,
::Actions::Katello::Repository::Sync,
import.intersecting_repos_library_and_metadata.exportable(format: metadata_map.format),
skip_candlepin_check: true
{ skip_candlepin_check: true }
)
end

if import.content_view
plan_action(ResetContentViewRepositoriesFromMetadata, import: import)
plan_action(ResetContentViewRepositoriesFromMetadata, { import: import })
plan_action(::Actions::Katello::ContentView::Publish, import.content_view, metadata_map.content_view_version.description,
path: path,
metadata: metadata,
{ path: opts[:path],
metadata: opts[:metadata],
importing: !metadata_map.syncable_format?,
syncable: metadata_map.syncable_format?,
major: metadata_map.content_view_version.major,
minor: metadata_map.content_view_version.minor)
minor: metadata_map.content_view_version.minor
})
plan_self(content_view_id: import.content_view.id)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ module Actions
module Katello
module ContentViewVersion
class ImportLibrary < Actions::EntryAction
def plan(organization, path:, metadata:)
def plan(organization, opts = {})
action_subject(organization)
plan_action(::Actions::Katello::ContentViewVersion::Import, organization: organization,
path: path,
metadata: metadata)
plan_action(::Actions::Katello::ContentViewVersion::Import, { organization: organization,
path: opts[:path],
metadata: opts[:metadata] })
end

def humanized_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ module Actions
module Katello
module ContentViewVersion
class ImportRepository < Actions::EntryAction
def plan(organization, path:, metadata:)
def plan(organization, opts = {})
action_subject(organization)
sequence do
plan_action(::Actions::Katello::ContentViewVersion::Import,
organization: organization,
path: path,
metadata: metadata)
path: opts[:path],
metadata: opts[:metadata])
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module Actions
module Katello
module ContentViewVersion
class ResetContentViewRepositoriesFromMetadata < Actions::Base
def plan(import:)
import.reset_content_view_repositories!
def plan(opts = {})
opts[:import].reset_content_view_repositories!
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/lib/actions/katello/organization/manifest_delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def plan(organization)
action_subject(organization)

sequence do
plan_action(Candlepin::Owner::DestroyImports, label: organization.label)
plan_action(Candlepin::Owner::DestroyImports, { label: organization.label })

repositories = ::Katello::Repository.in_default_view.in_product(::Katello::Product.redhat.in_org(organization))
repositories.each do |repo|
Expand Down
32 changes: 16 additions & 16 deletions app/lib/actions/katello/organization/manifest_refresh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ def plan(organization)
:organization_name => organization.name
)
upstream_update = plan_action(Candlepin::Owner::UpstreamUpdate,
:organization_id => organization.id,
:upstream => upstream)
{ :organization_id => organization.id,
:upstream => upstream })
export_action = plan_action(Candlepin::Owner::StartUpstreamExport,
:organization_id => organization.id,
:upstream => upstream,
:path => path,
:dependency => upstream_update.output)
{ :organization_id => organization.id,
:upstream => upstream,
:path => path,
:dependency => upstream_update.output })
retrieved_export = plan_action(Candlepin::Owner::RetrieveUpstreamExport,
:export_id => export_action.output[:task]['resultData']['exportId'],
:organization_id => organization.id,
:upstream => upstream,
:path => path,
:dependency => export_action.output)
{ :export_id => export_action.output[:task]['resultData']['exportId'],
:organization_id => organization.id,
:upstream => upstream,
:path => path,
:dependency => export_action.output })
owner_import = plan_action(Candlepin::Owner::Import,
:label => organization.label,
:path => path,
:dependency => retrieved_export.output)
{ :label => organization.label,
:path => path,
:dependency => retrieved_export.output })
import_products = plan_action(Candlepin::Owner::ImportProducts,
:organization_id => organization.id,
:dependency => owner_import.output)
{ :organization_id => organization.id,
:dependency => owner_import.output })
plan_action(Katello::Organization::EnvironmentContentsRefresh,
organization)
if manifest_update
Expand Down
35 changes: 20 additions & 15 deletions app/lib/actions/pulp3/orchestration/content_view_version/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,35 @@ class Export < Actions::EntryAction
param :export_path, String
end

def plan(content_view_version:, destination_server: nil,
chunk_size: nil, from_history: nil,
validate_incremental: true,
fail_on_missing_content: false,
format: ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE)
def plan(opts = {})
options = {
content_view_version: nil, destination_server: nil,
chunk_size: nil, from_history: nil,
validate_incremental: true,
fail_on_missing_content: false,
format: ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE
}.merge(opts)
content_view_version = options[:content_view_version]
format = options[:format]
smart_proxy = SmartProxy.pulp_primary!
from_content_view_version = from_history&.content_view_version
from_content_view_version = options[:from_history]&.content_view_version
export_service = ::Katello::Pulp3::ContentViewVersion::Export.create(
smart_proxy: smart_proxy,
content_view_version: content_view_version,
destination_server: destination_server,
destination_server: options[:destination_server],
from_content_view_version: from_content_view_version,
format: format)
export_service.validate!(fail_on_missing_content: fail_on_missing_content,
validate_incremental: validate_incremental,
chunk_size: chunk_size)
export_service.validate!(fail_on_missing_content: options[:fail_on_missing_content],
validate_incremental: options[:validate_incremental],
chunk_size: options[:chunk_size])

if format == ::Katello::Pulp3::ContentViewVersion::Export::SYNCABLE
sequence do
export_output = plan_action(SyncableExport,
content_view_version: content_view_version,
from_content_view_version: from_history&.content_view_version,
from_content_view_version: options[:from_history]&.content_view_version,
smart_proxy: smart_proxy,
destination_server: destination_server).output
destination_server: options[:destination_server]).output
plan_self(export_history_id: export_output[:export_history_id],
export_path: export_output[:export_path])
end
Expand All @@ -52,14 +57,14 @@ def plan(content_view_version:, destination_server: nil,
action_output = plan_action(::Actions::Pulp3::ContentViewVersion::CreateExporter,
content_view_version_id: content_view_version.id,
smart_proxy_id: smart_proxy.id,
destination_server: destination_server,
destination_server: options[:destination_server],
format: format).output

plan_action(::Actions::Pulp3::ContentViewVersion::Export,
content_view_version_id: content_view_version.id,
smart_proxy_id: smart_proxy.id,
exporter_data: action_output[:exporter_data],
chunk_size: chunk_size,
chunk_size: options[:chunk_size],
from_content_view_version_id: from_content_view_version&.id,
format: format)

Expand All @@ -70,7 +75,7 @@ def plan(content_view_version:, destination_server: nil,
pulp_href: action_output[:exporter_data][:pulp_href],
content_view_version_id: content_view_version.id,
from_content_view_version_id: from_content_view_version&.id,
destination_server: destination_server,
destination_server: options[:destination_server],
format: format
).output

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,33 @@ module Pulp3
module Orchestration
module ContentViewVersion
class ExportLibrary < Actions::EntryAction
def plan(organization, destination_server: nil,
chunk_size: nil,
from_history: nil,
fail_on_missing_content: false,
format: ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE)
def plan(organization, opts = {})
options = {
destination_server: nil,
chunk_size: nil,
from_history: nil,
fail_on_missing_content: false,
format: ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE
}.merge(opts)
action_subject(organization)
validate_repositories_immediate!(organization) if fail_on_missing_content
content_view = ::Katello::Pulp3::ContentViewVersion::Export.find_library_export_view(destination_server: destination_server,
validate_repositories_immediate!(organization) if options[:fail_on_missing_content]
content_view = ::Katello::Pulp3::ContentViewVersion::Export.find_library_export_view(destination_server: options[:destination_server],
organization: organization,
create_by_default: true,
format: format)
repo_ids_in_library = organization.default_content_view_version.repositories.exportable(format: format).immediate_or_none.pluck(:id)
format: options[:format])
repo_ids_in_library = organization.default_content_view_version.repositories.exportable(format: options[:format]).immediate_or_none.pluck(:id)
content_view.update!(repository_ids: repo_ids_in_library)

sequence do
publish_action = plan_action(::Actions::Katello::ContentView::Publish, content_view, '')
export_action = plan_action(Actions::Katello::ContentViewVersion::Export,
content_view_version: publish_action.version,
destination_server: destination_server,
chunk_size: chunk_size,
from_history: from_history,
destination_server: options[:destination_server],
chunk_size: options[:chunk_size],
from_history: options[:from_history],
validate_incremental: false,
fail_on_missing_content: fail_on_missing_content,
format: format)
fail_on_missing_content: options[:fail_on_missing_content],
format: options[:format])
plan_self(export_action_output: export_action.output)
end
end
Expand Down
Loading

0 comments on commit d2302e1

Please sign in to comment.