Class: Katello::Pulp3::ContentViewVersion::MetadataGenerator
- Inherits:
-
Object
- Object
- Katello::Pulp3::ContentViewVersion::MetadataGenerator
- Defined in:
- app/services/katello/pulp3/content_view_version/metadata_generator.rb
Instance Attribute Summary collapse
-
#export_service ⇒ Object
Returns the value of attribute export_service.
-
#gpg_keys ⇒ Object
Returns the value of attribute gpg_keys.
-
#products ⇒ Object
Returns the value of attribute products.
Instance Method Summary collapse
- #generate! ⇒ Object
- #generate_content_metadata(repo) ⇒ Object
- #generate_gpg_metadata(gpg) ⇒ Object
- #generate_product_metadata(product) ⇒ Object
- #generate_repository_metadata(repo) ⇒ Object
-
#initialize(export_service:) ⇒ MetadataGenerator
constructor
A new instance of MetadataGenerator.
- #zip_gpg_keys(entities) ⇒ Object
- #zip_products(repos) ⇒ Object
Constructor Details
#initialize(export_service:) ⇒ MetadataGenerator
Returns a new instance of MetadataGenerator.
11 12 13 14 15 |
# File 'app/services/katello/pulp3/content_view_version/metadata_generator.rb', line 11 def initialize(export_service:) self.export_service = export_service self.gpg_keys = {} self.products = {} end |
Instance Attribute Details
#export_service ⇒ Object
Returns the value of attribute export_service.
5 6 7 |
# File 'app/services/katello/pulp3/content_view_version/metadata_generator.rb', line 5 def export_service @export_service end |
#gpg_keys ⇒ Object
Returns the value of attribute gpg_keys.
5 6 7 |
# File 'app/services/katello/pulp3/content_view_version/metadata_generator.rb', line 5 def gpg_keys @gpg_keys end |
#products ⇒ Object
Returns the value of attribute products.
5 6 7 |
# File 'app/services/katello/pulp3/content_view_version/metadata_generator.rb', line 5 def products @products end |
Instance Method Details
#generate! ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/services/katello/pulp3/content_view_version/metadata_generator.rb', line 17 def generate! ret = { organization: organization.name, base_path: Setting['pulpcore_export_destination'], repositories: {}, content_view: content_view.slice(:name, :label, :description, :generated_for), content_view_version: content_view_version.slice(:major, :minor, :description), incremental: from_content_view_version.present?, format: export_service.format } unless from_content_view_version.blank? ret[:from_content_view_version] = from_content_view_version.slice(:major, :minor) end repositories.each do |repo| next if repo.version_href.blank? pulp3_repo = export_service.fetch_repository_info(repo.version_href).name ret[:repositories][pulp3_repo] = (repo) end zip_products(ret[:repositories].values) zip_gpg_keys(ret[:repositories].values) zip_gpg_keys(products.values) ret[:products] = products ret[:gpg_keys] = gpg_keys ret end |
#generate_content_metadata(repo) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/services/katello/pulp3/content_view_version/metadata_generator.rb', line 66 def (repo) content = repo.content return {} if content.blank? content_data = Katello::Content.substitute_content_path(arch: repo.arch, releasever: repo.minor, content_path: content.content_url) { id: content.cp_content_id, label: content.label, url: content_data[:path] } end |
#generate_gpg_metadata(gpg) ⇒ Object
61 62 63 64 |
# File 'app/services/katello/pulp3/content_view_version/metadata_generator.rb', line 61 def (gpg) return {} if gpg.blank? gpg.slice(:name, :content_type, :content) end |
#generate_product_metadata(product) ⇒ Object
55 56 57 58 59 |
# File 'app/services/katello/pulp3/content_view_version/metadata_generator.rb', line 55 def (product) product.slice(:name, :label, :description, :cp_id). merge(gpg_key: (product.gpg_key), redhat: product.redhat?) end |
#generate_repository_metadata(repo) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'app/services/katello/pulp3/content_view_version/metadata_generator.rb', line 45 def (repo) repo.slice(:name, :label, :description, :arch, :content_type, :unprotected, :checksum_type, :os_versions, :major, :minor, :download_policy, :mirroring_policy). merge(product: (repo.product), gpg_key: (repo.gpg_key), content: (repo), redhat: repo.redhat?) end |
#zip_gpg_keys(entities) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'app/services/katello/pulp3/content_view_version/metadata_generator.rb', line 78 def zip_gpg_keys(entities) # this goes through each repo/product # identifies gpg keys # updates the gpg_keys map if necessary # replaces the value of gpg_key by just the name # For example: # Input: {label: 'repo', gpg_key: {name: 'who', content: 'great'}} # Output: {label: 'repo', gpg_key: {name: 'who'}} entities.each do |entity| gpg = entity[:gpg_key] unless gpg.blank? || gpg_keys.key?(gpg[:name]) gpg_keys[gpg[:name]] = gpg end entity[:gpg_key] = gpg.slice(:name) end end |
#zip_products(repos) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/services/katello/pulp3/content_view_version/metadata_generator.rb', line 95 def zip_products(repos) # this goes through each repo # identifies product # updates the products map if necessary # replaces the value of product by just the label # For example: # Input: {label: 'repo', product: {name: 'prod', label: 'foo', description: 'great'}} # Output: {label: 'repo', product: {label: 'foo'}} repos.each do |repo| product = repo[:product] unless products.key?(product[:label]) products[product[:label]] = product end repo[:product] = product.slice(:label) end end |