Class: Qonfig::Loaders::Vault Private

Inherits:
Basic
  • Object
show all
Defined in:
lib/qonfig/plugins/vault/loaders/vault.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.25.0

Constant Summary collapse

VAULT_EXPR_EVAL_SCOPE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Returns:

  • (Binding)

Since:

  • 0.25.0

Version:

  • 0.27.0

BasicObject.new.__binding__.tap do |binding|
  Object.new.method(:freeze).unbind.bind_call(binding.receiver)
end

Class Method Summary collapse

Methods inherited from Basic

load, load_empty_data

Class Method Details

.empty_dataHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash)

Since:

  • 0.25.0



41
42
43
# File 'lib/qonfig/plugins/vault/loaders/vault.rb', line 41

def empty_data
  {}
end

.load_file(path, fail_on_unexist: true) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • path (String, Pathname)
  • fail_on_unexist (Hash) (defaults to: true)

    a customizable set of options

Options Hash (fail_on_unexist:):

  • (Boolean)

Returns:

  • (Object)

Raises:

Since:

  • 0.25.0



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/qonfig/plugins/vault/loaders/vault.rb', line 24

def load_file(path, fail_on_unexist: true)
  data = ::Vault.with_retries(Vault::HTTPError) do
    ::Vault.logical.read(path.to_s)&.data&.dig(:data)
  end
  raise Qonfig::FileNotFoundError, "Path #{path} not exist" if data.nil? && fail_on_unexist
  result = data || empty_data
  deep_transform_values(result)
rescue Vault::VaultError => error
  raise(Qonfig::VaultLoaderError.new(error.message).tap do |exception|
    exception.set_backtrace(error.backtrace)
  end)
end