class Onceover::Node
Attributes
beaker_node[RW]
fact_set[RW]
name[RW]
trusted_external_set[RW]
trusted_set[RW]
Public Class Methods
all()
click to toggle source
# File lib/onceover/node.rb, line 64 def self.all @@all end
clean_facts(factset)
click to toggle source
This method ensures that all facts are valid and clean anoything that we can’t handle
# File lib/onceover/node.rb, line 69 def self.clean_facts(factset) factset.delete('environment') factset end
find(node_name)
click to toggle source
# File lib/onceover/node.rb, line 50 def self.find(node_name) @@all.each do |node| if node_name.is_a?(Onceover::Node) if node = node_name return node end elsif node.name == node_name return node end end logger.warn "Node #{node_name} not found" nil end
new(name)
click to toggle source
# File lib/onceover/node.rb, line 14 def initialize(name) @name = name @beaker_node = nil # If we can't find the factset it will fail, so just catch that error and ignore it begin facts_file_index = Onceover::Controlrepo.facts_files.index {|facts_file| File.basename(facts_file, '.json') == name } @fact_set = Onceover::Node.clean_facts(Onceover::Controlrepo.facts[facts_file_index]) # First see if we can find a 'trusted' hash at the top level of our factset @trusted_set = Onceover::Controlrepo.trusted_facts[facts_file_index] # If we don't find it, attempt to find a 'trusted.extensions' hash nested in our fact_set @trusted_set = @fact_set.dig('trusted', 'extensions') if @trusted_set.nil? # If we still can't find any, return an empty hash so the following doesn't blow up user written tests: # let(:trusted_facts) { trusted_facts } @trusted_set = {} if @trusted_set.nil? # First see if we can find a 'trusted_external' hash at the top level of our factset @trusted_external_set = Onceover::Controlrepo.trusted_external_facts[facts_file_index] # If we don't find it, attempt to find a 'trusted.external' hash nested in our fact_set @trusted_external_set = @fact_set.dig('trusted', 'external') if @trusted_external_set.nil? # If we still can't find any, return an empty hash so the following doesn't blow up user written tests: # let(:trusted_external_data) { trusted_external_data } @trusted_external_set = {} if @trusted_external_set.nil? rescue TypeError @fact_set = {} @trusted_set = {} @trusted_external_set = {} end @@all << self end