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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28b7e3334605263bb65b51caeee7801018273553660aa9079afa7dbcc9cc1334
4
- data.tar.gz: b750dacf95ee93a1e055a30df375eddf9cebcb53905c3b06eaeb098b0d094166
3
+ metadata.gz: 892ebe1bfde6f2e84b314886d6b0b66fcf110cc01f1dd6ce554de39c09d9a9b3
4
+ data.tar.gz: ac45411ee564e2d6bd9d4b56f40dbfa972f559626878082ae53cdc388dd12947
5
5
  SHA512:
6
- metadata.gz: d63024ea9077c527a4db8b658efb2badc03e5e3d7d1096dc8e609773112a246b08a0409c3fad8d808763911f51b8e2d2c82b25878fc6708bf831449907dd3f1a
7
- data.tar.gz: 3ddc4be800c46e72b19abf6c679c8b0ffc805bda918c3a6a678a97d17cb9ee7bdf3332f9ad09dbc0dc1c465221e6dd1ef4a800a8c2e829e1848c4a306a9086ba
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
- export `ACG_CONFIG="test.json"; ruby lib/clowder-common-ruby/test.rb
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
@@ -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 << " raise \"The input [\#{k}] is invalid\" unless valid_keys.include?(k.to_sym)\n"
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
- raise "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
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
 
@@ -1,3 +1,3 @@
1
1
  module ClowderCommonRuby
2
- VERSION = '0.2.2'.freeze
2
+ VERSION = '0.2.3'.freeze
3
3
  end
data/test.json CHANGED
@@ -1,4 +1,12 @@
1
1
  {
2
+ "metadata": {
3
+ "deployments": [
4
+ {
5
+ "name": "svc",
6
+ "image": "quay.io/not_us/test_ruby_app:1337"
7
+ }
8
+ ]
9
+ },
2
10
  "webPort": 8000,
3
11
  "metricsPort": 9000,
4
12
  "metricsPath": "/metrics",
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.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-03-12 00:00:00.000000000 Z
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