Skip to content

Commit

Permalink
(GH-543) - Fix merging of nested default facts
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanbreen28 committed Apr 3, 2024
1 parent 748bd60 commit e7c7598
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ Gemfile:
- gem: racc
version: '~> 1.4.0'
condition: "Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))"
- gem: deep_merge
version: '~> 1.0'
- gem: 'voxpupuli-puppet-lint-plugins'
version: '~> 5.0'
- gem: 'facterdb'
Expand Down
5 changes: 3 additions & 2 deletions moduleroot/spec/spec_helper.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ default_fact_files.each do |f|
next unless File.exist?(f) && File.readable?(f) && File.size?(f)

begin
default_facts.merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true))
require 'deep_merge'
default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true))
rescue StandardError => e
RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
end
end

# read default_facts and merge them over what is provided by facterdb
default_facts.each do |fact, value|
add_custom_fact fact, value
add_custom_fact fact, value, merge_facts: true
end

RSpec.configure do |c|
Expand Down

0 comments on commit e7c7598

Please sign in to comment.