Merge "image: Fail if we can't find an image"

This commit is contained in:
Zuul 2022-12-20 13:36:43 +00:00 committed by Gerrit Code Review
commit 21c3c33087
2 changed files with 26 additions and 9 deletions

View File

@ -191,7 +191,8 @@ class AddProjectToImage(command.ShowOne):
).id ).id
image = image_client.find_image( image = image_client.find_image(
parsed_args.image, ignore_missing=False parsed_args.image,
ignore_missing=False,
) )
obj = image_client.add_member( obj = image_client.add_member(
@ -664,7 +665,8 @@ class DeleteImage(command.Command):
for image in parsed_args.images: for image in parsed_args.images:
try: try:
image_obj = image_client.find_image( image_obj = image_client.find_image(
image, ignore_missing=False image,
ignore_missing=False,
) )
image_client.delete_image(image_obj.id) image_client.delete_image(image_obj.id)
except Exception as e: except Exception as e:
@ -835,7 +837,10 @@ class ListImage(command.Lister):
if parsed_args.limit: if parsed_args.limit:
kwargs['limit'] = parsed_args.limit kwargs['limit'] = parsed_args.limit
if parsed_args.marker: 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: if parsed_args.name:
kwargs['name'] = parsed_args.name kwargs['name'] = parsed_args.name
if parsed_args.status: if parsed_args.status:
@ -932,7 +937,10 @@ class ListImageProjects(command.Lister):
image_client = self.app.client_manager.image image_client = self.app.client_manager.image
columns = ("Image ID", "Member ID", "Status") 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) data = image_client.members(image=image_id)
@ -977,7 +985,8 @@ class RemoveProjectImage(command.Command):
).id ).id
image = image_client.find_image( 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) image_client.remove_member(member=project_id, image=image.id)
@ -1003,7 +1012,10 @@ class SaveImage(command.Command):
def take_action(self, parsed_args): def take_action(self, parsed_args):
image_client = self.app.client_manager.image 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 output_file = parsed_args.filename
if output_file is None: if output_file is None:
@ -1371,7 +1383,8 @@ class ShowImage(command.ShowOne):
image_client = self.app.client_manager.image image_client = self.app.client_manager.image
image = image_client.find_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) info = _format_image(image, parsed_args.human_readable)
@ -1415,7 +1428,8 @@ class UnsetImage(command.Command):
def take_action(self, parsed_args): def take_action(self, parsed_args):
image_client = self.app.client_manager.image image_client = self.app.client_manager.image
image = image_client.find_image( image = image_client.find_image(
parsed_args.image, ignore_missing=False parsed_args.image,
ignore_missing=False,
) )
kwargs = {} kwargs = {}

View File

@ -905,7 +905,10 @@ class TestImageList(TestImage):
marker=self._image.id, 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): def test_image_list_name_option(self):
arglist = [ arglist = [