Allow loading pools from a directory of files

This allows for specifying a directory containing yaml files with one or
more array entries inside where each array entry is a pool definition.
The reason for this addition is to facilitate having one ConfigMap per
pool in Kubernetes.
This commit is contained in:
Gene Liverman 2021-08-12 15:56:32 -04:00
parent 3b6073933e
commit 21692e021d
No known key found for this signature in database
GPG key ID: A5E7EC8322AE6F74

View file

@ -46,6 +46,15 @@ module Vmpooler
parsed_config.merge!(extra_config) parsed_config.merge!(extra_config)
end end
end end
parsed_config[:config]['pools_from_dir'] = ENV['POOLS_FROM_DIR'] if ENV['POOLS_FROM_DIR']
if parsed_config[:config]['pools_from_dir'] && Dir.exist?(parsed_config[:config]['pools_from_dir'])
pools_from_dir = []
Dir["#{parsed_config[:config]['pools_from_dir']}/*.yaml"].sort.each do |file_name|
parsed_pool = Yaml.load_file(file_name)
pools_from_dir += parsed_pool if parsed_pool
end
parsed_config[:pools] = pools_from_dir unless pools_from_dir.empty?
end
end end
parsed_config ||= { config: {} } parsed_config ||= { config: {} }