image: Fail if we can't find an image

Whenever we attempt to find a provided image, we generally want to fail
fast if they can't be found. This wasn't happening. Fix it.

Change-Id: Ibea38354a78381cb87d287f03726ecd03ecd246d
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2022-11-30 13:30:40 +00:00
parent a538104a94
commit 799a073b68
2 changed files with 26 additions and 9 deletions

View File

@ -190,7 +190,8 @@ class AddProjectToImage(command.ShowOne):
).id
image = image_client.find_image(
parsed_args.image, ignore_missing=False
parsed_args.image,
ignore_missing=False,
)
obj = image_client.add_member(
@ -663,7 +664,8 @@ class DeleteImage(command.Command):
for image in parsed_args.images:
try:
image_obj = image_client.find_image(
image, ignore_missing=False
image,
ignore_missing=False,
)
image_client.delete_image(image_obj.id)
except Exception as e:
@ -834,7 +836,10 @@ class ListImage(command.Lister):
if parsed_args.limit:
kwargs['limit'] = parsed_args.limit
if parsed_args.marker:
kwargs['marker'] = image_client.find_image(parsed_args.marker).id
kwargs['marker'] = image_client.find_image(
parsed_args.marker,
ignore_missing=False,
).id
if parsed_args.name:
kwargs['name'] = parsed_args.name
if parsed_args.status:
@ -931,7 +936,10 @@ class ListImageProjects(command.Lister):
image_client = self.app.client_manager.image
columns = ("Image ID", "Member ID", "Status")
image_id = image_client.find_image(parsed_args.image).id
image_id = image_client.find_image(
parsed_args.image,
ignore_missing=False,
).id
data = image_client.members(image=image_id)
@ -976,7 +984,8 @@ class RemoveProjectImage(command.Command):
).id
image = image_client.find_image(
parsed_args.image, ignore_missing=False
parsed_args.image,
ignore_missing=False,
)
image_client.remove_member(member=project_id, image=image.id)
@ -1002,7 +1011,10 @@ class SaveImage(command.Command):
def take_action(self, parsed_args):
image_client = self.app.client_manager.image
image = image_client.find_image(parsed_args.image)
image = image_client.find_image(
parsed_args.image,
ignore_missing=False,
)
output_file = parsed_args.filename
if output_file is None:
@ -1370,7 +1382,8 @@ class ShowImage(command.ShowOne):
image_client = self.app.client_manager.image
image = image_client.find_image(
parsed_args.image, ignore_missing=False
parsed_args.image,
ignore_missing=False,
)
info = _format_image(image, parsed_args.human_readable)
@ -1414,7 +1427,8 @@ class UnsetImage(command.Command):
def take_action(self, parsed_args):
image_client = self.app.client_manager.image
image = image_client.find_image(
parsed_args.image, ignore_missing=False
parsed_args.image,
ignore_missing=False,
)
kwargs = {}

View File

@ -905,7 +905,10 @@ class TestImageList(TestImage):
marker=self._image.id,
)
self.client.find_image.assert_called_with('graven')
self.client.find_image.assert_called_with(
'graven',
ignore_missing=False,
)
def test_image_list_name_option(self):
arglist = [