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

Refactor SUSE repo cleanup and local path generation logic supporting Akamai CDN #1257

Merged
merged 6 commits into from
Dec 16, 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
5 changes: 3 additions & 2 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ class Repository < ApplicationRecord
class << self

def remove_suse_repos_without_tokens!
where(auth_token: nil).where('external_url LIKE ?', 'https://updates.suse.com%').delete_all
where(auth_token: nil).where("external_url LIKE '%.suse.com%'").where(installer_updates: 0).where.not(scc_id: nil).delete_all
end

# Mangles remote repo URL to make a nicer local path, see specs for examples
def make_local_path(url)
uri = URI(url)
path = uri.path.to_s
path.gsub!(%r{^/repo}, '') if (uri.hostname == 'updates.suse.com')
# drop '/repo' from SLE11 paths, to avoid double /repo/repo in local storage path.
path.gsub!(%r{^/repo/\$RCE/}, '/$RCE/')
(path == '') ? '/' : path
end

Expand Down
17 changes: 16 additions & 1 deletion spec/lib/rmt/scc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,18 @@
:repository,
:with_products,
auth_token: nil,
external_url: 'https://example.com/repos/not/updates.suse.com/'
external_url: 'https://installer-updates.suse.com/repos/not/updates',
installer_updates: true
)
end
let!(:custom_repo) do
FactoryBot.create(
:repository,
:with_products,
auth_token: nil,
external_url: 'http://customer.com/stuff.suse.com/x86',
installer_updates: false,
scc_id: nil
)
end

Expand Down Expand Up @@ -297,6 +308,10 @@ def scc
it 'other repos without auth_tokens persist' do
expect { other_repo_without_token.reload }.not_to raise_error
end

it 'custom repos without auth_tokens persist' do
expect { custom_repo.reload }.not_to raise_error
end
end

describe '#export' do
Expand Down
Loading