provisioners/salt: don't use exteranl deep_merge [GH-2348]
This commit is contained in:
parent
233e8abd35
commit
4c9e6e46b2
|
@ -131,6 +131,8 @@ BUG FIXES:
|
|||
the newest versions of Docker. [GH-2874]
|
||||
- provisioners/puppet: Append default module path to the module paths
|
||||
always. [GH-2677]
|
||||
- provisioners/salt: Setting pillar data doesn't require `deep_merge`
|
||||
plugin anymore. [GH-2348]
|
||||
- provisioners/salt: Options can now set install type and install args.
|
||||
[GH-2766]
|
||||
- provisioners/salt: Fix case when salt would say "options only allowed
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
module Vagrant
|
||||
module Util
|
||||
module DeepMerge
|
||||
# This was lifted straight from Rails 4.0.2 as a basic Hash
|
||||
# deep merge.
|
||||
def self.deep_merge(myself, other_hash, &block)
|
||||
myself = myself.dup
|
||||
other_hash.each_pair do |k,v|
|
||||
tv = myself[k]
|
||||
if tv.is_a?(Hash) && v.is_a?(Hash)
|
||||
myself[k] = deep_merge(tv, v, &block)
|
||||
else
|
||||
myself[k] = block && tv ? block.call(k, tv, v) : v
|
||||
end
|
||||
end
|
||||
myself
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
require "i18n"
|
||||
require "vagrant"
|
||||
require "vagrant/util/deep_merge"
|
||||
|
||||
module VagrantPlugins
|
||||
module Salt
|
||||
|
@ -78,7 +78,7 @@ module VagrantPlugins
|
|||
|
||||
def pillar(data)
|
||||
@pillar_data = {} if @pillar_data == UNSET_VALUE
|
||||
@pillar_data.deep_merge!(data)
|
||||
@pillar_data = Vagrant::Util::DeepMerge.deep_merge(@pillar_data, data)
|
||||
end
|
||||
|
||||
def validate(machine)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
require File.expand_path("../../../base", __FILE__)
|
||||
|
||||
require 'vagrant/util/deep_merge'
|
||||
|
||||
describe Vagrant::Util::DeepMerge do
|
||||
it "should deep merge hashes" do
|
||||
original = {
|
||||
"foo" => {
|
||||
"bar" => "baz",
|
||||
},
|
||||
"bar" => "blah",
|
||||
}
|
||||
|
||||
other = {
|
||||
"foo" => {
|
||||
"bar" => "new",
|
||||
},
|
||||
}
|
||||
|
||||
result = described_class.deep_merge(original, other)
|
||||
expect(result).to_not equal(original)
|
||||
expect(result).to eq({
|
||||
"foo" => {
|
||||
"bar" => "new",
|
||||
},
|
||||
"bar" => "blah",
|
||||
})
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue