Class: Katello::Pulp3::ContentViewVersion::ImportableRepositories

Inherits:
Object
  • Object
show all
Defined in:
app/services/katello/pulp3/content_view_version/importable_repositories.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(organization:, metadata_repositories:, syncable_format: false, path: nil) ⇒ ImportableRepositories

Returns a new instance of ImportableRepositories.



7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/katello/pulp3/content_view_version/importable_repositories.rb', line 7

def initialize(organization:,
               metadata_repositories:,
               syncable_format: false,
               path: nil)
  @organization = organization
   = 
  @creatable = []
  @updatable = []
  @syncable_format = syncable_format
  @path = path
end

Instance Attribute Details

#creatableObject (readonly)

Returns the value of attribute creatable.



5
6
7
# File 'app/services/katello/pulp3/content_view_version/importable_repositories.rb', line 5

def creatable
  @creatable
end

#updatableObject (readonly)

Returns the value of attribute updatable.



5
6
7
# File 'app/services/katello/pulp3/content_view_version/importable_repositories.rb', line 5

def updatable
  @updatable
end

Instance Method Details

#generate!Object



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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/services/katello/pulp3/content_view_version/importable_repositories.rb', line 19

def generate!
  # For Red Hat repositories or Custom Repositories in the metadata exclusively
  # Set up a 2 different list of importable root repositories
  # creatable: repos that are part of the metadata but not in the library.
  #         They are ready to be created
  # updatable: repo that are both in the metadata and library.
  #         These may contain updates to the repo and hence ready to be updated.
  .each do |repo|
    product = (repo)
    fail _("Unable to find product '%s' in organization '%s'" % [repo.product.label, @organization.name]) if product.blank?

    root = product.root_repositories.find do |r|
      if repo.content&.id && repo.redhat
        r.content.cp_content_id == repo.content.id &&
          r.arch == repo.arch &&
          r.major == repo.major &&
          r.minor == repo.minor
      else
        r.label == repo.label
      end
    end

    if root
      updatable << { repository: root, options: update_repo_params(repo) }
    elsif repo.redhat
      product_content = fetch_product_content(repo.content, product)
      substitutions = {
        basearch: repo.arch,
        releasever: repo.minor
      }
      creatable << { product: product,
                     content: product_content,
                     substitutions: substitutions,
                     override_url: fetch_feed_url(repo)
                   }
    else
      creatable << { repository: product.add_repo(create_repo_params(repo, product)) }
    end
  end
end