Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-3286) Add file::delete() function #3287

Merged
merged 1 commit into from
Apr 16, 2024
Merged

Conversation

jay7x
Copy link
Contributor

@jay7x jay7x commented Mar 30, 2024

Closes #3286

!feature

  • Add file::delete() function Delete a file on localhost using ruby's File.delete. This will only delete files on the machine you run Bolt on.

@jay7x jay7x requested a review from a team as a code owner March 30, 2024 16:54
@jay7x
Copy link
Contributor Author

jay7x commented Mar 30, 2024

One more note wrt this.. I guess it'd be nice to add another function signature like file::delete(String $file, Boolean $catch_errors = false). This is functional equivalent of rm -f, which is quite useful if one doesn't really want to check if the file exists before deleting it.

Closes puppetlabs#3286

!feature

* **Add `file::delete()` function**
  Delete a file on localhost using ruby's `File.delete`. This will only
  delete files on the machine you run Bolt on.
Puppet.lookup(:bolt_executor) {}&.report_function_call(self.class.name)

File.delete(filename)
nil
Copy link
Contributor

Choose a reason for hiding this comment

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

why nil here, do you always want to return nil and not the result of delete()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was copied from file::write() actually.. In our case delete() will always return 1 (number of filenames passed as the arguments). Not sure how useful it is.

@donoghuc
Copy link
Member

donoghuc commented Apr 1, 2024

This looks good. I'll need to look in to the integration tests and docs actions. I'll do that in a separate PR.

@donoghuc donoghuc merged commit f758ac2 into puppetlabs:main Apr 16, 2024
41 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add file::delete() function
3 participants