Module: Consul::Template::Generator

Included in:
CMD
Defined in:
lib/consul/template/generator.rb,
lib/consul/template/generator/ct.rb,
lib/consul/template/generator/cmd.rb,
lib/consul/template/generator/run.rb,
lib/consul/template/generator/init.rb,
lib/consul/template/generator/version.rb,
lib/consul/template/generator/key_value.rb,
lib/consul/template/generator/configuration.rb

Defined Under Namespace

Modules: CMD, STDLogLvl, STDLogger Classes: CTRunner, Configuration

Constant Summary collapse

VERSION =
'0.3.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



17
18
19
# File 'lib/consul/template/generator.rb', line 17

def config
  @config
end

.create_session(name) ⇒ Object

Returns the value of attribute create_session.



18
19
20
# File 'lib/consul/template/generator.rb', line 18

def create_session
  @create_session
end

.destroy_session(sess_id) ⇒ Object

Returns the value of attribute destroy_session.



18
19
20
# File 'lib/consul/template/generator.rb', line 18

def destroy_session
  @destroy_session
end

.renew_session(sess_id) ⇒ Object

Returns the value of attribute renew_session.



18
19
20
# File 'lib/consul/template/generator.rb', line 18

def renew_session
  @renew_session
end

Class Method Details

.configure {|self.config| ... } ⇒ Object

Yields:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/consul/template/generator.rb', line 19

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