class Minimart::Mirror::InventoryConfiguration
This class is responsible for parsing a user defined Minimart
configuration file.
Attributes
configuration[R]
The raw parsed configuration file
inventory_config_path[R]
The path to the inventory configuration file
Public Class Methods
new(inventory_config_path)
click to toggle source
@param [String] inventory_config_path
The path to the inventory configuration file
# File lib/minimart/mirror/inventory_configuration.rb, line 17 def initialize(inventory_config_path) @inventory_config_path = inventory_config_path @configuration = parse_config_file parse_global_configuration end
Public Instance Methods
requirements()
click to toggle source
The collection of cookbook requirements defined in the inventory file @return [Array]
# File lib/minimart/mirror/inventory_configuration.rb, line 31 def requirements @cookbooks ||= InventoryRequirements.new(raw_cookbooks) end
sources()
click to toggle source
The collection of files defined in the inventory file @return [Minimart::Mirror::Sources]
# File lib/minimart/mirror/inventory_configuration.rb, line 25 def sources @sources ||= Sources.new(raw_sources) end
Private Instance Methods
parse_config_file()
click to toggle source
# File lib/minimart/mirror/inventory_configuration.rb, line 40 def parse_config_file unless Utils::FileHelper.file_exists?(inventory_config_path) raise Error::InvalidInventoryError, 'The inventory configuration file could not be found' end file = File.open(inventory_config_path).read erb = ERB.new(file).result(binding) YAML.load(erb) end
parse_global_configuration()
click to toggle source
# File lib/minimart/mirror/inventory_configuration.rb, line 50 def parse_global_configuration return unless (conf = configuration['configuration']) && conf.is_a?(Hash) Minimart::Configuration.tap do |c| c.chef_server_config = conf.fetch('chef', {}) c.github_config = conf.fetch('github', []) c.verify_ssl = conf['verify_ssl'] end end
raw_cookbooks()
click to toggle source
# File lib/minimart/mirror/inventory_configuration.rb, line 64 def raw_cookbooks configuration['cookbooks'].tap do |cookbooks| if cookbooks.nil? || cookbooks.empty? raise Error::InvalidInventoryError, 'Minimart could not find any cookbooks defined in the inventory' end end end
raw_sources()
click to toggle source
# File lib/minimart/mirror/inventory_configuration.rb, line 60 def raw_sources configuration['sources'] || [] end