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
This commit is contained in:
Simeon Gourlin 2021-01-13 18:46:41 +01:00 committed by Takashi Kajinami
parent b153bb414c
commit 19fa1ca37f
1 changed files with 1 additions and 1 deletions

View File

@ -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