Skip to content

Commit

Permalink
remove function remove_suse_repos_without_tokens!;
Browse files Browse the repository at this point in the history
  • Loading branch information
paragjain0910 committed Dec 12, 2024
1 parent 992c0a0 commit caa9831
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
10 changes: 2 additions & 8 deletions app/models/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@ class Repository < ApplicationRecord
before_destroy :ensure_destroy_possible

class << self

def remove_suse_repos_without_tokens!
where(auth_token: nil)
.where("external_url LIKE 'https://updates.suse.com%' OR external_url LIKE 'https://dl.suse.com%'")
.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' || uri.hostname == 'dl.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
6 changes: 0 additions & 6 deletions lib/rmt/scc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ def sync
data.each { |item| migration_paths(item) }

update_repositories(scc_api_client.list_repositories)

Repository.remove_suse_repos_without_tokens!

update_subscriptions(scc_api_client.list_subscriptions)
end

Expand Down Expand Up @@ -68,9 +65,6 @@ def import(path)
data.each { |item| migration_paths(item) }

update_repositories(JSON.parse(File.read(File.join(path, 'organizations_repositories.json')), symbolize_names: true))

Repository.remove_suse_repos_without_tokens!

update_subscriptions(JSON.parse(File.read(File.join(path, 'organizations_subscriptions.json')), symbolize_names: true))
end

Expand Down
4 changes: 0 additions & 4 deletions spec/lib/rmt/scc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,6 @@ def scc
expect { suse_repo_with_token.reload }.not_to raise_error
end

it 'SUSE repos without auth_tokens are removed' do
expect { suse_repo_without_token.reload }.to raise_error(ActiveRecord::RecordNotFound)
end

it 'other repos without auth_tokens persist' do
expect { other_repo_without_token.reload }.not_to raise_error
end
Expand Down

0 comments on commit caa9831

Please sign in to comment.