Skip to content

Commit c5beb0a

Browse files
quba42sbernhard
authored andcommitted
Fixes #38912 - Update deb content URL options via metadata generate
1 parent adbb150 commit c5beb0a

File tree

14 files changed

+7814
-4513
lines changed

14 files changed

+7814
-4513
lines changed

app/lib/actions/katello/repository/metadata_generate.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ module Katello
33
module Repository
44
class MetadataGenerate < Actions::EntryAction
55
def plan(repository, options = {})
6-
return if repository.root.is_container_push && repository.library_instance?
6+
root = repository.root
7+
return if root.is_container_push && repository.library_instance?
78
action_subject(repository)
89
repository.check_ready_to_act!
910
source_repository = options.fetch(:source_repository, nil)
@@ -17,6 +18,20 @@ def plan(repository, options = {})
1718
:force_publication => force_publication,
1819
:source_repository => source_repository,
1920
:matching_content => matching_content)
21+
22+
if repository.deb? && repository.content && !repository.content.content_url.end_with?(repository.deb_content_url_options)
23+
plan_action(::Actions::Candlepin::Product::ContentUpdate,
24+
owner: repository.organization.label,
25+
repository_id: repository.id,
26+
name: root.name,
27+
type: root.content_type,
28+
arches: root.format_arches,
29+
label: repository.content.label,
30+
content_url: root.custom_content_path,
31+
gpg_key_url: repository.yum_gpg_key_url,
32+
os_versions: root.os_versions&.join(','),
33+
metadata_expire: root.metadata_expire)
34+
end
2035
end
2136

2237
def resource_locks

app/services/katello/pulp3/repository/apt.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def initialize_empty
2727
def pulp_components
2828
return [] if repo.version_href.blank?
2929
return ["all"] if version_missing_structure_content?
30-
pulp_primary_api.content_release_components_api.list({:repository_version => repo.version_href}).results.map { |x| x.plain_component }.uniq
30+
pulp_primary_api.content_release_components_api.list({:repository_version => repo.version_href}).results.map { |x| x.plain_component }.uniq.sort
3131
end
3232

3333
def sanitize_pulp_distribution(distribution)
@@ -40,7 +40,7 @@ def sanitize_pulp_distribution(distribution)
4040
def pulp_distributions
4141
return [] if repo.version_href.blank?
4242
return ["default"] if version_missing_structure_content?
43-
pulp_primary_api.content_release_components_api.list({:repository_version => repo.version_href}).results.map { |x| sanitize_pulp_distribution(x.distribution) }.uniq
43+
pulp_primary_api.content_release_components_api.list({:repository_version => repo.version_href}).results.map { |x| sanitize_pulp_distribution(x.distribution) }.uniq.sort
4444
end
4545

4646
def remote_options

test/actions/katello/repository/metadata_generate_test.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ module Actions
88

99
let(:action_class) { ::Actions::Katello::Repository::MetadataGenerate }
1010
let(:pulp_metadata_generate_class) { ::Actions::Pulp3::Orchestration::Repository::GenerateMetadata }
11+
let(:candlepin_product_content_update_class) { ::Actions::Candlepin::Product::ContentUpdate }
1112
let(:success_task) { ForemanTasks::Task::DynflowTask.create!(state: :success, result: "good") }
1213
let(:yum_repo) { katello_repositories(:fedora_17_x86_64) }
1314
let(:yum_repo2) { katello_repositories(:fedora_17_x86_64_dev) }
15+
let(:deb_repo) { katello_repositories(:debian_10_amd64) }
1416
let(:action_options) do
1517
{
1618
:source_repository => nil,
@@ -27,6 +29,7 @@ module Actions
2729

2830
assert_action_planned_with(action, pulp_metadata_generate_class, yum_repo, SmartProxy.pulp_primary,
2931
action_options)
32+
refute_action_planned(action, candlepin_product_content_update_class)
3033
end
3134

3235
it 'plans a yum refresh in other location' do
@@ -77,5 +80,33 @@ module Actions
7780
assert_action_planned_with(action, pulp_metadata_generate_class, yum_repo, SmartProxy.pulp_primary,
7881
yum_action_options)
7982
end
83+
84+
it 'plans a deb metadata generate' do
85+
action = create_action(action_class)
86+
action.stubs(:task).returns(success_task)
87+
action.expects(:action_subject).with(deb_repo)
88+
deb_repo.expects(:deb_content_url_options).returns("/?comp=main&rel=bookworm")
89+
90+
plan_action(action, deb_repo)
91+
92+
assert_equal(deb_repo.content.content_url, "/custom/Debian_12/Debian_12_amd64_main/?comp=main&rel=bookworm")
93+
assert_action_planned_with(action, pulp_metadata_generate_class, deb_repo, SmartProxy.pulp_primary,
94+
action_options)
95+
refute_action_planned(action, candlepin_product_content_update_class)
96+
end
97+
98+
it 'plans a deb metadata generate with changed deb_content_url_options' do
99+
action = create_action(action_class)
100+
action.stubs(:task).returns(success_task)
101+
action.expects(:action_subject).with(deb_repo)
102+
deb_repo.expects(:deb_content_url_options).returns("/?comp=main,contrib&rel=bookworm")
103+
104+
plan_action(action, deb_repo)
105+
106+
assert_equal(deb_repo.content.content_url, "/custom/Debian_12/Debian_12_amd64_main/?comp=main&rel=bookworm")
107+
assert_action_planned_with(action, pulp_metadata_generate_class, deb_repo, SmartProxy.pulp_primary,
108+
action_options)
109+
assert_action_planned(action, candlepin_product_content_update_class)
110+
end
80111
end
81112
end

test/fixtures/models/katello_contents.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ deb_content_v3:
3030
content_url: /custom/Debian_12/Debian_10_amd64_main/?comp=main&rel=buster
3131
content_type: "deb"
3232

33+
deb_content_empty:
34+
name: debian
35+
label: debian
36+
cp_content_id: 114
37+
organization_id: <%= ActiveRecord::FixtureSet.identify(:empty_organization) %>
38+
content_url: /custom/Debian_12/Debian_12_amd64_main/?comp=empty&rel=katello
39+
content_type: "deb"
40+
3341
some_content:
3442
name: Fedora
3543
cp_content_id: 1

test/fixtures/models/katello_repositories.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ debian_10_amd64:
2626
debian_10_amd64_duplicate:
2727
root_id: <%= ActiveRecord::FixtureSet.identify(:debian_10_amd64_duplicate_root) %>
2828
pulp_id: Debian_10_duplicate
29+
content_id: 114
2930
relative_path: 'ACME_Corporation/library/debian_10_duplicate_label'
3031
environment_id: <%= ActiveRecord::FixtureSet.identify(:library) %>
3132
content_view_version_id: <%= ActiveRecord::FixtureSet.identify(:library_default_version) %>

0 commit comments

Comments
 (0)