From 9415964d9aab6db7537de14fb39df94198a84687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lipovsk=C3=BD?= Date: Mon, 12 Jun 2023 15:50:17 +0200 Subject: [PATCH] Update get_image_label return value --- iib/workers/tasks/utils.py | 4 ++-- tests/test_workers/test_tasks/test_utils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iib/workers/tasks/utils.py b/iib/workers/tasks/utils.py index c0e4a406..fbd6bb6e 100644 --- a/iib/workers/tasks/utils.py +++ b/iib/workers/tasks/utils.py @@ -1088,7 +1088,7 @@ def get_all_index_images_info( return infos -def get_image_label(pull_spec: str, label: str) -> Optional[str]: +def get_image_label(pull_spec: str, label: str) -> str: """ Get a specific label from the container image. @@ -1098,7 +1098,7 @@ def get_image_label(pull_spec: str, label: str) -> Optional[str]: :rtype: str """ log.debug('Getting the label of %s from %s', label, pull_spec) - return get_image_labels(pull_spec).get(label) + return get_image_labels(pull_spec).get(label, '') def verify_labels(bundles: List[str]) -> None: diff --git a/tests/test_workers/test_tasks/test_utils.py b/tests/test_workers/test_tasks/test_utils.py index 7f3ca302..256fc7f1 100644 --- a/tests/test_workers/test_tasks/test_utils.py +++ b/tests/test_workers/test_tasks/test_utils.py @@ -795,7 +795,7 @@ def test_get_image_arches_not_manifest_list(mock_si): utils.get_image_arches('image:latest') -@pytest.mark.parametrize('label, expected', (('some_label', 'value'), ('not_there', None))) +@pytest.mark.parametrize('label, expected', (('some_label', 'value'), ('not_there', ''))) @mock.patch('iib.workers.tasks.utils.skopeo_inspect') def test_get_image_label(mock_si, label, expected): mock_si.return_value = {'config': {'Labels': {'some_label': 'value'}}}