Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for emtpy defaults section #204 #212

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/hiera_data/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def load_content
else
{}
end
config['defaults'] ||= {}
defaults.deep_merge(config)
rescue => error
raise Hdm::Error, error
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 5
defaults:
hierarchy:
- name: "common settings"
paths:
- "common.yaml"
1 change: 1 addition & 0 deletions test/models/environment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class EnvironmentTest < ActiveSupport::TestCase
expected_environments = %w(
development
dynamic_datadir
empty_defaults
eyaml
globs
hdm
Expand Down
12 changes: 12 additions & 0 deletions test/models/hiera_data/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,16 @@ def base_path
Pathname.new(Rails.configuration.hdm["config_dir"]).join("environments", "multiple_hierarchies")
end
end

class HieraData::ConfigWithEmptyDefaultsTest < ActiveSupport::TestCase
test "empty defaults get replaced" do
config = HieraData::Config.new(base_path)
assert_not_nil config.content["defaults"]
assert_equal Puppet::Pops::Lookup::HieraConfigV5::DEFAULT_CONFIG_HASH["defaults"], config.content["defaults"]
end

def base_path
Pathname.new(Rails.configuration.hdm["config_dir"]).join("environments", "empty_defaults")
end
end
end