devopshq / artifactory-cleanup

Extended cleanup tool for JFrog Artifactory
MIT License
125 stars 66 forks source link

KeepLatestNFilesInFolder not working properly when more than one repository is selected #69

Open afolgado opened 2 years ago

afolgado commented 2 years ago

Hi all,

When filtering by RepoByMask instead of Repo, multiple repositories could be selected.

In this case, the rule KeepLatestNFilesInFolder won't work properly because doesn't use the repository name for grouping the artifacts: https://github.com/devopshq/artifactory-cleanup/blob/master/artifactory_cleanup/rules/keep.py#L134

My proposal is to modify it to something like this:

        for artifact in result_artifact:
            path = '{repo}/{path}'.format(**artifact)
            artifacts_by_path[path].append(artifact)

It would be nice to add the repo name to this print too: https://github.com/devopshq/artifactory-cleanup/blob/master/artifactory_cleanup/rules/keep.py#L146

Thanks for this awesome tool!

allburov commented 2 years ago

@afolgado hi, thank you for providing the feedback! Yep, it looks like a bug.

Feel free to create a PR for suggested changes and the solution for the bug!