glance_image: Enforce correct type for properties
This property supports only strings or hashes. Change-Id: Icf25ce9e2d76c726d3299eb3b5833b3bb3dfc4f0
This commit is contained in:
parent
120b9a0739
commit
89513a4d61
|
@ -106,10 +106,14 @@ Puppet::Type.newtype(:glance_image) do
|
|||
end
|
||||
|
||||
validate do |value|
|
||||
return true if value.is_a? Hash
|
||||
|
||||
value.split(',').each do |property|
|
||||
raise ArgumentError, "Key/value pairs should be separated by an =" unless property.include?('=')
|
||||
if value.is_a?(Hash)
|
||||
return true
|
||||
elsif value.is_a?(String)
|
||||
value.split(',').each do |property|
|
||||
raise ArgumentError, "Key/value pairs should be separated by an =" unless property.include?('=')
|
||||
end
|
||||
else
|
||||
raise ArgumentError, "Invalid properties #{value}. Requires a String or a Hash, not a #{value.class}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue