Skip to content

Commit

Permalink
Update get_image_label return value
Browse files Browse the repository at this point in the history
  • Loading branch information
lipoja authored and yashvardhannanavati committed Jun 16, 2023
1 parent 54b5a66 commit bab7635
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions iib/workers/tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_workers/test_tasks/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}}
Expand Down

0 comments on commit bab7635

Please sign in to comment.