Skip to content

Commit 21692e0

Browse files
committed
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.
1 parent 3b60739 commit 21692e0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/vmpooler.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ def self.config(filepath = 'vmpooler.yaml')
4646
parsed_config.merge!(extra_config)
4747
end
4848
end
49+
parsed_config[:config]['pools_from_dir'] = ENV['POOLS_FROM_DIR'] if ENV['POOLS_FROM_DIR']
50+
if parsed_config[:config]['pools_from_dir'] && Dir.exist?(parsed_config[:config]['pools_from_dir'])
51+
pools_from_dir = []
52+
Dir["#{parsed_config[:config]['pools_from_dir']}/*.yaml"].sort.each do |file_name|
53+
parsed_pool = Yaml.load_file(file_name)
54+
pools_from_dir += parsed_pool if parsed_pool
55+
end
56+
parsed_config[:pools] = pools_from_dir unless pools_from_dir.empty?
57+
end
4958
end
5059

5160
parsed_config ||= { config: {} }

0 commit comments

Comments
 (0)