From 1778cddd9c7126af9cd3b45744c1036165e96b98 Mon Sep 17 00:00:00 2001 From: nusantara-self <15647296+nusantara-self@users.noreply.github.com> Date: Tue, 6 Feb 2024 22:56:26 +0800 Subject: [PATCH] Improve remote image comparison logging --- dockerhub.py | 10 ++++++++++ registry.py | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/dockerhub.py b/dockerhub.py index 435ce2d..990dc16 100644 --- a/dockerhub.py +++ b/dockerhub.py @@ -81,6 +81,16 @@ def get_remote_image_id(self, namespace, image, tag): ) metadata = json.loads(resp.content.decode("utf-8")) + try: + print(f"DEBUG: remote image last pushed: {metadata['images'][0]['last-pushed']}") + print(f"DEBUG: remote image status: {metadata['images'][0]['status']}") + print(f"DEBUG: repository tag status: {metadata['status']}") + print(f"DEBUG: repository tag last updated: {metadata['last_updated']}") + print(f"DEBUG: repository tag last pushed: {metadata['tag_last_pushed']}") + except KeyError as e: + print(f"KeyError encountered while accessing metadata: {e}") + except IndexError as e: + print(f"IndexError encountered while accessing metadata: {e}") return metadata["images"][0]["digest"] except Exception as e: print("Can't get remote image id: {}".format(e)) diff --git a/registry.py b/registry.py index 9963f97..4b5d69d 100644 --- a/registry.py +++ b/registry.py @@ -105,4 +105,8 @@ def correctly_pushed(self, namespace, repo, tag): remote_id = self.get_remote_image_id(namespace, repo, tag) if remote_id is None: return True + try: + print(f"DEBUG: Comparing local_id and remote_id, local_id: {local_id}, remote_id: {remote_id}") + except NameError as e: + print(f"Error: {e}. Ensure 'local_id' and 'remote_id' are defined before comparing.") return local_id == remote_id