module Tiller::ConsulCommon

Public Instance Methods

interpolate(path, template_name = nil) click to toggle source

Interpolate configuration placeholders with values

# File lib/tiller/consul.rb, line 34
def interpolate(path, template_name = nil)
  path.gsub!('%e', Tiller::config[:environment])
  path.gsub!('%t', template_name) if template_name
  path
end
setup() click to toggle source
# File lib/tiller/consul.rb, line 9
def setup
  # Set our defaults if not specified
  @consul_config = Tiller::Consul.defaults
  unless Tiller::config.has_key?('consul')
    Tiller::log.info('No Consul configuration block for this environment')
    return
  end
  @consul_config.deep_merge!(Tiller::config['consul'])

  # Sanity check
  ['url'].each {|c| raise "Consul: Missing Consul configuration #{c}" unless @consul_config.has_key?(c)}

  # Now we connect to Consul
  Diplomat.configure do |config|
    Tiller::log.debug("#{self} : Connecting to Consul at #{@consul_config['url']}")
    config.url = @consul_config['url']

    if @consul_config['acl_token']
      Tiller::log.debug("#{self} : Using Consul ACL token")
      config.acl_token = @consul_config['acl_token']
    end
  end
end