You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
https://tickets.puppetlabs.com/browse/MODULES-5003 gave rise to
#788 and
#794 which caused
different behavior based on whether the line value was matched by the
match regex or not.
This resolves the behavior by adding a new parameter to control whether
multiple matches should universally be replaced by the line value, or
whether matches should be left alone when the line exists elsewhere in
the file.
This problem only affects modifying multiple lines when the line already
exists.
I also revised many of the tests and some of the documentation where
wrong or ambiguous.
Copy file name to clipboardExpand all lines: README.md
+11-3Lines changed: 11 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -219,7 +219,7 @@ Values: String.
219
219
220
220
##### `match`
221
221
222
-
Specifies a regular expression to compare against existing lines in the file; if a match is found, it is replaced rather than adding a new line. A regex comparison is performed against the line value, and if it does not match, an exception is raised.
222
+
Specifies a regular expression to compare against existing lines in the file; if a match is found, it is replaced rather than adding a new line.
223
223
224
224
Values: String containing a regex.
225
225
@@ -236,7 +236,7 @@ Default value: `false`.
236
236
237
237
##### `multiple`
238
238
239
-
Specifies whether `match` and `after` can change multiple lines. If set to `false`, an exception is raised if more than one line matches.
239
+
Specifies whether `match` and `after` can change multiple lines. If set to `false`, allows file\_line to replace only one line and raises an error if more than one will be replaced. If set to `true`, allows file\_line to replace one or more lines.
240
240
241
241
Values: `true`, `false`.
242
242
@@ -261,12 +261,20 @@ Value: String specifying an absolute path to the file.
261
261
262
262
##### `replace`
263
263
264
-
Specifies whether the resource overwrites an existing line that matches the `match` parameter. If set to `false` and a line is found matching the `match` parameter, the line is not placed in the file.
264
+
Specifies whether the resource overwrites an existing line that matches the `match` parameter when `line` does not otherwise exist.
265
+
266
+
If set to `false` and a line is found matching the `match` parameter, the line is not placed in the file.
265
267
266
268
Boolean.
267
269
268
270
Default value: `true`.
269
271
272
+
##### `replace_all_matches_not_matching_line`
273
+
274
+
Replace all lines matched by `match` parameter, even if `line` already exists in the file.
# there are matches, and replace_all_matches_not_matching_line is true so we want to replace all matches that don't match line... at this point we only get matches if they DONT match line because count_matches takes this into account and will only tell us if it found matches OTHER than line
44
+
found=false# unknown lies if the match matches line, otherwise lies
desc'Configures the behavior of replacing all lines in a file which match the `match` parameter regular expression, regardless of whether the specified line is already present in the file.'
156
+
157
+
newvalues(true,false)
158
+
defaulttofalse
159
+
end
160
+
154
161
newparam(:encoding)do
155
162
desc'For files that are not UTF-8 encoded, specify encoding such as iso-8859-1'
0 commit comments