From ddaf6a4d4cfbc495301fb6deac0af7f81f85cd51 Mon Sep 17 00:00:00 2001 From: Marco Salathe Date: Sat, 24 May 2025 15:10:21 -0700 Subject: [PATCH] fails if image not on server --- dockrice/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dockrice/utils.py b/dockrice/utils.py index 23d0c23..cb37312 100644 --- a/dockrice/utils.py +++ b/dockrice/utils.py @@ -5,6 +5,19 @@ from typing import Union +def image_is_not_on_server(e): + """Checks an docker.error.APIError for if it means + the image can not be found.""" + + message = e.response.json()["message"].lower() + return ( + "manifest invalid" in message + or "manifest unknown" in message + or "name invalid" in message + or "name unknown" in message + ) + + def get_image( image: Union[str, docker.models.images.Image], client: docker.DockerClient = None, @@ -60,6 +73,9 @@ def get_image( except docker.errors.APIError as e: if not try_login: raise e + # this means it can't find it, no point in logging in + if image_is_not_on_server(e): + raise e kwargs = {} if "/" in image: registry = image.split("/")[0]