Skip to content

Commit 9162935

Browse files
jbtrystramjlebon
authored andcommitted
src/cmd-coreos-prune: update to new schema
1 parent b07c808 commit 9162935

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/cmd-coreos-prune

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Build = collections.namedtuple("Build", ["id", "images", "arch", "meta_json"])
5555
# set metadata caching to 5m
5656
CACHE_MAX_AGE_METADATA = 60 * 5
5757
# These lists are up to date as of schema hash
58-
# 58da31f35c1405d5a752a297d0ee012f577720f810113d38cdabca102ec7edd8. If changing
58+
# 1711aa3ce997c644130139e1318d2683e2a5f11538e2b0528771a8658d62ee64. If changing
5959
# this hash, ensure that the list of SUPPORTED and UNSUPPORTED artifacts below
6060
# is up to date.
6161
SUPPORTED = ["amis", "gcp"]
@@ -185,12 +185,13 @@ def main():
185185
print(f"\t\t\tRelease {build_id} is a barrier release. Skipping container prune.")
186186
continue
187187
# Retrieve container tags excluding the stream name since it updates with each release.
188-
container_tags, container_repo = get_container_tags(meta_json, exclude=[stream])
189-
if container_tags:
190-
for tag in container_tags:
191-
prune_container(tag, args.dry_run, container_repo, args.registry_auth_file)
192-
else:
193-
print(f"\t\t\tNo container tags to prune for build {build_id}.")
188+
containers = get_container_tags(meta_json, exclude=[stream])
189+
for (container_repo, container_tags) in containers:
190+
if container_tags:
191+
for tag in container_tags:
192+
prune_container(tag, args.dry_run, container_repo, args.registry_auth_file)
193+
else:
194+
print(f"\t\t\tNo container tags to prune for build {build_id}.")
194195
actions_completed.append(action) # Append action to completed list
195196
# Only add policy-cleanup for the build in builds.json if any
196197
# of the cleanup actions were completed.
@@ -450,9 +451,14 @@ def get_container_tags(meta_json, exclude):
450451
if base_oscontainer:
451452
tags = base_oscontainer.get("tags", [])
452453
filtered_tags = [tag for tag in tags if tag not in exclude]
453-
container_repo = base_oscontainer.get("image", "")
454-
return filtered_tags, container_repo
455-
return [], ""
454+
container_repos = [(base_oscontainer.get("image", ""), filtered_tags)]
455+
additional_images = base_oscontainer.get("additional-images", [])
456+
for image in additional_images:
457+
tags = image.get("tags", [])
458+
filtered_tags = [tag for tag in tags if tag not in exclude]
459+
container_repos.append((image.get("image", ""), filtered_tags))
460+
return container_repos
461+
return []
456462

457463

458464
def prune_container(tag, dry_run, container_repo, registry_auth_file):

0 commit comments

Comments
 (0)