Class: SettingsReader::VaultResolver::Instance

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Logging

#debug, #error, #info, #warn

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

#configObject (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

Returns:

  • (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