Class: ClowderCommonRuby::AppConfig

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/clowder-common-ruby/types.rb

Direct Known Subclasses

Config

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ AppConfig

Returns a new instance of AppConfig.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/clowder-common-ruby/types.rb', line 16

def initialize(attributes)
  super
  raise 'The input argument (attributes) must be a hash' if (!attributes || !attributes.is_a?(Hash))

  attributes = attributes.each_with_object({}) do |(k, v), h|
    warn "The input [#{k}] is invalid" unless valid_keys.include?(k.to_sym)
    h[k.to_sym] = v
  end

  @logging = LoggingConfig.new(attributes.fetch(:logging, {}))
  @metadata = AppMetadata.new(attributes.fetch(:metadata, {}))
  @kafka = KafkaConfig.new(attributes.fetch(:kafka, {}))
  @database = DatabaseConfig.new(attributes.fetch(:database, {}))
  @objectStore = ObjectStoreConfig.new(attributes.fetch(:objectStore, {}))
  @inMemoryDb = InMemoryDBConfig.new(attributes.fetch(:inMemoryDb, {}))
  @featureFlags = FeatureFlagsConfig.new(attributes.fetch(:featureFlags, {}))
  @endpoints = []
  attributes.fetch(:endpoints, []).each do |attr|
    @endpoints << DependencyEndpoint.new(attr)
  end
  @privateEndpoints = []
  attributes.fetch(:privateEndpoints, []).each do |attr|
    @privateEndpoints << PrivateDependencyEndpoint.new(attr)
  end
end

Instance Attribute Details

#databaseObject

Returns the value of attribute database.



9
10
11
# File 'lib/clowder-common-ruby/types.rb', line 9

def database
  @database
end

#endpointsObject

Returns the value of attribute endpoints.



13
14
15
# File 'lib/clowder-common-ruby/types.rb', line 13

def endpoints
  @endpoints
end

#featureFlagsObject

Returns the value of attribute featureFlags.



12
13
14
# File 'lib/clowder-common-ruby/types.rb', line 12

def featureFlags
  @featureFlags
end

#inMemoryDbObject

Returns the value of attribute inMemoryDb.



11
12
13
# File 'lib/clowder-common-ruby/types.rb', line 11

def inMemoryDb
  @inMemoryDb
end

#kafkaObject

Returns the value of attribute kafka.



8
9
10
# File 'lib/clowder-common-ruby/types.rb', line 8

def kafka
  @kafka
end

#loggingObject

Returns the value of attribute logging.



6
7
8
# File 'lib/clowder-common-ruby/types.rb', line 6

def logging
  @logging
end

#metadataObject

Returns the value of attribute metadata.



7
8
9
# File 'lib/clowder-common-ruby/types.rb', line 7

def 
  @metadata
end

#objectStoreObject

Returns the value of attribute objectStore.



10
11
12
# File 'lib/clowder-common-ruby/types.rb', line 10

def objectStore
  @objectStore
end

#privateEndpointsObject

Returns the value of attribute privateEndpoints.



14
15
16
# File 'lib/clowder-common-ruby/types.rb', line 14

def privateEndpoints
  @privateEndpoints
end

Instance Method Details

#valid_keysObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/clowder-common-ruby/types.rb', line 42

def valid_keys
  [].tap do |keys|
    keys << :privatePort
    keys << :publicPort
    keys << :webPort
    keys << :tlsCAPath
    keys << :metricsPort
    keys << :metricsPath
    keys << :logging
    keys << :metadata
    keys << :kafka
    keys << :database
    keys << :objectStore
    keys << :inMemoryDb
    keys << :featureFlags
    keys << :endpoints
    keys << :privateEndpoints
    keys << :BOPURL
    keys << :hashCache
  end
end