Class: Actions::Katello::Repository::CloneToVersion

Inherits:
Base
  • Object
show all
Defined in:
app/lib/actions/katello/repository/clone_to_version.rb

Instance Method Summary collapse

Instance Method Details

#extract_rpm_filenames(repos_units, repo_label) ⇒ Object



37
38
39
40
41
42
43
44
# File 'app/lib/actions/katello/repository/clone_to_version.rb', line 37

def extract_rpm_filenames(repos_units, repo_label)
  return if repos_units.blank?

  repo_units = repos_units.detect { |r| r[:label] == repo_label }
  return if repo_units.blank?

  repo_units.fetch(:rpm_filenames, nil)
end

#plan(repositories, content_view_version, destination_repository, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/lib/actions/katello/repository/clone_to_version.rb', line 5

def plan(repositories, content_view_version, destination_repository, options = {})
  incremental = options.fetch(:incremental, false)
  content_view = content_view_version.content_view
  filters = incremental ? [] : content_view.filters.applicable(repositories.first)
  rpm_filenames = extract_rpm_filenames(options.fetch(:repos_units, nil), repositories.first.label)
  fail _('Cannot publish a composite with rpm filenames') if content_view.composite? && rpm_filenames&.any?
  if rpm_filenames&.any?
    verify_rpm_filenames(repositories.first, rpm_filenames)
    Rails.logger.warn("Filters on content view have been overridden by passed-in filename list during publish") if filters.any?
  end

  copy_contents = destination_repository.primary?
  fail _('Cannot publish a link repository if multiple component clones are specified') if !copy_contents && repositories.count > 1

  sequence do
    plan_action(::Actions::Katello::Repository::CloneContents, repositories, destination_repository,
                purge_empty_contents: true,
                filters: filters,
                rpm_filenames: rpm_filenames,
                copy_contents: copy_contents,
                solve_dependencies: content_view.solve_dependencies,
                metadata_generate: !incremental)
  end
end

#verify_rpm_filenames(repo, filenames) ⇒ Object



30
31
32
33
34
35
# File 'app/lib/actions/katello/repository/clone_to_version.rb', line 30

def verify_rpm_filenames(repo, filenames)
  rpms_available = repo.rpms.pluck(:filename)
  filenames.each do |filename|
    fail "%s not available in repository %s" % [filename, repo.label] unless rpms_available.include? filename
  end
end