smart_proxy_container_gateway 3.4.0 → 3.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 470113167c3182629d62ee7babddf775b3e99e4c21ce0df5a9716894867dad86
4
- data.tar.gz: 7adbe20e3c0dda9a9a3704501144c5f4134c7d9c266f36b19f24e83df09ad997
3
+ metadata.gz: 3d6e568aa93e31c6a60234698cbbc0a86fb61c71179e01692dd7f22193e3e096
4
+ data.tar.gz: 2085424bbca11bd822b190eadf4ccb14519397e2b8f1d8fff6182bacbd73c5ca
5
5
  SHA512:
6
- metadata.gz: b017c8a19c575d9ddcae254500917089eef21739914b5dc73447ba39af9840679028a4401bf15fd1216ae7299b7da7f55c6200a87830d7553fd8b380bc6c821b
7
- data.tar.gz: e37b37684d5eaace152ab018067f4fa9292a5f5663543e030ed07eba894e59d6486c6b43a0c465c11dd7de65af14599b2e54a22882ff541dd5cb45e1ae381776
6
+ metadata.gz: e5ebdf2d44f61b518be4115b73e5b6fae57364753c84cd61fc361e3275883b9c07f9c60e28b0e674f968dd14abacd35e1e62c1288d48c7f8dff0d60134fe6c24
7
+ data.tar.gz: f4a21694af41c33ba437e2c5e53e6bbed64a0e26d99a9c4ffd56c27b421d16ee8e28d261016d5a36b53d55e3405d376eabe5d1d58344590f7deccf3b041e717f
@@ -262,7 +262,8 @@ module Proxy
262
262
  database.connection.transaction(isolation: :serializable, retry_on: [Sequel::SerializationFailure]) do
263
263
  hosts_table = database.connection[:hosts]
264
264
  hosts_table.delete
265
- hosts_table.import(%i[uuid], hosts.map { |host| [host['uuid']] })
265
+ valid_hosts = hosts.filter_map { |host| [host['uuid']] if host['uuid'].present? }
266
+ hosts_table.import(%i[uuid], valid_hosts) unless valid_hosts.empty?
266
267
  end
267
268
  {}
268
269
  end
@@ -277,6 +278,8 @@ module Proxy
277
278
  do_authorize_any
278
279
  params['hosts'].flat_map do |host_map|
279
280
  host_map.filter_map do |host_uuid, repos|
281
+ next if host_uuid.nil? || host_uuid.to_s.strip.empty?
282
+
280
283
  if repos.nil? || repos.empty?
281
284
  repo_names = []
282
285
  else
@@ -195,33 +195,50 @@ module Proxy
195
195
  # Insert all in a single transaction
196
196
  database.connection.transaction(isolation: :serializable, retry_on: [Sequel::SerializationFailure]) do
197
197
  hosts_repositories.delete
198
- hosts_repositories.import(%i[repository_id host_id], entries)
198
+ hosts_repositories.import(%i[repository_id host_id], entries) unless entries.nil? || entries.empty?
199
199
  end
200
200
  end
201
201
 
202
202
  def build_host_repository_mapping(host_repo_maps)
203
+ return [] if host_repo_maps['hosts'].nil?
204
+
203
205
  hosts = database.connection[:hosts]
204
206
  repositories = database.connection[:repositories]
207
+
205
208
  entries = host_repo_maps['hosts'].flat_map do |host_map|
206
209
  host_map.filter_map do |host_uuid, repos|
207
- host = hosts[{ uuid: host_uuid }]
208
- next unless host
209
-
210
- repo_names = repos
211
- .select { |repo| repo['auth_required'].to_s.downcase == "true" }
212
- .map { |repo| repo['repository'] }
213
-
214
- repositories
215
- .where(name: repo_names, auth_required: true)
216
- .select(:id)
217
- .map { |repo| [repo[:id], host[:id]] }
210
+ build_host_entries(hosts, repositories, host_uuid, repos)
218
211
  end
219
212
  end
220
- entries.flatten!(1)
213
+ entries&.flatten(1)&.compact
214
+ end
215
+
216
+ def build_host_entries(hosts, repositories, host_uuid, repos)
217
+ return if host_uuid.nil? || host_uuid.to_s.strip.empty?
218
+
219
+ host = hosts[{ uuid: host_uuid }]
220
+ return unless host
221
+ return if repos.nil? || repos.empty?
222
+
223
+ repo_names = extract_auth_required_repo_names(repos)
224
+ repositories
225
+ .where(name: repo_names, auth_required: true)
226
+ .select(:id)
227
+ .map { |repo| [repo[:id], host[:id]] }
228
+ end
229
+
230
+ def extract_auth_required_repo_names(repos)
231
+ repos
232
+ .select { |repo| repo['auth_required'].to_s.downcase == "true" }
233
+ .map { |repo| repo['repository'] }
221
234
  end
222
235
 
223
236
  def update_host_repositories(uuid, repositories)
237
+ return if uuid.nil? || uuid.to_s.strip.empty?
238
+
224
239
  host = find_or_create_host(uuid)
240
+ return unless host
241
+
225
242
  hosts_repositories = database.connection[:hosts_repositories]
226
243
  database.connection.transaction(isolation: :serializable,
227
244
  retry_on: [Sequel::SerializationFailure],
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module ContainerGateway
3
- VERSION = '3.4.0'.freeze
3
+ VERSION = '3.4.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_container_gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Ballou
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2025-12-05 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: activesupport
@@ -76,8 +77,8 @@ email: ianballou67@gmail.com
76
77
  executables: []
77
78
  extensions: []
78
79
  extra_rdoc_files:
79
- - LICENSE
80
80
  - README.md
81
+ - LICENSE
81
82
  files:
82
83
  - LICENSE
83
84
  - README.md
@@ -102,6 +103,7 @@ homepage: https://github.com/Katello/smart_proxy_container_gateway
102
103
  licenses:
103
104
  - GPL-3.0-only
104
105
  metadata: {}
106
+ post_install_message:
105
107
  rdoc_options: []
106
108
  require_paths:
107
109
  - lib
@@ -109,14 +111,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
111
  requirements:
110
112
  - - ">="
111
113
  - !ruby/object:Gem::Version
112
- version: '2.7'
114
+ version: '3.0'
113
115
  required_rubygems_version: !ruby/object:Gem::Requirement
114
116
  requirements:
115
117
  - - ">="
116
118
  - !ruby/object:Gem::Version
117
119
  version: '0'
118
120
  requirements: []
119
- rubygems_version: 3.6.7
121
+ rubygems_version: 3.2.33
122
+ signing_key:
120
123
  specification_version: 4
121
124
  summary: Pulp 3 container registry support for Foreman/Katello Smart-Proxy
122
125
  test_files: []