Class: SensuGenerator::Config
- Inherits:
-
Object
- Object
- SensuGenerator::Config
- Defined in:
- lib/sensu_generator/config.rb
Constant Summary collapse
- @@default =
{ :sensu => { :check_default_params => { :refresh => 86400, :interval => 60, :aggregate => true }, :minimal_to_restart => 2, :service => "sensu-server", :rsync_repo => "sensu-server", :supervisor => {:user => "", :password => ""}, }, :mode => 'server', :server => { :addr => '', :port => nil }, :result_dir => "work/result", :templates_dir => "work/templates", :logger => { :file => STDOUT, :notify_level => "error", :log_level => "debug" }, :slack => { :url => nil, :channel => nil, :level => "error" }, :kv_tags_path => "checks", # See diplomat documentation to set proper consul parameters :consul => { :url => "http://consul.service.consul:8500" } }
Instance Method Summary collapse
- #file_prefix ⇒ Object
- #get ⇒ Object
-
#initialize(path = nil) ⇒ Config
constructor
A new instance of Config.
- #process(path) ⇒ Object
- #result_dir ⇒ Object
Constructor Details
#initialize(path = nil) ⇒ Config
Returns a new instance of Config.
42 43 44 |
# File 'lib/sensu_generator/config.rb', line 42 def initialize(path = nil) @config = process(path) end |
Instance Method Details
#file_prefix ⇒ Object
60 61 62 |
# File 'lib/sensu_generator/config.rb', line 60 def file_prefix @file_prefix ||= get[:mode] == 'server' ? "local_" : "#{Socket.gethostname}_" end |
#get ⇒ Object
46 47 48 |
# File 'lib/sensu_generator/config.rb', line 46 def get @config end |
#process(path) ⇒ Object
50 51 52 53 |
# File 'lib/sensu_generator/config.rb', line 50 def process(path) custom = path ? JSON(File.read(path), :symbolize_names => true) : {} @config = @@default.deep_merge(custom) end |
#result_dir ⇒ Object
55 56 57 58 |
# File 'lib/sensu_generator/config.rb', line 55 def result_dir raise(GeneratorError, "Result dir is not defined!") unless get[:result_dir] File.(get[:result_dir]) end |