lib/onceover/controlrepo.rb in onceover-3.5.2 vs lib/onceover/controlrepo.rb in onceover-3.6.0

- old
+ new

@@ -68,13 +68,17 @@ def self.config @@existing_controlrepo.config end def self.facts(filter = nil) - @@existing_controlrepo.facts(filter) + @@existing_controlrepo.facts(filter, 'values') end + def self.trusted_facts(filter = nil) + @@existing_controlrepo.facts(filter, 'trusted') + end + def self.hiera_config_file @@existing_controlrepo.hiera_config_file end # # End class methods @@ -168,16 +172,16 @@ classes << get_classes(dir) end classes.flatten end - def facts(filter = nil) + def facts(filter = nil, key = 'values') # Returns an array facts hashes all_facts = [] logger.debug "Reading factsets" @facts_files.each do |file| - all_facts << read_facts(file)['values'] + all_facts << read_facts(file)[key] end if filter # Allow us to pass a hash of facts to filter by raise "Filter param must be a hash" unless filter.is_a?(Hash) all_facts.keep_if do |hash| @@ -577,10 +581,10 @@ def read_facts(facts_file) file = File.read(facts_file) begin result = JSON.parse(file) rescue JSON::ParserError - raise "Could not parse the JSON file, check that it is valid JSON and that the encoding is correct" + raise "Could not parse the file #{facts_file}, check that it is valid JSON and that the encoding is correct" end result end def keypair_is_in_hash(first_hash, key, value)