From d8ac561879401ebc1f8b24beac2f73870849eb79 Mon Sep 17 00:00:00 2001 From: Luis Caparroz Date: Mon, 23 Dec 2024 14:39:59 +0100 Subject: [PATCH 1/4] feat: configure SUMA product tree base URL Allow user to configure the SUMA product tree base URL in RMT's config file `mirroring.suma_product_tree_base_url` attribute. The configured value takes precedence over the default (https://scc.suse.com/suma/). --- lib/rmt/mirror/suma_product_tree.rb | 4 +- spec/lib/rmt/mirror/suma_product_tree_spec.rb | 38 ++++++++++++++++--- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/lib/rmt/mirror/suma_product_tree.rb b/lib/rmt/mirror/suma_product_tree.rb index cc0f45a9f..924e2b10c 100644 --- a/lib/rmt/mirror/suma_product_tree.rb +++ b/lib/rmt/mirror/suma_product_tree.rb @@ -3,9 +3,9 @@ class RMT::Mirror::SumaProductTree attr_reader :mirroring_base_dir, :url, :logger - def initialize(logger:, mirroring_base_dir:, url: FILE_URL) + def initialize(logger:, mirroring_base_dir:, url: nil) @mirroring_base_dir = mirroring_base_dir - @url = url + @url = url || Settings.try(:mirroring).try(:suma_product_tree_base_url) || FILE_URL @logger = logger end diff --git a/spec/lib/rmt/mirror/suma_product_tree_spec.rb b/spec/lib/rmt/mirror/suma_product_tree_spec.rb index e010c441d..ca16b5e2a 100644 --- a/spec/lib/rmt/mirror/suma_product_tree_spec.rb +++ b/spec/lib/rmt/mirror/suma_product_tree_spec.rb @@ -12,7 +12,7 @@ let(:ref_configuration) do { relative_path: 'product_tree.json', - base_url: described_class::FILE_URL, + base_url: base_url, cache_dir: nil, base_dir: File.join(base_dir, '/suma/') } @@ -21,11 +21,7 @@ let(:base_dir) { '/tmp' } let(:downloader) { instance_double RMT::Downloader } - describe '#mirror' do - before do - allow(RMT::Downloader).to receive(:new).and_return downloader - end - + shared_examples 'mirror SUMA product tree' do it 'mirrors the product_tree file' do expect(RMT::Mirror::FileReference).to receive(:new).with(**ref_configuration) expect(downloader).to receive(:download_multi) @@ -48,4 +44,34 @@ end end end + + describe '#mirror' do + before do + allow(RMT::Downloader).to receive(:new).and_return downloader + end + + context 'with default SUMA product tree URL' do + before do + allow(Settings).to receive(:try).with(:mirroring).and_return(nil) + end + + it_behaves_like 'mirror SUMA product tree' do + let(:base_url) { 'https://scc.suse.com/suma/' } + end + end + + context 'with custom SUMA product tree URL' do + before do + allow(Settings).to receive(:try).with(:mirroring).and_return(mirroring_configuration) + allow(mirroring_configuration).to receive(:try) + .with(:suma_product_tree_base_url).and_return(base_url) + end + + let(:mirroring_configuration) { instance_double(Config::Options) } + + it_behaves_like 'mirror SUMA product tree' do + let(:base_url) { 'http://localhost:3000/suma/' } + end + end + end end From db348c07297ee23c2689482e9fd28314fec9dcc1 Mon Sep 17 00:00:00 2001 From: Luis Caparroz Date: Mon, 23 Dec 2024 15:11:39 +0100 Subject: [PATCH 2/4] build: Bump version to 2.21 --- lib/rmt.rb | 2 +- package/obs/rmt-server.changes | 6 ++++++ package/obs/rmt-server.spec | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/rmt.rb b/lib/rmt.rb index a68d53a1a..e043c2ad9 100644 --- a/lib/rmt.rb +++ b/lib/rmt.rb @@ -1,5 +1,5 @@ module RMT - VERSION ||= '2.20'.freeze + VERSION ||= '2.21'.freeze DEFAULT_USER = '_rmt'.freeze DEFAULT_GROUP = 'nginx'.freeze diff --git a/package/obs/rmt-server.changes b/package/obs/rmt-server.changes index c86808f99..b4db0c4a7 100644 --- a/package/obs/rmt-server.changes +++ b/package/obs/rmt-server.changes @@ -1,3 +1,9 @@ +Mon Dec 23 14:07:00 UTC 2024 - Luís Caparroz + +- Version 2.21 +- Allow users to configure the SUMA product tree base URL to download + 'product_tree.json' from host other than 'scc.suse.com'. + ------------------------------------------------------------------- Mon Dec 23 08:03:56 UTC 2024 - Parag Jain diff --git a/package/obs/rmt-server.spec b/package/obs/rmt-server.spec index 9803c0228..4652e8be5 100644 --- a/package/obs/rmt-server.spec +++ b/package/obs/rmt-server.spec @@ -34,7 +34,7 @@ %undefine _find_debuginfo_dwz_opts Name: rmt-server -Version: 2.20 +Version: 2.21 Release: 0 Summary: Repository mirroring tool and registration proxy for SCC License: GPL-2.0-or-later From fb82b243073ac81194ce51d9045ab37719f9ec6c Mon Sep 17 00:00:00 2001 From: Adnilson Delgado Date: Thu, 26 Dec 2024 21:15:26 +0000 Subject: [PATCH 3/4] Add bug number to server changes --- package/obs/rmt-server.changes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/obs/rmt-server.changes b/package/obs/rmt-server.changes index b4db0c4a7..a89738a3c 100644 --- a/package/obs/rmt-server.changes +++ b/package/obs/rmt-server.changes @@ -1,8 +1,8 @@ Mon Dec 23 14:07:00 UTC 2024 - Luís Caparroz - Version 2.21 -- Allow users to configure the SUMA product tree base URL to download - 'product_tree.json' from host other than 'scc.suse.com'. +* Allow users to configure the SUMA product tree base URL to download + 'product_tree.json' from host other than 'scc.suse.com'. (bsc#1234844) ------------------------------------------------------------------- Mon Dec 23 08:03:56 UTC 2024 - Parag Jain From 594a95db8b7efce0ea104130dd1d595eb49d5f6e Mon Sep 17 00:00:00 2001 From: Adnilson Delgado Date: Mon, 30 Dec 2024 14:15:06 +0000 Subject: [PATCH 4/4] Add env variable to suma_product_tree_base_url --- config/rmt.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/rmt.yml b/config/rmt.yml index 6a2df5b5c..e3c849bf2 100644 --- a/config/rmt.yml +++ b/config/rmt.yml @@ -31,6 +31,7 @@ scc: mirroring: mirror_src: false dedup_method: hardlink + suma_product_tree_base_url: <%= ENV['SUMA_PRODUCT_TREE_BASE_URL'] %> http_client: verbose: false