lib/consul/async/vault_endpoint.rb in consul-templaterb-1.25.2 vs lib/consul/async/vault_endpoint.rb in consul-templaterb-1.26.0
- old
+ new
@@ -44,14 +44,19 @@
else
method(symbol).call
end
end
- def create(path)
+ def create(path, agent: nil)
return self unless @paths[path.to_sym]
- VaultConfiguration.new(base_url: ch(path, :base_url),
+ 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),
@@ -115,11 +120,11 @@
# Endpoint in vault (a path in Vault)
class VaultEndpoint
attr_reader :conf, :path, :http_method, :queue, :stats, :last_result, :enforce_json_200, :start_time, :default_value, :query_params
- def initialize(conf, path, http_method = 'GET', enforce_json_200 = true, query_params = {}, default_value = '{}', post_data = {})
- @conf = conf.create(path)
+ def initialize(conf, path, http_method = 'GET', enforce_json_200 = true, query_params = {}, default_value = '{}', post_data = {}, agent: nil)
+ @conf = conf.create(path, agent: agent)
@default_value = default_value
@path = path
@http_method = http_method
@queue = EM::Queue.new
@x_consul_index = 0