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

feat: add support for glob pattern to the prautomation->deletes->files #586

Conversation

floreks
Copy link
Member

@floreks floreks commented Dec 18, 2024

Summary

Ref: PROD-3014

Test Plan

Locally with some basic glob patterns and direct paths, i.e.:

  • /dir/**/*.yaml
  • /path/file.yaml

Checklist

  • If required, I have updated the Plural documentation accordingly.
  • I have added tests to cover my changes.
  • I have added a meaningful title and summary to convey the impact of this PR to a user.
  • I have added relevant labels to this PR to help with categorization for release notes.

Copy link

linear bot commented Dec 18, 2024

@@ -40,3 +40,18 @@ func replaceTo(from, to string, rep func(data []byte) ([]byte, error)) error {
func replaceInPlace(path string, rep func(data []byte) ([]byte, error)) error {
return replaceTo(path, path, rep)
}

func removeMatches(glob string) error {
matches, err := filepath.Glob(glob)
Copy link
Member

Choose a reason for hiding this comment

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

does this still work for non-glob patterns?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, if full filepath is provided, filepath.Glob checks for file existence and returns it as part of matches array if it exists, otherwise it returns null and nothing happens.

Copy link
Member

Choose a reason for hiding this comment

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

cool that works then

@floreks floreks self-assigned this Dec 18, 2024
@floreks floreks added the enhancement New feature or request label Dec 18, 2024
@michaeljguarino michaeljguarino merged commit 5883324 into main Dec 18, 2024
10 of 11 checks passed
@michaeljguarino michaeljguarino deleted the sebastian/prod-3014-support-file-globs-in-deletes-for-plural-template-pr branch December 18, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants