Skip to content

Commit

Permalink
Merge pull request #1257 from SUSE/akamai_cdn_migration
Browse files Browse the repository at this point in the history
Refactor SUSE repo cleanup and local path generation logic supporting Akamai CDN
  • Loading branch information
paragjain0910 authored Dec 16, 2024
2 parents 5b38127 + 3503590 commit 62bd50a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
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

0 comments on commit 62bd50a

Please sign in to comment.