Class: Katello::Pulp3::Repository::Docker

Inherits:
Katello::Pulp3::Repository show all
Defined in:
app/services/katello/pulp3/repository/docker.rb

Constant Summary

Constants inherited from Katello::Pulp3::Repository

COPY_UNIT_PAGE_SIZE

Instance Attribute Summary

Attributes inherited from Katello::Pulp3::Repository

#repo, #smart_proxy

Instance Method Summary collapse

Methods inherited from Katello::Pulp3::Repository

#add_content_for_repo, #api, api, #append_proxy_cacert, #common_remote_options, #compute_remote_options, #content_service, #copy_all, #copy_units_by_href, #copy_version, #core_api, #create, #create_distribution, #create_mirror_entities, #create_options, #create_publication, #create_remote, #delete_distributions, #delete_distributions_by_path, #delete_remote, #delete_repository, #delete_version, #distribution_needs_update?, #distribution_reference, #fail_missing_publication, #generate_backend_object_name, #get_distribution, #get_remote, #initialize, instance_for_type, #list, #lookup_distributions, #lookup_publication, #lookup_version, publication_href?, #publication_options, #published?, #read, #read_distribution, #refresh_distributions, #refresh_if_needed, #refresh_mirror_entities, #remote_partial_update, #remove_content, #repair, #repository_import_content, #repository_reference, #retain_package_versions_count, #save_distribution_references, #should_purge_empty_contents?, #skip_types, #specific_create_options, #ssl_remote_options, #sync, #sync_url_params, #unit_keys, #update, #update_distribution, #update_remote, version_href?, #version_zero?, #with_mirror_adapter

Methods included from ServiceCommon

#create_remote, #create_test_remote, #ignore_404_exception, #reformat_api_exception, #test_remote_name

Methods included from Util::HttpProxy

#proxy, #proxy_host, #proxy_port, #proxy_scheme, #proxy_uri

Constructor Details

This class inherits a constructor from Katello::Pulp3::Repository

Instance Method Details

#add_content(content_unit_href) ⇒ Object



67
68
69
70
# File 'app/services/katello/pulp3/repository/docker.rb', line 67

def add_content(content_unit_href)
  content_unit_href = [content_unit_href] unless content_unit_href.is_a?(Array)
  api.repositories_api.add(repository_reference.repository_href, content_units: content_unit_href)
end

#copy_content_for_source(source_repository, options = {}) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'app/services/katello/pulp3/repository/docker.rb', line 83

def copy_content_for_source(source_repository, options = {})
  filters = ContentViewDockerFilter.where(:id => options[:filter_ids])
  include_list_ids = []
  exclude_list_ids = []
  filters.each do |filter|
    if filter.inclusion
      include_list_ids += filter.content_unit_pulp_ids(source_repository)
    else
      exclude_list_ids += filter.content_unit_pulp_ids(source_repository)
    end
  end

  if include_list_ids.empty?
    copy_units_recursively(source_repository.docker_tags.pluck(:pulp_id).sort - exclude_list_ids, true)
  else
    copy_units_recursively(include_list_ids - exclude_list_ids, true)
  end
end

#copy_units_recursively(unit_hrefs, clear_repo = false) ⇒ Object



72
73
74
75
76
77
78
79
80
81
# File 'app/services/katello/pulp3/repository/docker.rb', line 72

def copy_units_recursively(unit_hrefs, clear_repo = false)
  tasks = []
  if clear_repo
    tasks << api.repositories_api.remove(repository_reference.repository_href,
                                         api.class.recursive_manage_class.new(:content_units => ["*"]))
  end
  tasks << api.repositories_api.add(repository_reference.repository_href,
                                    api.class.recursive_manage_class.new(content_units: unit_hrefs))
  tasks
end

#create_version(options = {}) ⇒ Object



55
56
57
58
59
60
# File 'app/services/katello/pulp3/repository/docker.rb', line 55

def create_version(options = {})
  api.repositories_api.add(repository_reference.repository_href,
                           api.class.recursive_manage_class.new(content_units: options[:add_content_units]))
  api.repositories_api.remove(repository_reference.repository_href,
                              api.class.recursive_manage_class.new(content_units: options[:remove_content_units]))
end

#distribution_options(path) ⇒ Object



47
48
49
50
51
52
53
# File 'app/services/katello/pulp3/repository/docker.rb', line 47

def distribution_options(path)
  {
    base_path: path,
    repository_version: repo.version_href,
    name: "#{generate_backend_object_name}"
  }
end

#mirror_remote_optionsObject



38
39
40
41
42
43
44
45
# File 'app/services/katello/pulp3/repository/docker.rb', line 38

def mirror_remote_options
  super.merge(
    {
      url: "https://#{SmartProxy.pulp_primary.pulp3_host!.downcase}",
      upstream_name: repo.container_repository_name
    }
  )
end

#partial_repo_pathObject



11
12
13
# File 'app/services/katello/pulp3/repository/docker.rb', line 11

def partial_repo_path
  ''
end

#relative_pathObject



7
8
9
# File 'app/services/katello/pulp3/repository/docker.rb', line 7

def relative_path
  repo.container_repository_name
end

#remote_optionsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/katello/pulp3/repository/docker.rb', line 15

def remote_options
  options = {url: root.url, upstream_name: root.docker_upstream_name, policy: root.download_policy}
  if root.include_tags&.any?
    options[:include_tags] = root.include_tags
  else
    options[:include_tags] = nil
  end
  if root.exclude_tags&.any?
    options[:exclude_tags] = root.exclude_tags
  else
    options[:exclude_tags] = nil
  end
  common_remote_options.merge(options)
end

#secure_distribution_options(path) ⇒ Object



30
31
32
33
34
35
36
# File 'app/services/katello/pulp3/repository/docker.rb', line 30

def secure_distribution_options(path)
  #we never need a content guard for docker, and pulp creates one behind the scenes,
  # so we have to make sure not to try to clear it out
  options = super
  options.delete(:content_guard)
  options
end

#tag_manifest(name, digest) ⇒ Object



62
63
64
65
# File 'app/services/katello/pulp3/repository/docker.rb', line 62

def tag_manifest(name, digest)
  api.repositories_api.tag(repository_reference.repository_href,
                           api.class.tag_image_class.new(tag: name, digest: digest))
end