module Consul::Template::Generator

Constants

VERSION

Attributes

config[RW]
create_session[RW]
destroy_session[RW]
renew_session[RW]

Public Class Methods

configure() { |config| ... } click to toggle source
# File lib/consul/template/generator.rb, line 20
def configure
  self.config ||= Consul::Template::Generator::Configuration.new
  self.config.node = `hostname`.strip
  self.config.consul_host = '127.0.0.1:8500'

  yield self.config

  if self.config.consul_template_binary.nil?
    ct_binary = `which consul-template`.strip
    if ct_binary.empty?
      raise "consul-template must be in your $PATH or configure the location to the executable"
    end
    self.config.consul_template_binary = ct_binary
  end

  if self.config.templates.empty? || self.config.templates.any? { |k,v| v.nil? }
    raise "template must be defined in configuration"
  end

  Diplomat.configure do |config|
    config.url = "http://#{self.config.consul_host}"
    config.options = self.config.client_options
  end
end