Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure SUMA product tree base URL #1264

Merged
merged 4 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Adnilson marked this conversation as resolved.
Show resolved Hide resolved
@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 <[email protected]>

- 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 <[email protected]>

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
Loading