Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ARM] Fix az resource list cannot use tag when there is a default location #11787

Merged
merged 8 commits into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use "az configure" command

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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