Skip to content

Commit

Permalink
Allow non-word characters in vs_bridge external_ids
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bodepd committed Jul 2, 2014
1 parent 4fce711 commit b7a15fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet/type/vs_bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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
Expand Down
11 changes: 11 additions & 0 deletions spec/unit/puppet/lib/type/vs_bridge_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b7a15fc

Please sign in to comment.