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
This commit is contained in:
Dan 2014-07-02 10:56:39 -07:00
parent 4fce711b3e
commit b7a15fc68c
2 changed files with 12 additions and 1 deletions

View File

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

View File

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