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'}}}