Skip to content

[#puppethack] Adding replace attribute to file_line#494

Merged
bmjen merged 1 commit intopuppetlabs:masterfrom
CENGN:fix/master/file_line_replace
Jul 30, 2015
Merged

[#puppethack] Adding replace attribute to file_line#494
bmjen merged 1 commit intopuppetlabs:masterfrom
CENGN:fix/master/file_line_replace

Conversation

@rmaika
Copy link
Copy Markdown
Contributor

@rmaika rmaika commented Jul 30, 2015

Adding tests and minor changes to make @WhatsARanjit's PR #451 work.

The patch adds the optional replace attribute to file_line. It defaults to true, which maintains current behavior. Setting the attribute to false will allow users to ensure that a line matching the match attribute exists without overwriting it with the contents of line if the matching lines exists

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If match_regex returns nil... this will result in a NoMethodError

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second look, given this code path, you should be able to assume that match_regex is not nil.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the handle_create_with_match function will not be used to write the line unless resource[:match] is not nil. So the creation of the regex that match_regex returns should not fail in this block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it also isn't a new behavior with this patch. The line only changes because where the Regexp is created is moved and renamed from regex to match_regex

bmjen added a commit that referenced this pull request Jul 30, 2015
[#puppethack] Adding replace attribute to file_line
@bmjen bmjen merged commit ebf7348 into puppetlabs:master Jul 30, 2015
@bmjen bmjen mentioned this pull request Jul 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants