From b7a15fc68c1c8e1e463c7d9e60a80f8c805fc11a Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 2 Jul 2014 10:56:39 -0700 Subject: [PATCH] Allow non-word characters in vs_bridge external_ids Currently, the type enforces a regex for vs_bridge external id values that is way to strict. Essentially that entries are \w*=\w*. Bridge external ids commonly include non-word characters , like '-' (ie: br-ex). This patch updates the parameter checking to allow any non-whitespace characters. Change-Id: I26d47b9744e6e294b0b1bc09cd6268f5587f8bd8 --- lib/puppet/type/vs_bridge.rb | 2 +- spec/unit/puppet/lib/type/vs_bridge_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 spec/unit/puppet/lib/type/vs_bridge_spec.rb diff --git a/lib/puppet/type/vs_bridge.rb b/lib/puppet/type/vs_bridge.rb index c5a5e7ca..cbcce902 100644 --- a/lib/puppet/type/vs_bridge.rb +++ b/lib/puppet/type/vs_bridge.rb @@ -22,7 +22,7 @@ Puppet::Type.newtype(:vs_bridge) do if !value.is_a?(String) raise ArgumentError, "Invalid external_ids #{value}. Requires a String, not a #{value.class}" end - if value !~ /^(?>[a-zA-Z]\w*=\w*){1}(?>[,][a-zA-Z]\w*=\w*)*$/ + if value !~ /^(?>[a-zA-Z]\S*=\S*){1}(?>[,][a-zA-Z]\S*=\S*)*$/ raise ArgumentError, "Invalid external_ids #{value}. Must a list of key1=value2,key2=value2" end end diff --git a/spec/unit/puppet/lib/type/vs_bridge_spec.rb b/spec/unit/puppet/lib/type/vs_bridge_spec.rb new file mode 100644 index 00000000..4b88b317 --- /dev/null +++ b/spec/unit/puppet/lib/type/vs_bridge_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe Puppet::Type.type(:vs_bridge) do + + it "should support present as a value for ensure" do + expect do + described_class.new(:name => 'foo', :ensure => :present, :external_ids => 'foo=br-ex,blah-id=bar)') + end.to_not raise_error + end + +end