From 1faf38668857695b68714d9390ecf1dd37771977 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Thu, 6 Jan 2022 14:54:44 +0100 Subject: [PATCH] Align on pulp_content_url The Pulp content URLs should always respect what's exposed in the pulp_content_url setting. This includes the /pulp/content part. It does highlight a missing setting for pulp_ansible content. Again, Katello should not have to guess URLs but discover it from the infrastructure. --- app/helpers/katello/katello_urls_helper.rb | 10 ++++------ app/models/katello/repository.rb | 14 +++++++++----- app/services/katello/pulp/repository/yum.rb | 1 + app/services/katello/pulp3/repository/yum.rb | 1 + 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/helpers/katello/katello_urls_helper.rb b/app/helpers/katello/katello_urls_helper.rb index 484437cf7ce..f064f309a70 100644 --- a/app/helpers/katello/katello_urls_helper.rb +++ b/app/helpers/katello/katello_urls_helper.rb @@ -45,18 +45,16 @@ def subscription_manager_configuration_url(host = nil, rpm = true, hostname: nil end def repository_url(content_path, _content_type = nil, schema = 'http') return content_path if content_path =~ %r|^([\w\-\+]+)://| - url = if @host.content_source - "#{schema}://#{@host.content_source.hostname}" - else - foreman_settings_url(schema) - end + + url = @host.content_source.pulp_content_url + url.schema = schema content_path = content_path.sub(%r|^/|, '') if @host.content_view && !@host.content_view.default? content_path = [@host.content_view.label, content_path].join('/') end path = ::Katello::Glue::Pulp::Repos.repo_path_from_content_path( @host.lifecycle_environment, content_path) - "#{url}/pulp/content/#{path}" + "#{url}/#{path}" end end end diff --git a/app/models/katello/repository.rb b/app/models/katello/repository.rb index 3955d21ed75..8fd08cbf95e 100644 --- a/app/models/katello/repository.rb +++ b/app/models/katello/repository.rb @@ -427,15 +427,19 @@ def group end def full_path(smart_proxy = nil, force_http = false) - pulp_uri = URI.parse(smart_proxy ? smart_proxy.url : ::SmartProxy.pulp_primary.url) - scheme = force_http ? 'http' : 'https' + smart_proxy ||= ::SmartProxy.pulp_primary + pulp_uri = smart_proxy.pulp_content_url + pulp_uri.scheme = force_http ? 'http' : 'https' + # TODO: this should be normalized in smart_proxy_pulp's setting + pulp_uri.host = pulp_uri.host.downcase if docker? - "#{pulp_uri.host.downcase}/#{container_repository_name}" + "#{pulp_uri.host}/#{container_repository_name}" elsif ansible_collection? - "#{scheme}://#{pulp_uri.host.downcase}/pulp_ansible/galaxy/#{relative_path}/api/" + "#{scheme}://#{pulp_uri.host}/pulp_ansible/galaxy/#{relative_path}/api/" else - "#{scheme}://#{pulp_uri.host.downcase}/pulp/content/#{relative_path}/" + pulp_uri.path += "/#{relative_path}" end + pulp_uri.to_s end def to_hash(content_source = nil, force_http = false) diff --git a/app/services/katello/pulp/repository/yum.rb b/app/services/katello/pulp/repository/yum.rb index 9e1d9849ed2..fe2bea9ef56 100644 --- a/app/services/katello/pulp/repository/yum.rb +++ b/app/services/katello/pulp/repository/yum.rb @@ -24,6 +24,7 @@ def generate_mirror_importer end def partial_repo_path + # TODO: get /pulp/content from pulp_content_url "/pulp/content/#{repo.relative_path}/".sub('//', '/') end diff --git a/app/services/katello/pulp3/repository/yum.rb b/app/services/katello/pulp3/repository/yum.rb index 0bd5976bdeb..eb8d79c8d27 100644 --- a/app/services/katello/pulp3/repository/yum.rb +++ b/app/services/katello/pulp3/repository/yum.rb @@ -92,6 +92,7 @@ def self.distribution_bootable?(distribution) end def partial_repo_path + # TODO: get /pulp/content from pulp_content_url "/pulp/content/#{repo.relative_path}/".sub('//', '/') end