mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
B #-: Fix loading YAML with aliases (#3194)
+ make empty YAML load backward comp.
This commit is contained in:
parent
97237d6f3c
commit
9f77a06745
@ -41,7 +41,15 @@ module OneCfg::Config::Type
|
||||
def load(name = @name)
|
||||
reset
|
||||
|
||||
@content = YAML.load_file(name)
|
||||
if Gem::Version.new(Psych.const_get(:VERSION)) >= Gem::Version.new('4.0')
|
||||
@content = YAML.load_file(name, :aliases => true)
|
||||
|
||||
# for backward compatibility with older Psych return `false`
|
||||
# instead of `nil` if the file was empty
|
||||
@content = false if @content.nil?
|
||||
else
|
||||
@content = YAML.load_file(name)
|
||||
end
|
||||
|
||||
@content
|
||||
end
|
||||
|
@ -165,7 +165,11 @@ module OneCfg::Patch
|
||||
#
|
||||
# @param filename [String] path to patch in YAML format
|
||||
def parse_yaml(filename)
|
||||
@patches = YAML.load_file(filename)
|
||||
if Psych::VERSION > '4.0'
|
||||
@patches = YAML.load_file(filename, :aliases => true)
|
||||
else
|
||||
@patches = YAML.load_file(filename)
|
||||
end
|
||||
|
||||
return if @patches.is_a?(Hash)
|
||||
|
||||
|
@ -42,7 +42,11 @@ module OneCfg
|
||||
reset
|
||||
|
||||
if ::File.exist?(@name)
|
||||
@content = YAML.load_file(@name)
|
||||
if Psych::VERSION > '4.0'
|
||||
@content = YAML.load_file(@name, :aliases => true)
|
||||
else
|
||||
@content = YAML.load_file(@name)
|
||||
end
|
||||
end
|
||||
rescue StandardError => e
|
||||
OneCfg::LOG.error("Can't load settings from '#{@name}' " \
|
||||
|
Loading…
x
Reference in New Issue
Block a user