From 0f500ef7da98b9579f801132f70e030e8d56922f Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 25 Dec 2023 12:54:13 +0900 Subject: [PATCH] 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 --- lib/puppet/type/cinder_type.rb | 4 ++-- spec/acceptance/10_basic_cinder_spec.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/puppet/type/cinder_type.rb b/lib/puppet/type/cinder_type.rb index cd203b79..616509d1 100644 --- a/lib/puppet/type/cinder_type.rb +++ b/lib/puppet/type/cinder_type.rb @@ -9,14 +9,14 @@ Puppet::Type.newtype(:cinder_type) do end newproperty(:properties, :array_matching => :all) do - desc 'The properties of the cinder type. Should be an array, all items should match pattern ' + desc 'The properties of the cinder type. Should be an array, all items should match pattern ' defaultto [] def insync?(is) return false unless is.is_a? Array is.sort == should.sort end 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 diff --git a/spec/acceptance/10_basic_cinder_spec.rb b/spec/acceptance/10_basic_cinder_spec.rb index 4694ffc0..aacc4e5b 100644 --- a/spec/acceptance/10_basic_cinder_spec.rb +++ b/spec/acceptance/10_basic_cinder_spec.rb @@ -14,6 +14,10 @@ describe 'basic cinder' do include openstack_integration::memcached include openstack_integration::keystone include openstack_integration::cinder + + cinder_type { 'testvolumetype' : + properties => ['k=v', 'key1=val1', 'key2= True'] + } EOS