Skip to content

Commit 4fff979

Browse files
Miracle05allburov
authored andcommitted
Add multiarch images to Docker rules
1 parent 65a9c2f commit 4fff979

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

artifactory_cleanup/rules/docker.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class RuleForDocker(Rule):
1919
"""
2020

2121
MANIFEST_FILENAME = "manifest.json"
22+
FAT_MANIFEST_FILENAME = "list.manifest.json"
2223

2324
def get_docker_images_list(self, docker_repo):
2425
url = f"/api/docker/{docker_repo}/v2/_catalog"
@@ -37,13 +38,13 @@ def get_docker_tags_list(self, docker_repo, docker_image):
3738

3839
def _manifest_to_docker_images(self, artifacts: ArtifactsList):
3940
"""
40-
Convert manifest.json path to folder path
41-
Docker rules get path to MANIFEST_FILENAME file,
41+
Convert manifest.json or list.manifest.json path to folder path
42+
Docker rules get path to MANIFEST_FILENAME file or FAT_MANIFEST_FILENAME for multiarch images,
4243
in order to remove the whole image we have to "up" one level
4344
"""
4445
for artifact in artifacts:
4546
# already done it or it's just a folder
46-
if "name" not in artifact or artifact["name"] != self.MANIFEST_FILENAME:
47+
if "name" not in artifact or artifact["name"] not in [self.MANIFEST_FILENAME, self.FAT_MANIFEST_FILENAME]:
4748
continue
4849

4950
artifact["path"], docker_tag = artifact["path"].rsplit("/", 1)
@@ -76,7 +77,7 @@ def _collect_docker_size(self, artifacts):
7677
artifact["size"] = images_sizes.get(image_key, 0)
7778

7879
def aql_add_filter(self, filters):
79-
filters.append({"name": {"$match": self.MANIFEST_FILENAME}})
80+
filters.append({'$or': [{'name': {'$match': self.MANIFEST_FILENAME}}, {'name': {'$match': self.FAT_MANIFEST_FILENAME}}]})
8081
return filters
8182

8283
def filter(self, artifacts):

0 commit comments

Comments
 (0)