diff --git a/artifactory_cleanup/rules/docker.py b/artifactory_cleanup/rules/docker.py index 14756ad..d0cadf8 100644 --- a/artifactory_cleanup/rules/docker.py +++ b/artifactory_cleanup/rules/docker.py @@ -229,7 +229,10 @@ def filter(self, artifacts): def _groupby(artifact): """Group by major/minor/patch version""" - return self.get_version(artifact)[: self.number_of_digits_in_version] + return ( + artifact["path"], + self.get_version(artifact)[: self.number_of_digits_in_version], + ) # Group artifacts by major/minor or patch grouped = pydash.group_by(artifacts, iteratee=_groupby) diff --git a/tests/test_rules_docker.py b/tests/test_rules_docker.py index b8315a7..23e53be 100644 --- a/tests/test_rules_docker.py +++ b/tests/test_rules_docker.py @@ -48,6 +48,21 @@ def test_filter(self): "path": "foobar/2.1.1", "name": "manifest.json", }, + { + "properties": {"docker.manifest": "0.1.86"}, + "path": "baz/0.1.86", + "name": "manifest.json", + }, + { + "properties": {"docker.manifest": "0.1.87"}, + "path": "baz/0.1.87", + "name": "manifest.json", + }, + { + "properties": {"docker.manifest": "0.1.83"}, + "path": "baz/0.1.83", + "name": "manifest.json", + }, ] artifacts = ArtifactsList.from_response(data) policy = CleanupPolicy( @@ -60,6 +75,12 @@ def test_filter(self): ), ) assert policy.filter(artifacts) == [ + { + "name": "0.1.83", + "path": "baz", + "properties": {"docker.manifest": "0.1.83"}, + "stats": {}, + }, { "name": "0.1.99", "path": "foobar",