From 19fa1ca37f45def065a2e07fe5fe426370c29630 Mon Sep 17 00:00:00 2001 From: Simeon Gourlin Date: Wed, 13 Jan 2021 18:46:41 +0100 Subject: [PATCH] Allow single alias in swift_storage_policy provider Regex validation for aliases in swift_storage_policy provider does not allow single alias value, like for exemple: swift::storage::policy { '1': policy_name => '3-Replica-Policy', policy_aliases => 'green', This fixes the accepted pattenr to allow single-value for policy_aliases parameter. Also, the whole expression is updated to more strictly validate the pattern, especially when more than 2 aliases are given. Change-Id: I62c86097c717d2a74c100386cf20e07976571805 --- lib/puppet/type/swift_storage_policy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/type/swift_storage_policy.rb b/lib/puppet/type/swift_storage_policy.rb index cd4bea52..cebf88ec 100644 --- a/lib/puppet/type/swift_storage_policy.rb +++ b/lib/puppet/type/swift_storage_policy.rb @@ -25,7 +25,7 @@ Puppet::Type.newtype(:swift_storage_policy) do newproperty(:aliases) do desc 'Storage policy aliases' validate do |value| - value_match = /([a-zA-Z\d\-]+,\s+)+[a-zA-Z\d\-]+/.match(value) + value_match = /^(\s*[a-zA-Z\d\-]+\s*)(,\s*[a-zA-Z\d\-]+\s*)*$/.match(value) next unless value_match.nil? || !value_match[0].eql?(value) fail('aliases must contain only letters, digits or a dash in a comma separated string') end