Skip to content

Commit

Permalink
Adapted for Facter 4 factsets
Browse files Browse the repository at this point in the history
The facts function was updated to understand that the top level key
'values' may not exist. A two new factsets were added under spec to
validate things work with both a Facter 4 and pre-Facter 4 factset is
present. Additionally, the list of nodes in the caching control repo was
sorted.

In addition to changes directly related to this issue, fixes required by
the current version of Rubocop were also applied.

Fixes #307
  • Loading branch information
genebean authored and dylanratcliffe committed Mar 17, 2021
1 parent 6ead124 commit 95bd1a8
Show file tree
Hide file tree
Showing 4 changed files with 1,820 additions and 23 deletions.
21 changes: 10 additions & 11 deletions lib/onceover/controlrepo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,14 @@ def facts(filter = nil, key = 'values')
all_facts = []
logger.debug "Reading factsets"
@facts_files.each do |file|
all_facts << read_facts(file)[key]
facts_from_file = read_facts(file)
# Facter 4 removed the top level key 'values' and, instead, puts facts
# at the top level. The conditional below accounts for this.
if (key.eql?('values') and facts_from_file.has_key?('values')) or !key.eql?('values')
all_facts << facts_from_file[key]
else
all_facts << facts_from_file
end
end
if filter
# Allow us to pass a hash of facts to filter by
Expand All @@ -201,11 +208,7 @@ def facts(filter = nil, key = 'values')
filter.each do |filter_fact,value|
matches << keypair_is_in_hash(hash,filter_fact,value)
end
if matches.include? false
false
else
true
end
!matches.include? false
end
end
return all_facts
Expand Down Expand Up @@ -626,11 +629,7 @@ def keypair_is_in_hash(first_hash, key, value)
else
matches << false
end
if matches.include? false
false
else
true
end
!matches.include? false
end

def get_classes(dir)
Expand Down
Loading

0 comments on commit 95bd1a8

Please sign in to comment.