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 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/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/package/obs/rmt-server.changes b/package/obs/rmt-server.changes index c86808f99..a89738a3c 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'. (bsc#1234844) + ------------------------------------------------------------------- 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 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