Skip to content

Commit

Permalink
Merge pull request #1264 from SUSE/custom-suma-tree-url
Browse files Browse the repository at this point in the history
Configure SUMA product tree base URL
  • Loading branch information
Adnilson authored Dec 30, 2024
2 parents 5aabdb4 + 594a95d commit c1537cf
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
1 change: 1 addition & 0 deletions config/rmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rmt.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RMT
VERSION ||= '2.20'.freeze
VERSION ||= '2.21'.freeze

DEFAULT_USER = '_rmt'.freeze
DEFAULT_GROUP = 'nginx'.freeze
Expand Down
4 changes: 2 additions & 2 deletions lib/rmt/mirror/suma_product_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions package/obs/rmt-server.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Mon Dec 23 14:07:00 UTC 2024 - Luís Caparroz <lcaparroz@suse.com>

- 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 <parag.jain@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/obs/rmt-server.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 32 additions & 6 deletions spec/lib/rmt/mirror/suma_product_tree_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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/')
}
Expand All @@ -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)
Expand All @@ -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

0 comments on commit c1537cf

Please sign in to comment.