module Muchkeys
Constants
- VERSION
Public Class Methods
configure_from_yaml(file)
click to toggle source
# File lib/muchkeys.rb, line 58 def self.configure_from_yaml(file) app_config = YAML.load(File.read(file)).with_indifferent_access Muchkeys.configure do |config| config.application_name = app_config[:application_name] if app_config.has_key?(:application_name) config.consul_url = app_config[:consul_url] if app_config.has_key?(:consul_url) config.keys_dir = app_config[:keys_dir] if app_config.has_key?(:keys_dir) config.private_key = app_config[:private_key] if app_config.has_key?(:private_key) config.public_key = app_config[:public_key] if app_config.has_key?(:public_key) config.search_paths = app_config[:search_paths] if app_config.has_key?(:search_paths) config.secrets_hint = app_config[:secrets_hint] if app_config.has_key?(:secrets_hint) end end
env_keys()
click to toggle source
# File lib/muchkeys.rb, line 42 def self.env_keys # parse all environments found in .env and populate them from consul if defined? ::Rails check_dir = ::Rails.root else check_dir = Pathname.getwd end unless File.exists?(check_dir.join(".env")) raise IOError, ".env files are required for Muchkeys ENV injection to work" end File.read(check_dir.join(".env")).each_line.select(&:presence).map { |x| x.split("=")[0] } end
populate_environment!(*required_keys)
click to toggle source
# File lib/muchkeys.rb, line 71 def self.populate_environment!(*required_keys) app = ApplicationClient.new(config) app.verify_keys(*required_keys) app.known_keys.each do |key| ENV[key] ||= app.first(key) end nil end