clowder-common-ruby 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -8
- data/bin/output +134 -0
- data/bin/ruby_class_converter.rb +1 -1
- data/bin/schema.json +31 -4
- data/lib/clowder-common-ruby/types.rb +13 -14
- data/lib/clowder-common-ruby/version.rb +1 -1
- data/test.json +8 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 892ebe1bfde6f2e84b314886d6b0b66fcf110cc01f1dd6ce554de39c09d9a9b3
|
4
|
+
data.tar.gz: ac45411ee564e2d6bd9d4b56f40dbfa972f559626878082ae53cdc388dd12947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 708a51e009bfdc3ae4d018a8df7933e5b7e06cfa2c0869389cde71f2449c3f735c71aa8828ecf7e9564d84f1da30ab6a06f844b79e02fe7fa5a2a5ca995e2a4d
|
7
|
+
data.tar.gz: 2879a909f197ca8153d0db2f60de26bf16717a43c2076f966606bb1921c92ded3d4865d93f9d2e65015664881c273f34feb4ad758ced8b84bee327a3f1dfc9fe
|
data/README.md
CHANGED
@@ -18,14 +18,14 @@ require 'clowder-common-ruby'
|
|
18
18
|
|
19
19
|
@config ||= {}.tap do |options|
|
20
20
|
# uses ENV['ACG_CONFIG'] or you can provide the path as a method param
|
21
|
-
|
22
|
-
if ClowderCommonRuby::Config.clowder_enabled?
|
23
|
-
config = ClowderCommonRuby::Config.load
|
21
|
+
|
22
|
+
if ClowderCommonRuby::Config.clowder_enabled?
|
23
|
+
config = ClowderCommonRuby::Config.load
|
24
24
|
options["webPorts"] = config.webPort
|
25
25
|
options["databaseHostname"] = config.database.hostname
|
26
26
|
options["kafkaTopics"] = config.kafka_topics
|
27
27
|
# ...
|
28
|
-
else
|
28
|
+
else
|
29
29
|
options["webPorts"] = 3000
|
30
30
|
options["databaseHostname"] = ENV['DATABASE_HOST']
|
31
31
|
end
|
@@ -49,8 +49,8 @@ See [test.json](test.json) for all available values
|
|
49
49
|
|
50
50
|
### Kafka Topics
|
51
51
|
|
52
|
-
Topics are structured as a hash `<requested_name> => <name>`
|
53
|
-
where requested_name is equal to the key topicName in your ClowdApp Custom Resource Definition(CRD)'s yaml
|
52
|
+
Topics are structured as a hash `<requested_name> => <name>`
|
53
|
+
where `requested_name` is equal to the key topicName in your ClowdApp Custom Resource Definition(CRD)'s yaml
|
54
54
|
|
55
55
|
If your kafka is deployed in `local` or `app-interface` mode (see [doc](https://clowder-operator.readthedocs.io/en/latest/providers/kafka.html))
|
56
56
|
the `name` is equal to the `requested_name`.
|
@@ -58,6 +58,6 @@ the `name` is equal to the `requested_name`.
|
|
58
58
|
Testing
|
59
59
|
-------
|
60
60
|
|
61
|
-
|
61
|
+
`ACG_CONFIG="test.json" ruby lib/clowder-common-ruby/test.rb`
|
62
62
|
|
63
|
-
It inspects and prints the config file with loaded values or shows an error it the env. variable not configured correctly
|
63
|
+
It inspects and prints the config file with loaded values or shows an error it the env. variable not configured correctly
|
data/bin/output
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# This file is automatically generated by bin/json_schema_ruby
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module ClowderCommonRuby
|
5
|
+
class AppConfig < OpenStruct
|
6
|
+
attr_accessor :logging
|
7
|
+
attr_accessor :kafka
|
8
|
+
attr_accessor :database
|
9
|
+
attr_accessor :objectStore
|
10
|
+
attr_accessor :inMemoryDb
|
11
|
+
attr_accessor :featureFlags
|
12
|
+
attr_accessor :endpoints
|
13
|
+
attr_accessor :privateEndpoints
|
14
|
+
|
15
|
+
def initialize(attributes)
|
16
|
+
super
|
17
|
+
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
18
|
+
|
19
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
20
|
+
raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
21
|
+
h[k.to_sym] = v
|
22
|
+
end
|
23
|
+
|
24
|
+
@logging = LoggingConfig.new(attributes.fetch(:logging, {}))
|
25
|
+
@kafka = KafkaConfig.new(attributes.fetch(:kafka, {}))
|
26
|
+
@database = DatabaseConfig.new(attributes.fetch(:database, {}))
|
27
|
+
@objectStore = ObjectStoreConfig.new(attributes.fetch(:objectStore, {}))
|
28
|
+
@inMemoryDb = InMemoryDBConfig.new(attributes.fetch(:inMemoryDb, {}))
|
29
|
+
@featureFlags = FeatureFlagsConfig.new(attributes.fetch(:featureFlags, {}))
|
30
|
+
@endpoints = []
|
31
|
+
attributes.fetch(:endpoints, []).each do |attr|
|
32
|
+
@endpoints << DependencyEndpoint.new(attr)
|
33
|
+
end
|
34
|
+
@privateEndpoints = []
|
35
|
+
attributes.fetch(:privateEndpoints, []).each do |attr|
|
36
|
+
@privateEndpoints << PrivateDependencyEndpoint.new(attr)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def valid_keys
|
41
|
+
[].tap do |keys|
|
42
|
+
keys << :privatePort
|
43
|
+
keys << :publicPort
|
44
|
+
keys << :webPort
|
45
|
+
keys << :metricsPort
|
46
|
+
keys << :metricsPath
|
47
|
+
keys << :logging
|
48
|
+
keys << :kafka
|
49
|
+
keys << :database
|
50
|
+
keys << :objectStore
|
51
|
+
keys << :inMemoryDb
|
52
|
+
keys << :featureFlags
|
53
|
+
keys << :endpoints
|
54
|
+
keys << :privateEndpoints
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class LoggingConfig < OpenStruct
|
60
|
+
attr_accessor :cloudwatch
|
61
|
+
|
62
|
+
def initialize(attributes)
|
63
|
+
super
|
64
|
+
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
65
|
+
|
66
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
67
|
+
raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
68
|
+
h[k.to_sym] = v
|
69
|
+
end
|
70
|
+
|
71
|
+
@cloudwatch = CloudWatchConfig.new(attributes.fetch(:cloudwatch, {}))
|
72
|
+
end
|
73
|
+
|
74
|
+
def valid_keys
|
75
|
+
[].tap do |keys|
|
76
|
+
keys << :type
|
77
|
+
keys << :cloudwatch
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class CloudWatchConfig < OpenStruct
|
83
|
+
|
84
|
+
def initialize(attributes)
|
85
|
+
super
|
86
|
+
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
87
|
+
|
88
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
89
|
+
raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
90
|
+
h[k.to_sym] = v
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
def valid_keys
|
96
|
+
[].tap do |keys|
|
97
|
+
keys << :accessKeyId
|
98
|
+
keys << :secretAccessKey
|
99
|
+
keys << :region
|
100
|
+
keys << :logGroup
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
class KafkaConfig < OpenStruct
|
106
|
+
attr_accessor :brokers
|
107
|
+
attr_accessor :topics
|
108
|
+
|
109
|
+
def initialize(attributes)
|
110
|
+
super
|
111
|
+
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
112
|
+
|
113
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
114
|
+
raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
115
|
+
h[k.to_sym] = v
|
116
|
+
end
|
117
|
+
|
118
|
+
@brokers = []
|
119
|
+
attributes.fetch(:brokers, []).each do |attr|
|
120
|
+
@brokers << BrokerConfig.new(attr)
|
121
|
+
end
|
122
|
+
@topics = []
|
123
|
+
attributes.fetch(:topics, []).each do |attr|
|
124
|
+
@topics << TopicConfig.new(attr)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def valid_keys
|
129
|
+
[].tap do |keys|
|
130
|
+
keys << :brokers
|
131
|
+
keys << :topics
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
data/bin/ruby_class_converter.rb
CHANGED
@@ -76,7 +76,7 @@ class RubyClassConverter
|
|
76
76
|
init_function << " raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))\n"
|
77
77
|
init_function << "\n"
|
78
78
|
init_function << " attributes = attributes.each_with_object({}) do |(k, v), h|\n"
|
79
|
-
init_function << "
|
79
|
+
init_function << " warn \"The input [\#{k}] is invalid\" unless valid_keys.include?(k.to_sym)\n"
|
80
80
|
init_function << " h[k.to_sym] = v\n"
|
81
81
|
init_function << " end\n"
|
82
82
|
init_function << "\n"
|
data/bin/schema.json
CHANGED
@@ -139,6 +139,19 @@
|
|
139
139
|
"topics"
|
140
140
|
]
|
141
141
|
},
|
142
|
+
"KafkaSASLConfig":{
|
143
|
+
"id": "kafkaSASLConfig",
|
144
|
+
"type": "object",
|
145
|
+
"description": "SASL Configuration for Kafka",
|
146
|
+
"properties": {
|
147
|
+
"username": {
|
148
|
+
"type": "string"
|
149
|
+
},
|
150
|
+
"password": {
|
151
|
+
"type": "string"
|
152
|
+
}
|
153
|
+
}
|
154
|
+
},
|
142
155
|
"BrokerConfig": {
|
143
156
|
"id": "brokerConfig",
|
144
157
|
"type": "object",
|
@@ -149,6 +162,16 @@
|
|
149
162
|
},
|
150
163
|
"port": {
|
151
164
|
"type": "integer"
|
165
|
+
},
|
166
|
+
"cacert": {
|
167
|
+
"type": "string"
|
168
|
+
},
|
169
|
+
"authtype": {
|
170
|
+
"type": "string",
|
171
|
+
"enum": ["mtls", "sasl"]
|
172
|
+
},
|
173
|
+
"sasl": {
|
174
|
+
"$ref": "#/definitions/KafkaSASLConfig"
|
152
175
|
}
|
153
176
|
},
|
154
177
|
"required": [
|
@@ -167,10 +190,6 @@
|
|
167
190
|
"name": {
|
168
191
|
"description": "The name of the actual topic on the Kafka server.",
|
169
192
|
"type": "string"
|
170
|
-
},
|
171
|
-
"consumerGroup": {
|
172
|
-
"description": "Defines the consumer group that should be used for the topic.",
|
173
|
-
"type": "string"
|
174
193
|
}
|
175
194
|
},
|
176
195
|
"required": [
|
@@ -245,6 +264,10 @@
|
|
245
264
|
"description": "Defines the secret key for the specified bucket.",
|
246
265
|
"type": "string"
|
247
266
|
},
|
267
|
+
"region": {
|
268
|
+
"description": "Defines the region for the specified bucket.",
|
269
|
+
"type": "string"
|
270
|
+
},
|
248
271
|
"requestedName": {
|
249
272
|
"description": "The name that was requested for the bucket in the ClowdApp.",
|
250
273
|
"type": "string"
|
@@ -309,6 +332,10 @@
|
|
309
332
|
"port": {
|
310
333
|
"description": "Defines the port for the FeatureFlags server",
|
311
334
|
"type": "integer"
|
335
|
+
},
|
336
|
+
"clientAccessToken": {
|
337
|
+
"description": "Defines the client access token to use when connect to the FeatureFlags server",
|
338
|
+
"type": "string"
|
312
339
|
}
|
313
340
|
},
|
314
341
|
"required":[
|
@@ -17,7 +17,7 @@ module ClowderCommonRuby
|
|
17
17
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
18
18
|
|
19
19
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
20
|
-
|
20
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
21
21
|
h[k.to_sym] = v
|
22
22
|
end
|
23
23
|
|
@@ -64,7 +64,7 @@ module ClowderCommonRuby
|
|
64
64
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
65
65
|
|
66
66
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
67
|
-
|
67
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
68
68
|
h[k.to_sym] = v
|
69
69
|
end
|
70
70
|
|
@@ -86,7 +86,7 @@ module ClowderCommonRuby
|
|
86
86
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
87
87
|
|
88
88
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
89
|
-
|
89
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
90
90
|
h[k.to_sym] = v
|
91
91
|
end
|
92
92
|
|
@@ -111,7 +111,7 @@ module ClowderCommonRuby
|
|
111
111
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
112
112
|
|
113
113
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
114
|
-
|
114
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
115
115
|
h[k.to_sym] = v
|
116
116
|
end
|
117
117
|
|
@@ -140,7 +140,7 @@ module ClowderCommonRuby
|
|
140
140
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
141
141
|
|
142
142
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
143
|
-
|
143
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
144
144
|
h[k.to_sym] = v
|
145
145
|
end
|
146
146
|
|
@@ -161,7 +161,7 @@ module ClowderCommonRuby
|
|
161
161
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
162
162
|
|
163
163
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
164
|
-
|
164
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
165
165
|
h[k.to_sym] = v
|
166
166
|
end
|
167
167
|
|
@@ -183,7 +183,7 @@ module ClowderCommonRuby
|
|
183
183
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
184
184
|
|
185
185
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
186
|
-
|
186
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
187
187
|
h[k.to_sym] = v
|
188
188
|
end
|
189
189
|
|
@@ -199,7 +199,6 @@ module ClowderCommonRuby
|
|
199
199
|
keys << :adminUsername
|
200
200
|
keys << :adminPassword
|
201
201
|
keys << :rdsCa
|
202
|
-
keys << :sslMode
|
203
202
|
end
|
204
203
|
end
|
205
204
|
end
|
@@ -211,7 +210,7 @@ module ClowderCommonRuby
|
|
211
210
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
212
211
|
|
213
212
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
214
|
-
|
213
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
215
214
|
h[k.to_sym] = v
|
216
215
|
end
|
217
216
|
|
@@ -235,7 +234,7 @@ module ClowderCommonRuby
|
|
235
234
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
236
235
|
|
237
236
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
238
|
-
|
237
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
239
238
|
h[k.to_sym] = v
|
240
239
|
end
|
241
240
|
|
@@ -264,7 +263,7 @@ module ClowderCommonRuby
|
|
264
263
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
265
264
|
|
266
265
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
267
|
-
|
266
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
268
267
|
h[k.to_sym] = v
|
269
268
|
end
|
270
269
|
|
@@ -285,7 +284,7 @@ module ClowderCommonRuby
|
|
285
284
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
286
285
|
|
287
286
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
288
|
-
|
287
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
289
288
|
h[k.to_sym] = v
|
290
289
|
end
|
291
290
|
|
@@ -308,7 +307,7 @@ module ClowderCommonRuby
|
|
308
307
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
309
308
|
|
310
309
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
311
|
-
|
310
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
312
311
|
h[k.to_sym] = v
|
313
312
|
end
|
314
313
|
|
@@ -331,7 +330,7 @@ module ClowderCommonRuby
|
|
331
330
|
raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))
|
332
331
|
|
333
332
|
attributes = attributes.each_with_object({}) do |(k, v), h|
|
334
|
-
|
333
|
+
warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
|
335
334
|
h[k.to_sym] = v
|
336
335
|
end
|
337
336
|
|
data/test.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clowder-common-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Red Hat Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This is a ruby interface for preparing Clowder variables.
|
14
14
|
email:
|
@@ -20,6 +20,7 @@ files:
|
|
20
20
|
- README.md
|
21
21
|
- Rakefile
|
22
22
|
- bin/json_schema_ruby
|
23
|
+
- bin/output
|
23
24
|
- bin/ruby_class_converter.rb
|
24
25
|
- bin/schema.json
|
25
26
|
- lib/clowder-common-ruby.rb
|