Skip to content

Commit 9fc9e8d

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Allow to filter multiple tags for image list"
2 parents ccd877d + 5cc6fc2 commit 9fc9e8d

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

openstackclient/image/v2/image.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,10 @@ def get_parser(self, prog_name):
613613
parser.add_argument(
614614
'--tag',
615615
metavar='<tag>',
616-
default=None,
617-
help=_('Filter images based on tag.'),
616+
action='append',
617+
default=[],
618+
help=_('Filter images based on tag. '
619+
'(repeat option to filter on multiple tags)'),
618620
)
619621
parser.add_argument(
620622
'--hidden',

openstackclient/tests/functional/image/v2/test_image.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def setUp(self):
2626

2727
self.name = uuid.uuid4().hex
2828
self.image_tag = 'my_tag'
29+
self.image_tag1 = 'random'
2930
json_output = json.loads(self.openstack(
3031
'--os-image-api-version 2 '
3132
'image create -f json --tag {tag} {name}'.format(
@@ -78,13 +79,18 @@ def test_image_list_with_status_filter(self):
7879

7980
def test_image_list_with_tag_filter(self):
8081
json_output = json.loads(self.openstack(
81-
'image list --tag ' + self.image_tag + ' --long -f json'
82+
'image list --tag ' + self.image_tag + ' --tag ' +
83+
self.image_tag1 + ' --long -f json'
8284
))
8385
for taglist in [img['Tags'] for img in json_output]:
8486
self.assertIn(
8587
self.image_tag,
8688
taglist
8789
)
90+
self.assertIn(
91+
self.image_tag1,
92+
taglist
93+
)
8894

8995
def test_image_attributes(self):
9096
"""Test set, unset, show on attributes, tags and properties"""

openstackclient/tests/unit/image/v2/test_image.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,15 +835,16 @@ def test_image_list_hidden_option(self):
835835
def test_image_list_tag_option(self):
836836
arglist = [
837837
'--tag', 'abc',
838+
'--tag', 'cba'
838839
]
839840
verifylist = [
840-
('tag', 'abc'),
841+
('tag', ['abc', 'cba']),
841842
]
842843
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
843844

844845
columns, data = self.cmd.take_action(parsed_args)
845846
self.client.images.assert_called_with(
846-
tag='abc'
847+
tag=['abc', 'cba']
847848
)
848849

849850

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
features:
3+
- |
4+
The ``image list`` now accepts multiple ``--tag`` options, allowing you to
5+
filter images on more than one tag.

0 commit comments

Comments
 (0)