class Consul::Async::VaultConfiguration

Configuration for Vault Endpoints

Attributes

base_url[R]
debug[R]
fail_fast_errors[R]
lease_duration_factor[R]
max_consecutive_errors_on_endpoint[R]
max_retry_duration[R]
min_duration[R]
retry_duration[R]
retry_on_non_diff[R]
tls_cert_chain[R]
tls_private_key[R]
tls_verify_peer[R]
token[R]
token_renew[R]
wait_duration[R]

Public Class Methods

new(base_url: 'http://localhost:8200', debug: { network: false }, token: nil, token_renew: true, retry_duration: 10, min_duration: 0.1, lease_duration_factor: 0.5, max_retry_duration: 600, paths: {}, max_consecutive_errors_on_endpoint: 10, fail_fast_errors: false, tls_cert_chain: nil, tls_private_key: nil, tls_verify_peer: true) click to toggle source
# File lib/consul/async/vault_endpoint.rb, line 16
def initialize(base_url: 'http://localhost:8200',
               debug: { network: false },
               token: nil,
               token_renew: true,
               retry_duration: 10,
               min_duration: 0.1,
               lease_duration_factor: 0.5,
               max_retry_duration: 600,
               paths: {},
               max_consecutive_errors_on_endpoint: 10,
               fail_fast_errors: false,
               tls_cert_chain: nil,
               tls_private_key: nil,
               tls_verify_peer: true)
  @base_url = base_url
  @token_renew = token_renew
  @debug = debug
  @retry_duration = retry_duration
  @min_duration = min_duration
  @max_retry_duration = max_retry_duration
  @lease_duration_factor = lease_duration_factor
  @paths = paths
  @token = token
  @max_consecutive_errors_on_endpoint = max_consecutive_errors_on_endpoint
  @fail_fast_errors = fail_fast_errors
  @tls_cert_chain = tls_cert_chain
  @tls_private_key = tls_private_key
  @tls_verify_peer = tls_verify_peer
end

Public Instance Methods

ch(path, symbol) click to toggle source
# File lib/consul/async/vault_endpoint.rb, line 46
def ch(path, symbol)
  sub = @paths[path.to_sym]
  if sub && sub[symbol]
    ::Consul::Async::Debug.puts_info "Overriding #{symbol}:=#{sub[symbol]} for #{path}"
    sub[symbol]
  else
    method(symbol).call
  end
end
create(path, agent: nil) click to toggle source
# File lib/consul/async/vault_endpoint.rb, line 56
def create(path, agent: nil)
  return self unless @paths[path.to_sym]

  base_url = ch(path, :base_url)
  if agent
    agent = "http://#{agent}" unless agent.start_with? 'http', 'https'
    base_url = agent
  end
  VaultConfiguration.new(base_url: base_url,
                         debug: ch(path, :debug),
                         token: ch(path, :token),
                         retry_duration: ch(path, :retry_duration),
                         min_duration: ch(path, :min_duration),
                         max_retry_duration: ch(path, :max_retry_duration),
                         lease_duration_factor: ch(path, :lease_duration_factor),
                         paths: @paths,
                         max_consecutive_errors_on_endpoint: @max_consecutive_errors_on_endpoint,
                         fail_fast_errors: @fail_fast_errors)
end