Skip to content

Commit

Permalink
Improve the error message of the conflict between tag and other filte…
Browse files Browse the repository at this point in the history
…r conditions for az resource list
  • Loading branch information
zhoxing-ms committed Jan 15, 2020
1 parent 49a3c3e commit 1fa123b
Show file tree
Hide file tree
Showing 4 changed files with 771 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

**ARM**

* Fix issue #9916: Improve the error message of the conflict between tag and other filter conditions for `az resource list` command

**IoT Central**

* Support app creation/update with the new sku name ST0, ST1, ST2.
Expand Down
17 changes: 14 additions & 3 deletions src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,20 @@ def _deploy_arm_template_subscription_scope(cli_ctx,
def _list_resources_odata_filter_builder(resource_group_name=None, resource_provider_namespace=None,
resource_type=None, name=None, tag=None, location=None):
"""Build up OData filter string from parameters """
if tag is not None:
if resource_group_name:
raise IncorrectUsageError('you cannot use the tag filter with resource group filter'
'(If the default value for resource group is set, please clear it with \'az configure\' command first)')
if resource_provider_namespace:
raise IncorrectUsageError('you cannot use the tag filter with namespace filter')
if resource_type:
raise IncorrectUsageError('you cannot use the tag filter with resource type filter')
if name:
raise IncorrectUsageError('you cannot use the tag filter with name filter')
if location:
raise IncorrectUsageError('you cannot use the tag filter with location filter'
'(If the default value for location is set, please clear it with \'az configure\' command first)')

filters = []

if resource_group_name:
Expand Down Expand Up @@ -534,9 +548,6 @@ def _list_resources_odata_filter_builder(resource_group_name=None, resource_prov
raise CLIError('--namespace also requires --resource-type')

if tag:
if name or location:
raise IncorrectUsageError('you cannot use the tag filter with other filters')

tag_name = list(tag.keys())[0] if isinstance(tag, dict) else tag
tag_value = tag[tag_name] if isinstance(tag, dict) else ''
if tag_name:
Expand Down
Loading

0 comments on commit 1fa123b

Please sign in to comment.