Module: ContainerConfig
- Defined in:
- lib/container_config.rb,
lib/container_config/rails.rb,
lib/container_config/redis.rb,
lib/container_config/logger.rb,
lib/container_config/coercer.rb,
lib/container_config/version.rb,
lib/container_config/provider.rb,
lib/container_config/coercer/base.rb,
lib/container_config/provider/env.rb,
lib/container_config/rails/mailer.rb,
lib/container_config/coercer/float.rb,
lib/container_config/provider/base.rb,
lib/container_config/coercer/string.rb,
lib/container_config/coercer/symbol.rb,
lib/container_config/coercer/boolean.rb,
lib/container_config/coercer/integer.rb,
lib/container_config/coercer/ssl_key.rb,
lib/container_config/provider/default.rb,
lib/container_config/provider/secret_volume.rb,
lib/container_config/coercer/ssl_certificate.rb,
lib/container_config/coercer/ssl_verify_mode.rb,
lib/container_config/provider/rails_credential.rb
Overview
Contains methods for loading and parsing container configuration
Defined Under Namespace
Modules: Coercer, Provider, Rails, Redis Classes: Error, InvalidEnumValue, Logger, MissingOverride, MissingRequiredValue
Constant Summary collapse
- VERSION =
ContainerConfig version
"0.2.0"
Class Method Summary collapse
-
.cache ⇒ Hash
Gets the configuration cache.
-
.clear_cache ⇒ Object
Clears all entries from the configuration cache.
-
.coercers ⇒ Array<ContainerConfig::Coercer::Base>
Gets the list of configuration value coercers.
-
.coercers=(coercers) ⇒ Object
Sets the list of configuration value coercers.
-
.load(key, *dig_keys, **options) ⇒ Object
Loads a configuration setting from environment variables, mounted secrets, or the application credentials.
-
.log_formatter ⇒ ::Logger::Formatter
Gets the container config log formatter.
-
.log_formatter=(log_formatter) ⇒ Object
Sets the container config log formatter.
-
.logger ⇒ ContainerConfig::Logger
Gets the container config logger.
-
.logger=(logger) ⇒ Object
Sets the container config logger.
-
.providers ⇒ Array<ContainerConfig::Provider::Base>
Gets the list of configuration value providers.
-
.providers=(providers) ⇒ Object
Sets the list of configuration value providers.
-
.rails_app? ⇒ Boolean
Whether this is in the context of a Rails application.
Class Method Details
.cache ⇒ Hash
Gets the configuration cache
61 62 63 |
# File 'lib/container_config.rb', line 61 def self.cache @cache ||= {} end |
.clear_cache ⇒ Object
Clears all entries from the configuration cache
52 53 54 |
# File 'lib/container_config.rb', line 52 def self.clear_cache @cache = {} end |
.coercers ⇒ Array<ContainerConfig::Coercer::Base>
Gets the list of configuration value coercers
70 71 72 |
# File 'lib/container_config.rb', line 70 def self.coercers @coercers ||= ContainerConfig::Coercer.default_coercers end |
.coercers=(coercers) ⇒ Object
Sets the list of configuration value coercers
79 80 81 |
# File 'lib/container_config.rb', line 79 def self.coercers=(coercers) @coercers = coercers end |
.load(key, *dig_keys, **options) ⇒ Object
Loads a configuration setting from environment variables, mounted secrets, or the application credentials
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/container_config.rb', line 32 def self.load(key, *dig_keys, **) logger.debug { "Loading configuration value for #{key}" } [:required] ||= [:raise] || false dig_keys = key.downcase.split("_") if dig_keys.empty? return cache[key] if [:cache] && cache.key?(key) config_value = ContainerConfig::Provider.load_value(key, *dig_keys, **) handle_empty_value(config_value, key, **) config_value = ContainerConfig::Coercer.coerce_value(config_value, [:type], **) handle_enum(config_value, **) cache[key] = config_value if [:cache] config_value end |
.log_formatter ⇒ ::Logger::Formatter
Gets the container config log formatter
128 129 130 |
# File 'lib/container_config.rb', line 128 def self.log_formatter @log_formatter ||= logger.formatter end |
.log_formatter=(log_formatter) ⇒ Object
Sets the container config log formatter
137 138 139 140 |
# File 'lib/container_config.rb', line 137 def self.log_formatter=(log_formatter) @log_formatter = log_formatter logger.formatter = log_formatter end |
.logger ⇒ ContainerConfig::Logger
Gets the container config logger
106 107 108 |
# File 'lib/container_config.rb', line 106 def self.logger @logger ||= ContainerConfig::Logger.new($stdout, level: Logger::INFO) end |
.logger=(logger) ⇒ Object
Sets the container config logger
115 116 117 118 119 120 121 |
# File 'lib/container_config.rb', line 115 def self.logger=(logger) if logger.nil? self.logger.level = Logger::FATAL return self.logger end @logger = logger end |
.providers ⇒ Array<ContainerConfig::Provider::Base>
Gets the list of configuration value providers
88 89 90 |
# File 'lib/container_config.rb', line 88 def self.providers @providers ||= ContainerConfig::Provider.default_providers end |
.providers=(providers) ⇒ Object
Sets the list of configuration value providers
97 98 99 |
# File 'lib/container_config.rb', line 97 def self.providers=(providers) @providers = providers end |
.rails_app? ⇒ Boolean
Whether this is in the context of a Rails application
147 148 149 |
# File 'lib/container_config.rb', line 147 def self.rails_app? defined?(::Rails) && ::Rails.respond_to?(:application) end |