(maint) Fix EXTRA_CONFIG merge behavior

Before this change if an extra config file had new keys they would get
merged to the main config but if it contained an existing key, like
'providers' it would overwrite the original config.
Adding a library 'deep_merge' to do a more natural merge, where existing keys
get sub-elements added together and arrays are combined like for the
pool configuration.
Adding spec tests around EXTRA_CONFIG as they were missing, by adding
and testing two new extra_config.yaml fixture files
This commit is contained in:
Samuel Beaulieu 2021-12-23 10:58:38 -06:00
parent 39dc26e485
commit 23efcc4cc0
No known key found for this signature in database
GPG key ID: 12030F74136D0F34
5 changed files with 39 additions and 2 deletions

View file

@ -3,6 +3,7 @@
module Vmpooler
require 'concurrent'
require 'date'
require 'deep_merge'
require 'json'
require 'net/ldap'
require 'open-uri'
@ -42,7 +43,7 @@ module Vmpooler
extra_configs = parsed_config[:config]['extra_config'].split(',')
extra_configs.each do |config|
extra_config = YAML.load_file(config)
parsed_config.merge!(extra_config)
parsed_config.deep_merge(extra_config)
end
end
end