mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
(POOLER-103) Fix configuration file loading
This commit updates the method used to load a configuration file to use YAML.load_file, which is how it was configured previously. The capability to specify an alternate configuration file via the VMPOOLER_CONFIG_FILE is retained, and now works as expected.
This commit is contained in:
parent
356c541fdc
commit
00970ffc9e
1 changed files with 9 additions and 8 deletions
|
|
@ -22,17 +22,18 @@ module Vmpooler
|
||||||
|
|
||||||
def self.config(filepath = 'vmpooler.yaml')
|
def self.config(filepath = 'vmpooler.yaml')
|
||||||
# Take the config either from an ENV config variable or from a config file
|
# Take the config either from an ENV config variable or from a config file
|
||||||
config_string = ENV['VMPOOLER_CONFIG'] || begin
|
if ENV['VMPOOLER_CONFIG']
|
||||||
# Take the name of the config file either from an ENV variable or from the filepath argument
|
config_string = ENV['VMPOOLER_CONFIG']
|
||||||
config_file = ENV['VMPOOLER_CONFIG_FILE'] || filepath
|
|
||||||
|
|
||||||
# Return the contents of the config file
|
|
||||||
File.read(File.expand_path(config_file))
|
|
||||||
end
|
|
||||||
|
|
||||||
# Parse the YAML config into a Hash
|
# Parse the YAML config into a Hash
|
||||||
# Whitelist the Symbol class
|
# Whitelist the Symbol class
|
||||||
parsed_config = YAML.safe_load(config_string, [Symbol])
|
parsed_config = YAML.safe_load(config_string, [Symbol])
|
||||||
|
else
|
||||||
|
# Take the name of the config file either from an ENV variable or from the filepath argument
|
||||||
|
config_file = ENV['VMPOOLER_CONFIG_FILE'] || filepath
|
||||||
|
parsed_config = YAML.load_file(config_file)
|
||||||
|
end
|
||||||
|
|
||||||
|
exit unless parsed_config
|
||||||
|
|
||||||
# Bail out if someone attempts to start vmpooler with dummy authentication
|
# Bail out if someone attempts to start vmpooler with dummy authentication
|
||||||
# without enbaling debug mode.
|
# without enbaling debug mode.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue