fetch-containers-fixes #769

Merged
dboreham merged 3 commits from dboreham/fetch-containers-fixes into main 2024-02-27 15:53:07 +00:00
Showing only changes of commit 1663881f94 - Show all commits

View File

@ -110,8 +110,11 @@ def _filter_for_platform(container: str,
def _get_latest_image(container: str, registry_info: RegistryInfo):
all_tags = _get_tags_for_container(container, registry_info)
tags_for_platform = _filter_for_platform(container, registry_info, all_tags)
latest_tag = _find_latest(tags_for_platform)
return f"{container}:{latest_tag}"
if len(tags_for_platform) > 0:
latest_tag = _find_latest(tags_for_platform)
return f"{container}:{latest_tag}"
else:
return None
def _fetch_image(tag: str, registry_info: RegistryInfo):
@ -148,6 +151,7 @@ def command(ctx, include, exclude, force_local_overwrite, image_registry, regist
# Generate list of target containers
stack = ctx.obj.stack
containers_in_scope = get_containers_in_scope(stack)
all_containers_found = True
for container in containers_in_scope:
local_tag = _local_tag_for(container)
if include_exclude_check(container, include, exclude):
@ -156,6 +160,10 @@ def command(ctx, include, exclude, force_local_overwrite, image_registry, regist
# For each container, attempt to find the latest of a set of
# images with the correct name and platform in the specified registry
image_to_fetch = _get_latest_image(container, registry_info)
if not image_to_fetch:
print(f"Warning: no image found to fetch for container {container}")
all_containers_found = False
continue
if opts.o.debug:
print(f"Fetching: {image_to_fetch}")
_fetch_image(image_to_fetch, registry_info)
@ -173,8 +181,11 @@ def command(ctx, include, exclude, force_local_overwrite, image_registry, regist
if not opts.o.quiet:
print(f"Skipping local tagging for this image: {container} because that would "
"overwrite an existing :local tagged image, use --force-local-overwrite to do so.")
continue
# Tag the fetched image with the :local tag
_add_local_tag(image_to_fetch, image_registry, local_tag)
else:
if opts.o.verbose:
print(f"Excluding: {container}")
if not all_containers_found:
print("Warning: couldn't find usable images for one or more containers, this stack will not deploy")