cinder_type: Fix regex for properties to accept short value
This fixes the regex to validate the properties property so that value
strings shorter than 3 characters are accepted.
This also removes the heading spaces because these are not stripped but
added to the keys, which likely results in an unexpected result.
Change-Id: I8d703a48060abb61834ecec9c72bb6295eff2b81
(cherry picked from commit 0f500ef7da)
This commit is contained in:
@@ -9,14 +9,14 @@ Puppet::Type.newtype(:cinder_type) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
newproperty(:properties, :array_matching => :all) do
|
newproperty(:properties, :array_matching => :all) do
|
||||||
desc 'The properties of the cinder type. Should be an array, all items should match pattern <key=value1[,value2 ...]>'
|
desc 'The properties of the cinder type. Should be an array, all items should match pattern <key=value>'
|
||||||
defaultto []
|
defaultto []
|
||||||
def insync?(is)
|
def insync?(is)
|
||||||
return false unless is.is_a? Array
|
return false unless is.is_a? Array
|
||||||
is.sort == should.sort
|
is.sort == should.sort
|
||||||
end
|
end
|
||||||
validate do |value|
|
validate do |value|
|
||||||
raise ArgumentError, "Properties doesn't match" unless value.match(/^\s*[^=\s]+=\S(([^=,])+((?<=\S),(?=\S))?)+([^\s=,])+$/)
|
raise ArgumentError, "Properties doesn't match" unless value.match(/^[^=\s]+=[^=]+$/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ describe 'basic cinder' do
|
|||||||
include openstack_integration::memcached
|
include openstack_integration::memcached
|
||||||
include openstack_integration::keystone
|
include openstack_integration::keystone
|
||||||
include openstack_integration::cinder
|
include openstack_integration::cinder
|
||||||
|
|
||||||
|
cinder_type { 'testvolumetype' :
|
||||||
|
properties => ['k=v', 'key1=val1', 'key2=<is> True']
|
||||||
|
}
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user