Module: SecretsLoader
- Defined in:
- lib/secrets_loader.rb,
lib/secrets_loader/config.rb,
lib/secrets_loader/railtie.rb,
lib/secrets_loader/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.1.0'
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
8 9 10 |
# File 'lib/secrets_loader.rb', line 8 def config @config end |
Class Method Details
.enable_secrets_loader? ⇒ Boolean
28 29 30 31 |
# File 'lib/secrets_loader.rb', line 28 def enable_secrets_loader? return false if ENV['ENABLE_SECRETS_LOADER'].nil? || ENV['ENABLE_SECRETS_LOADER'].empty? !(config.secret_id.nil? || config.secret_id.empty?) end |
.load ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/secrets_loader.rb', line 10 def load return unless enable_secrets_loader? load_secret_values.each do |key, value| if ENV.has_key?(key) warn "WARNING: Skipping key #{key.inspect}. Already set in ENV." else ENV[key] = value.to_s end end end |
.load_secret_values ⇒ Object
22 23 24 25 26 |
# File 'lib/secrets_loader.rb', line 22 def load_secret_values secrets_manager = config.client secret_string = secrets_manager.get_secret_value(secret_id: config.secret_id).secret_string JSON.parse(secret_string) end |