]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Remove line match validation
authorHunter Haugen <hunter@puppetlabs.com>
Tue, 16 Dec 2014 19:48:46 +0000 (11:48 -0800)
committerHunter Haugen <hunter@puppetlabs.com>
Tue, 16 Dec 2014 23:05:31 +0000 (15:05 -0800)
The `match` attribute was validated to match `line`, except that in many
cases (even the example given in the docs) a user would want to match a
line entirely different from the new line.

See comments on the original commit
https://github.com/puppetlabs/puppetlabs-stdlib/commit/a06c0d8115892a74666676b50d4282df9850a119
and ask
https://ask.puppetlabs.com/question/14366/file_line-resource-match-problems/
for further examples of confusion.

CHANGELOG.md
lib/puppet/type/file_line.rb
spec/unit/puppet/type/file_line_spec.rb

index 8da04af44bbab746fa70b1c9cc19de365c336461..c66734ebb4aa58c26f93560dd7dc9c9b4ed10fb9 100644 (file)
@@ -10,6 +10,7 @@ This release improves functionality of the member function and adds improved fut
 ####Bugfixes
 - Fix range() to work with numeric ranges with the future parser
 - Accurately express SLES support in metadata.json (was missing 10SP4 and 12)
+- Don't require `line` to match the `match` parameter
 
 ##2014-11-10 - Supported Release 4.4.0
 ###Summary
index 9dbe43cea4e93ae4e4a452dd0805564533f5205d..df263e6a7406f0fc91dc0bcfc4f1374d37885afe 100644 (file)
@@ -71,12 +71,5 @@ Puppet::Type.newtype(:file_line) do
     unless self[:line] and self[:path]
       raise(Puppet::Error, "Both line and path are required attributes")
     end
-
-    if (self[:match])
-      unless Regexp.new(self[:match]).match(self[:line])
-        raise(Puppet::Error, "When providing a 'match' parameter, the value must be a regex that matches against the value of your 'line' parameter")
-      end
-    end
-
   end
 end
index 9ef49efbff232b9d28102b3bb0fcca663452cfda..410d0bfec51c08237c8f1434a86836ea951f367b 100755 (executable)
@@ -15,14 +15,14 @@ describe Puppet::Type.type(:file_line) do
     file_line[:match] = '^foo.*$'
     expect(file_line[:match]).to eq('^foo.*$')
   end
-  it 'should not accept a match regex that does not match the specified line' do
+  it 'should accept a match regex that does not match the specified line' do
     expect {
       Puppet::Type.type(:file_line).new(
           :name   => 'foo',
           :path   => '/my/path',
           :line   => 'foo=bar',
           :match  => '^bar=blah$'
-    )}.to raise_error(Puppet::Error, /the value must be a regex that matches/)
+    )}.not_to raise_error
   end
   it 'should accept a match regex that does match the specified line' do
     expect {