diff options
author | Nikita Mathur <nikita.mathur@chef.io> | 2022-06-02 18:56:16 +0530 |
---|---|---|
committer | Nikita Mathur <nikita.mathur@chef.io> | 2022-06-02 18:56:18 +0530 |
commit | fc32fe0b64b0338f7d7261ed3205f3142b9b8d20 (patch) | |
tree | dcfbedd57b51dc3952c89e17395956ff160eea21 | |
parent | 00caf8367203dca11a9d3ccfc4819f85b7fe2542 (diff) | |
download | mixlib-config-fc32fe0b64b0338f7d7261ed3205f3142b9b8d20.tar.gz |
Fix in apply nested hash when passing hash in config
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
-rw-r--r-- | lib/mixlib/config.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/mixlib/config.rb b/lib/mixlib/config.rb index 7e4e139..fd50254 100644 --- a/lib/mixlib/config.rb +++ b/lib/mixlib/config.rb @@ -568,7 +568,10 @@ module Mixlib # hash<Hash>:: The hash to apply to the config object def apply_nested_hash(hash) hash.each do |k, v| - if v.is_a? Hash + if v.is_a?(Hash) && internal_get(k.to_sym).is_a?(Hash) + # If it is a plain config key (not a context) and the value is a Hash, plain merge the Hashes. + internal_set(k.to_sym, internal_get(k.to_sym).merge(v)) + elsif v.is_a? Hash # If loading from hash, and we reference a context that doesn't exist # and warning/strict is off, we need to create the config context that we expected to be here. context = internal_get(k.to_sym) || config_context(k.to_sym) |