FAQ
After some more digging, I found that the logic of
Hash.merge is reversed with the logic of DeepHash.merge,
so to get the expected results, the hiera/backend.rb must swap its hashes

When you change the merge_answer in hiera/backand.rb
from:

     def merge_answer(left,right)
       case Config[:merge_behavior]
       when :deeper,'deeper'
         left.deep_merge!(right)
       when :deep,'deep'
         left.deep_merge(right)
       else # Native and undefined
         left.merge(right)
       end
     end

to:

     def merge_answer(left,right)
       case Config[:merge_behavior]
       when :deeper,'deeper'
         right.deep_merge!(left) # <- swapped left/right
       when :deep,'deep'
         right.deep_merge(left) # <- swapped left/right
       else # Native and undefined
         left.merge(right)
       end
     end

then the results are what I expected

Fred.


Op maandag 20 mei 2013 11:53:20 UTC+2 schreef Fred Gansevles het volgende:
I was playing around with the new deep-merge hiera feature to check it's
usability

I found some unexpected behaviour with array resolution

the following yaml files get parsed

top.yaml:
----
arr:
- 1
hsh:
arr:
- 1

mid.yaml:
----
arr:
- 2
hsh:
arr:
- 2

bot.yaml:
----
arr:
- 3
hsh:
arr:
- 3

with :merge_behavior: deep (or deeper) I get the following result

$ hiera -a arr
[1, 2, 3] # I expected this

$ hiera -h hsh
{"arr"=>[3, 2, 1]} # I expected {"arr"=>[1, 2, 3]}

I've located the curl-pit in the deep_merge gem, but I am not sure if this
must be fixed there (the deep_merge gem is probably used by others)

any thoughts?

Fred.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
grouppuppet-users @
categoriespuppet
postedMay 20, '13 at 9:53a
activeMay 20, '13 at 4:27p
posts2
users1
websitepuppetlabs.com

1 user in discussion

Fred Gansevles: 2 posts

People

Translate

site design / logo © 2022 Grokbase