Class: SettingsReader::VaultResolver::Instance
- Inherits:
-
Object
- Object
- SettingsReader::VaultResolver::Instance
- Includes:
- Logging
- Defined in:
- lib/settings_reader/vault_resolver/instance.rb
Overview
Resolver class for Settings Reader
Constant Summary collapse
- IDENTIFIER =
'vault://'.freeze
- DATABASE_MOUNT =
'database'.freeze
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ Instance
constructor
A new instance of Instance.
- #resolvable?(value, _path) ⇒ Boolean
-
#resolve(value, _path) ⇒ Object
Expect value in format ‘vault://mount/path/to/secret?attribute_name`.
Methods included from Logging
Constructor Details
#initialize(config) ⇒ Instance
Returns a new instance of Instance.
14 15 16 17 |
# File 'lib/settings_reader/vault_resolver/instance.rb', line 14 def initialize(config) @config = config @engines = config.vault_engines end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/settings_reader/vault_resolver/instance.rb', line 12 def config @config end |
Instance Method Details
#resolvable?(value, _path) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/settings_reader/vault_resolver/instance.rb', line 19 def resolvable?(value, _path) return unless value.respond_to?(:start_with?) value.start_with?(IDENTIFIER) end |
#resolve(value, _path) ⇒ Object
Expect value in format ‘vault://mount/path/to/secret?attribute_name`
26 27 28 29 30 31 |
# File 'lib/settings_reader/vault_resolver/instance.rb', line 26 def resolve(value, _path) debug { "Resolving Vault secret at #{value}" } address = SettingsReader::VaultResolver::Address.new(value) entry = fetch_entry(address) entry&.value_for(address.attribute) end |