mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
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:
parent
3b6073933e
commit
21692e021d
1 changed files with 9 additions and 0 deletions
|
|
@ -46,6 +46,15 @@ module Vmpooler
|
|||
parsed_config.merge!(extra_config)
|
||||
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
|
||||
|
||||
parsed_config ||= { config: {} }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue