diff --git a/artifactory_cleanup/rules/docker.py b/artifactory_cleanup/rules/docker.py index 40c54c0..2e24407 100644 --- a/artifactory_cleanup/rules/docker.py +++ b/artifactory_cleanup/rules/docker.py @@ -45,9 +45,8 @@ def _manifest_to_docker_images(self, artifacts: ArtifactsList): # already done it or it's just a folder if "name" not in artifact or artifact["name"] != self.MANIFEST_FILENAME: continue - - artifact["path"], docker_tag = artifact["path"].rsplit("/", 1) - artifact["name"] = docker_tag + artifact["path"] = artifact["properties"]["docker.repoName"] + artifact["name"] = artifact["properties"]["docker.manifest"] # We're going to collect docker size later if "size" in artifact: del artifact["size"] diff --git a/tests/test_rules_docker.py b/tests/test_rules_docker.py index 0bf1666..63de7f8 100644 --- a/tests/test_rules_docker.py +++ b/tests/test_rules_docker.py @@ -14,67 +14,67 @@ def test_filter(self): data = [ { - "properties": {"docker.manifest": "0.1.100"}, + "properties": {"docker.manifest": "0.1.100", "docker.repoName": "foobar"}, "path": "foobar/0.1.100", "name": "manifest.json", }, { - "properties": {"docker.manifest": "0.1.200"}, + "properties": {"docker.manifest": "0.1.200", "docker.repoName": "foobar"}, "path": "foobar/0.1.200", "name": "manifest.json", }, { - "properties": {"docker.manifest": "0.1.99"}, + "properties": {"docker.manifest": "0.1.99", "docker.repoName": "foobar"}, "path": "foobar/0.1.99", "name": "manifest.json", }, { - "properties": {"docker.manifest": "1.1.1"}, + "properties": {"docker.manifest": "1.1.1", "docker.repoName": "foobar"}, "path": "foobar/1.1.1", "name": "manifest.json", }, { - "properties": {"docker.manifest": "1.2.1"}, + "properties": {"docker.manifest": "1.2.1", "docker.repoName": "foobar"}, "path": "foobar/1.2.1", "name": "manifest.json", }, { - "properties": {"docker.manifest": "1.3.1"}, + "properties": {"docker.manifest": "1.3.1", "docker.repoName": "foobar"}, "path": "foobar/1.3.1", "name": "manifest.json", }, { - "properties": {"docker.manifest": "2.1.1"}, + "properties": {"docker.manifest": "2.1.1", "docker.repoName": "foobar"}, "path": "foobar/2.1.1", "name": "manifest.json", }, { - "properties": {"docker.manifest": "0.1.86"}, + "properties": {"docker.manifest": "0.1.86", "docker.repoName": "baz"}, "path": "baz/0.1.86", "name": "manifest.json", }, { - "properties": {"docker.manifest": "0.1.87"}, + "properties": {"docker.manifest": "0.1.87", "docker.repoName": "baz"}, "path": "baz/0.1.87", "name": "manifest.json", }, { - "properties": {"docker.manifest": "0.1.83"}, + "properties": {"docker.manifest": "0.1.83", "docker.repoName": "baz"}, "path": "baz/0.1.83", "name": "manifest.json", }, { - "properties": {"docker.manifest": "v0.1.100"}, + "properties": {"docker.manifest": "v0.1.100", "docker.repoName": "qux"}, "path": "qux/v0.1.100", "name": "manifest.json", }, { - "properties": {"docker.manifest": "v0.1.200"}, + "properties": {"docker.manifest": "v0.1.200", "docker.repoName": "qux"}, "path": "qux/v0.1.200", "name": "manifest.json", }, { - "properties": {"docker.manifest": "v0.1.99"}, + "properties": {"docker.manifest": "v0.1.99", "docker.repoName": "qux"}, "path": "qux/v0.1.99", "name": "manifest.json", }, @@ -94,25 +94,25 @@ def test_filter(self): { "name": "0.1.83", "path": "baz", - "properties": {"docker.manifest": "0.1.83"}, + "properties": {"docker.manifest": "0.1.83", "docker.repoName": "baz"}, "stats": {}, }, { "name": "0.1.99", "path": "foobar", - "properties": {"docker.manifest": "0.1.99"}, + "properties": {"docker.manifest": "0.1.99", "docker.repoName": "foobar"}, "stats": {}, }, { "name": "1.1.1", "path": "foobar", - "properties": {"docker.manifest": "1.1.1"}, + "properties": {"docker.manifest": "1.1.1", "docker.repoName": "foobar"}, "stats": {}, }, { "name" : "v0.1.99", "path": "qux", - "properties": {"docker.manifest": "v0.1.99"}, + "properties": {"docker.manifest": "v0.1.99", "docker.repoName": "qux"}, "stats": {}, }, ]