Skip to content

Commit c6c203f

Browse files
committed
Remove line match validation
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 puppetlabs@a06c0d8 and ask https://ask.puppetlabs.com/question/14366/file_line-resource-match-problems/ for further examples of confusion.
1 parent 1493b21 commit c6c203f

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This release improves functionality of the member function and adds improved fut
1010
####Bugfixes
1111
- Fix range() to work with numeric ranges with the future parser
1212
- Accurately express SLES support in metadata.json (was missing 10SP4 and 12)
13+
- Don't require `line` to match the `match` parameter
1314

1415
##2014-11-10 - Supported Release 4.4.0
1516
###Summary

lib/puppet/type/file_line.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,5 @@
7171
unless self[:line] and self[:path]
7272
raise(Puppet::Error, "Both line and path are required attributes")
7373
end
74-
75-
if (self[:match])
76-
unless Regexp.new(self[:match]).match(self[:line])
77-
raise(Puppet::Error, "When providing a 'match' parameter, the value must be a regex that matches against the value of your 'line' parameter")
78-
end
79-
end
80-
8174
end
8275
end

spec/unit/puppet/type/file_line_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
file_line[:match] = '^foo.*$'
1616
expect(file_line[:match]).to eq('^foo.*$')
1717
end
18-
it 'should not accept a match regex that does not match the specified line' do
18+
it 'should accept a match regex that does not match the specified line' do
1919
expect {
2020
Puppet::Type.type(:file_line).new(
2121
:name => 'foo',
2222
:path => '/my/path',
2323
:line => 'foo=bar',
2424
:match => '^bar=blah$'
25-
)}.to raise_error(Puppet::Error, /the value must be a regex that matches/)
25+
)}.not_to raise_error
2626
end
2727
it 'should accept a match regex that does match the specified line' do
2828
expect {

0 commit comments

Comments
 (0)