Module: FlapjackConfigurator

Defined in:
lib/flapjack_configurator.rb,
lib/flapjack_configurator/version.rb,
lib/flapjack_configurator/entity_mapper.rb,
lib/flapjack_configurator/flapjack_media.rb,
lib/flapjack_configurator/flapjack_config.rb,
lib/flapjack_configurator/flapjack_contact.rb,
lib/flapjack_configurator/flapjack_pagerduty.rb,
lib/flapjack_configurator/user_configuration.rb,
lib/flapjack_configurator/flapjack_object_base.rb,
lib/flapjack_configurator/flapjack_sub_object_base.rb,
lib/flapjack_configurator/flapjack_notification_rule.rb

Overview

Define the gem version

Defined Under Namespace

Classes: EntityMapper, FlapjackConfig, FlapjackContact, FlapjackMedia, FlapjackNotificationRule, FlapjackObjectBase, FlapjackPagerduty, FlapjackSubObjectBase, UserConfiguration

Constant Summary collapse

VERSION =
'1.1.0'

Class Method Summary collapse

Class Method Details

.configure_flapjack(config, api_base_url = 'http://127.0.0.1:3081', logger = Logger.new(STDOUT), enable_all_entity = true) ⇒ Object

Method to configure flapjack



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/flapjack_configurator.rb', line 11

def self.configure_flapjack(config, api_base_url = 'http://127.0.0.1:3081', logger = Logger.new(STDOUT), enable_all_entity = true)
  ret_val = false
  Flapjack::Diner.base_uri(api_base_url)

  # The underlying classes treat the Flapjack::Diner module as if it is a class.
  # This was done as it was fairly natural and will allow Flapjack::Diner to be
  # replaced or wrapped very easily in the future.
  config_obj = FlapjackConfig.new(config, Flapjack::Diner, logger)

  if enable_all_entity
    # Ensure the ALL entity is present
    ret_val = true if config_obj.add_all_entity
  end

  # Update the contacts
  # This will update media, PD creds, notification rules, and entity associations
  #   as they're associated to the contact.
  ret_val = true if config_obj.update_contacts

  return ret_val
end

.load_config(file_list, logger) ⇒ Object

Helper to load and merge config yaml files



34
35
36
37
38
39
40
41
42
# File 'lib/flapjack_configurator.rb', line 34

def self.load_config(file_list, logger)
  config = {}
  file_list.each do |file_name|
    logger.debug("Loading config file #{file_name}")
    config.deep_merge!(YAML.load_file(file_name))
  end

  return config
end