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 +4 -4
- data/lib/clowder-common-ruby/rails_config.rb +47 -1
- data/lib/clowder-common-ruby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 504fdf9231ba7057b9e220a7518944d8dc444b3bdbbadbe1aace5660ab180b35
|
|
4
|
+
data.tar.gz: 7f0e02df8a474d37117914f82126f68bb6499b39df7c4e8264f07b27210831d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|