From e709ba7271ede8c58155cdbc14f15da87519c04f Mon Sep 17 00:00:00 2001 From: Edmund Rhudy Date: Fri, 26 Dec 2014 18:30:12 -0500 Subject: [PATCH 1/2] my first set of changes for the user tag idempotence issue --- lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb b/lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb index 8a8e9f41c..7f7f81eb4 100644 --- a/lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb +++ b/lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb @@ -111,6 +111,12 @@ def get_user_tags match = rabbitmqctl('-q', 'list_users').split(/\n/).collect do |line| line.match(/^#{Regexp.escape(resource[:name])}\s+\[(.*?)\]/) end.compact.first - Set.new(match[1].split(/, /)) if match + if match + # RabbitMQ 3.3.5 and up separate tags with ', ' + # 3.3.4 just separates with space + # this splits by space and then strips word-final commas + # (if you're ending a valid tag name with a comma, why) + Set.new(match[1].split(' ')).map{|x| x.gsub(/,$/, '')} + end end end From 247b6e049d1751ab58f122e037162aeb98699542 Mon Sep 17 00:00:00 2001 From: Edmund Rhudy Date: Fri, 26 Dec 2014 18:38:28 -0500 Subject: [PATCH 2/2] - moved the parenthesis before map to the end so that the map works on the array and then the set is created from that, instead of map coercing the set to an array, which breaks things that call Set#add - switching back to the previous more concise expression form --- lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb b/lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb index 7f7f81eb4..f1b914bb9 100644 --- a/lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb +++ b/lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb @@ -111,12 +111,6 @@ def get_user_tags match = rabbitmqctl('-q', 'list_users').split(/\n/).collect do |line| line.match(/^#{Regexp.escape(resource[:name])}\s+\[(.*?)\]/) end.compact.first - if match - # RabbitMQ 3.3.5 and up separate tags with ', ' - # 3.3.4 just separates with space - # this splits by space and then strips word-final commas - # (if you're ending a valid tag name with a comma, why) - Set.new(match[1].split(' ')).map{|x| x.gsub(/,$/, '')} - end + Set.new(match[1].split(' ').map{|x| x.gsub(/,$/, '')}) if match end end