From 694de61527f497bc6ded03d12cd35d83d35b1b0a Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Thu, 28 Jul 2016 14:33:14 +1000 Subject: [PATCH 1/2] Add definition validation and munge for ha-sync-batch-size With the release of RabbitMQ 3.6 there is an option to set the ha-sync-batch-size. This option takes an integer >0. This commit adds a validation statement to check the supplied value is an integer and then converts the string input into an integer. --- lib/puppet/type/rabbitmq_policy.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/puppet/type/rabbitmq_policy.rb b/lib/puppet/type/rabbitmq_policy.rb index 3aa713d13..337bc3f78 100644 --- a/lib/puppet/type/rabbitmq_policy.rb +++ b/lib/puppet/type/rabbitmq_policy.rb @@ -105,6 +105,12 @@ def validate_definition(definition) raise ArgumentError, "Invalid shards-per-node value '#{shards_per_node_val}'" end end + if definition.key? 'ha-sync-batch-size' + ha_sync_batch_size_val = definition['ha-sync-batch-size'] + unless ha_sync_batch_size_val.to_i.tos == ha_sync_batch_size_val + raise ArgumentErro, "Invalid ha-sync-batch-size value '#{ha_sync_batch_size_val}'" + end + end end def munge_definition(definition) @@ -123,6 +129,9 @@ def munge_definition(definition) if definition.key? 'shards-per-node' definition['shards-per-node'] = definition['shards-per-node'].to_i end + if definition.key? 'ha-sync-batch-size' + definition['ha-sync-batch-size'] = definition['ha-sync-batch-size'].to_i + end definition end end From 8a488730e98fbd47b475b1013cffb64aa8c8e739 Mon Sep 17 00:00:00 2001 From: combatdud3 Date: Fri, 29 Jul 2016 11:00:38 +1000 Subject: [PATCH 2/2] Fix syntax error Add missing _ that was causing failures. --- lib/puppet/type/rabbitmq_policy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/type/rabbitmq_policy.rb b/lib/puppet/type/rabbitmq_policy.rb index 337bc3f78..2f0fec6ee 100644 --- a/lib/puppet/type/rabbitmq_policy.rb +++ b/lib/puppet/type/rabbitmq_policy.rb @@ -107,7 +107,7 @@ def validate_definition(definition) end if definition.key? 'ha-sync-batch-size' ha_sync_batch_size_val = definition['ha-sync-batch-size'] - unless ha_sync_batch_size_val.to_i.tos == ha_sync_batch_size_val + unless ha_sync_batch_size_val.to_i.to_s == ha_sync_batch_size_val raise ArgumentErro, "Invalid ha-sync-batch-size value '#{ha_sync_batch_size_val}'" end end