clowder-common-ruby 0.5.7 → 0.5.8

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: 721b0528d52ef01fc735043e255337628b98196ed3c8f216c6436f9c34ad3c55
4
- data.tar.gz: 4db1236e8ac887664834d7048d69f927896dd69da5f7a221cdaa09dc41782cb1
3
+ metadata.gz: 504fdf9231ba7057b9e220a7518944d8dc444b3bdbbadbe1aace5660ab180b35
4
+ data.tar.gz: 7f0e02df8a474d37117914f82126f68bb6499b39df7c4e8264f07b27210831d5
5
5
  SHA512:
6
- metadata.gz: ae4425e74de30e9935ec3e52f7669658535b9ea9b2b14284cf18a8c19f331a1b88ea28959b41b7ea1097a45503c5c2941f179000f24e0fb6ea5cb02d2c5254b6
7
- data.tar.gz: ab698201f0268a255e6337cbf51c3a7a2f67121837137a998806b9d5ef00dc11084c855802bc5e5feec6505df523ec73d20c9ee0c67acf213ab8a32867b2106f
6
+ metadata.gz: 568524b67420a393a594bebc98d1ade386857b2d0b95299b4637b154533020ad32dee96640ee20c9c79dcc02b5cf07f7c5ae8057e440ad9a91aa2a998439d3a8
7
+ data.tar.gz: fff83d793494bdc4b4329b6202520b3550696f846c7b225c4174e74fd03eeabed88ec90a374b51fc7747e5b09231dd84e7a5147682de07fe547ab691e7c7e931
@@ -1,4 +1,5 @@
1
1
  require 'clowder-common-ruby'
2
+ require 'uri'
2
3
 
3
4
  module ClowderCommonRuby
4
5
  class RailsConfig
@@ -13,6 +14,8 @@ module ClowderCommonRuby
13
14
  redis: configure_redis(config),
14
15
  endpoints: configure_endpoints(config, :dependency_endpoints),
15
16
  private_endpoints: configure_endpoints(config, :private_dependency_endpoints),
17
+ v2_endpoints: configure_v2_endpoints(config, :v2_dependency_endpoints),
18
+ v2_private_endpoints: configure_v2_endpoints(config, :v2_private_dependency_endpoints),
16
19
  database: configure_database(config),
17
20
  prometheus_exporter_port: config&.metricsPort,
18
21
  tls_ca_path: config.tlsCAPath,
@@ -115,6 +118,46 @@ module ClowderCommonRuby
115
118
  }
116
119
  end
117
120
 
121
+ # V2 uses the same app -> deployment nesting as V1 but has a different
122
+ # endpoint object. Keep its Settings separate so consumers can fall back
123
+ # to the V1 endpoint when needed.
124
+ def configure_v2_endpoints(config, field)
125
+ config.try(field)&.each_with_object({}) do |(name, endpoint), obj|
126
+ key = name.underscore.to_sym
127
+ obj[key] = {}
128
+ endpoint.each do |deployment_name, service|
129
+ service = build_v2_endpoint(service)
130
+ next unless service
131
+
132
+ deployment_key = deployment_name.underscore.to_sym
133
+ obj[key][deployment_key] = service
134
+ end
135
+
136
+ obj.delete(key) if obj[key].empty?
137
+ end
138
+ end
139
+
140
+ # V2 endpoints provide a complete URI and endpoint-specific TLS/auth data.
141
+ # Return nil for absent or malformed URIs so the legacy endpoint remains
142
+ # available as a migration fallback.
143
+ def build_v2_endpoint(endpoint)
144
+ return unless endpoint&.uri.present?
145
+
146
+ uri = URI.parse(endpoint.uri)
147
+ return unless %w[http https].include?(uri.scheme) && uri.host
148
+
149
+ {
150
+ scheme: uri.scheme,
151
+ host: "#{uri.host}:#{uri.port}",
152
+ url: endpoint.uri,
153
+ ca_certificate: endpoint.ca_certificate.presence,
154
+ authenticated: endpoint.authenticated,
155
+ source: :v2
156
+ }
157
+ rescue URI::InvalidURIError
158
+ nil
159
+ end
160
+
118
161
  # All endpoints' configuration hash
119
162
  def configure_endpoints(config, field)
120
163
  config.try(field)&.each_with_object({}) do |(name, endpoint), obj|
@@ -136,7 +179,10 @@ module ClowderCommonRuby
136
179
  {
137
180
  scheme: scheme,
138
181
  host: host,
139
- url: "#{scheme}://#{host}"
182
+ url: "#{scheme}://#{host}",
183
+ ca_certificate: nil,
184
+ authenticated: false,
185
+ source: :v1
140
186
  }
141
187
  end
142
188
 
@@ -1,3 +1,3 @@
1
1
  module ClowderCommonRuby
2
- VERSION = '0.5.7'.freeze # Patch version is being automatically bumped
2
+ VERSION = '0.5.8'.freeze # Patch version is being automatically bumped
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clowder-common-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Red Hat Developers