From 93315bb1b79ea51f111703d4ecbbe4e29af923b7 Mon Sep 17 00:00:00 2001 From: Florian Haas Date: Wed, 15 Jul 2015 01:07:39 +0200 Subject: [PATCH] Allow 1-element arrays for primitives in cs_group Having only one primitive in a group is a perfectly valid use case. For example, one might have constraints related to an arbitrary number of primitives created with create_resources, and the simplest way of doing that is to place them all of them in a group, and have the constraint point to that. Disallowing the possibility of ending up with just one primitive in the group does not make much sense. Update the check to allow 1-element arrays. Also, remove a misleading comment that also looks like it was copied from some other code that talked about colocations, not groups. Fixes issue puppet-community/puppet-corosync#152. --- lib/puppet/type/cs_group.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/puppet/type/cs_group.rb b/lib/puppet/type/cs_group.rb index fc5d4263..52683b4d 100644 --- a/lib/puppet/type/cs_group.rb +++ b/lib/puppet/type/cs_group.rb @@ -23,11 +23,10 @@ module Puppet # Have to redefine should= here so we can sort the array that is given to # us by the manifest. While were checking on the class of our value we - # are going to go ahead and do some validation too. The way Corosync - # colocation works we need to only accept two value arrays. + # are going to go ahead and do some validation too. def should=(value) super - raise Puppet::Error, "Puppet::Type::Cs_Group: primitives property must be at least a 2-element array." unless value.is_a? Array and value.length > 1 + raise Puppet::Error, "Puppet::Type::Cs_Group: primitives property must be at least a 1-element array." unless value.is_a? Array and value.length >= 1 @should end end