Skip to content

Commit

Permalink
Convert hash keys to strings #293 (#302)
Browse files Browse the repository at this point in the history
* Convert hash keys to strings #293

Rails automatically converts keys to symbols, but this is not
standard behavior of the YAML parser, so we had a mismatch
here.

* Fix mixup #293

I wanted to revert my temporary changes to test data and
accidentally reverted the adjusted test for the previous
commit. This commit resolves that mixup.

---------

Co-authored-by: Martin Alfke <tuxmea@users.noreply.github.com>
  • Loading branch information
oneiros and tuxmea authored Feb 20, 2024
1 parent 381e915 commit c968bc6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/hiera_data/hierarchy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def determine_backend
value = raw_hash[lookup_function]
backends = BACKENDS
custom_mappings = Rails.configuration.hdm[:custom_lookup_function_mapping]
backends = backends.deep_merge({ "lookup_key" => custom_mappings }) if custom_mappings.present?
backends = backends.deep_merge({ "lookup_key" => custom_mappings.stringify_keys }) if custom_mappings.present?
backends.fetch(key).fetch(value).to_sym
rescue KeyError
raise Hdm::Error, "unknown backend #{value}"
Expand Down
2 changes: 1 addition & 1 deletion test/models/hiera_data/hierarchy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class HierarchyForCustomBackend < ActiveSupport::TestCase

test "custom lookup function mapped to eyaml" do
Rails.configuration.hdm[:custom_lookup_function_mapping] = {
"custom_eyaml_function" => "eyaml"
custom_eyaml_function: "eyaml"
}
hierarchy = HieraData::Hierarchy.new(raw_hash:, base_path: ".")
assert_equal :eyaml, hierarchy.backend
Expand Down

0 comments on commit c968bc6

Please sign in to comment.