class KumoConfig::EnvironmentConfig
Environment Configuration for an infrastructure stack
Constants
- LOGGER
Attributes
app_name[R]
env_name[R]
Public Class Methods
new(options, logger = LOGGER)
click to toggle source
# File lib/kumo_config/environment_config.rb, line 16 def initialize(options, logger = LOGGER) @env_name = options[:env_name] @injected_config = options[:injected_config] || {} @log = logger if options[:config_path] @config_file_loader = KumoConfig::FileLoader.new(config_dir_path: options[:config_path]) elsif options[:config_dir_path] @log.warn "[DEPRECATION] `:config_dir_path` is deprecated, please pass in `:config_path` instead" @config_file_loader = KumoConfig::FileLoader.new(config_dir_path: options[:config_dir_path]) end end
Public Instance Methods
config()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 42 def config # a hash of all settings that apply to this environment @config ||= common_config.merge(env_config).merge(@injected_config) end
development?()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 34 def development? !%w(production staging).include? env_name end
get_binding()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 47 def get_binding binding end
plain_text_secrets()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 38 def plain_text_secrets @plain_text_secrets ||= decrypt_secrets(encrypted_secrets) end
production?()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 30 def production? env_name == 'production' end
Private Instance Methods
common_config()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 105 def common_config @config_file_loader.load_hash('common.yml') end
decrypt_cipher(name, cipher_text)
click to toggle source
# File lib/kumo_config/environment_config.rb, line 66 def decrypt_cipher(name, cipher_text) if cipher_text.start_with? '[ENC,' begin [name, kms.decrypt(cipher_text[5, cipher_text.size]).to_s] rescue @log.error "Error decrypting secret '#{name}'" raise end else [name, cipher_text] end end
decrypt_secrets(secrets)
click to toggle source
# File lib/kumo_config/environment_config.rb, line 57 def decrypt_secrets(secrets) Hash[ secrets.map do |name, cipher_text| @log.debug "Decrypting '#{name}'" decrypt_cipher name, cipher_text end ] end
encrypted_common_secrets()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 91 def encrypted_common_secrets @config_file_loader.load_hash('common_secrets.yml') end
encrypted_env_secrets()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 95 def encrypted_env_secrets secrets = @config_file_loader.load_hash(env_secrets_file_name) if !secrets.empty? secrets else @config_file_loader.load_hash('development_secrets.yml') end end
encrypted_secrets()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 87 def encrypted_secrets encrypted_common_secrets.merge(encrypted_env_secrets) end
env_config()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 109 def env_config config = @config_file_loader.load_hash(env_config_file_name) if !config.empty? config else @config_file_loader.load_hash('development.yml') end end
env_config_file_name()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 79 def env_config_file_name "#{env_name}.yml" end
env_secrets_file_name()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 83 def env_secrets_file_name "#{env_name}_secrets.yml" end
kms()
click to toggle source
# File lib/kumo_config/environment_config.rb, line 53 def kms @kms ||= KumoKi::KMS.new end