Skip to content
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
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/storage/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem

for item in ['create', 'delete', 'exists', 'list', 'show', 'update']:
with self.argument_context('storage share-rm {}'.format(item), resource_type=ResourceType.MGMT_STORAGE) as c:
c.argument('resource_group_name', required=False, validator=process_resource_group)
c.argument('resource_group_name', required=False)
c.argument('account_name', storage_account_type)
Copy link
Member

Choose a reason for hiding this comment

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

storage_account_type already adds validator to parse for resource group name.

Copy link
Member

Choose a reason for hiding this comment

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

Is it better to add the logic to validator for storage_account_type instead of another validator?

c.argument('share_name', share_name_type, options_list=('--name', '-n'), id_part='child_name_2')
c.argument('share_quota', type=int, options_list='--quota')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ def _cancel_timer_event_handler(_, **__):


# region PARAMETER VALIDATORS
def parse_storage_account(namespace):
def parse_storage_account(cmd, namespace):
"""Parse storage account which can be either account name or account id"""
from msrestazure.tools import parse_resource_id, is_valid_resource_id

if namespace.account_name and is_valid_resource_id(namespace.account_name):
namespace.resource_group_name = parse_resource_id(namespace.account_name)['resource_group']
namespace.account_name = parse_resource_id(namespace.account_name)['name']
elif not namespace.resource_group_name:
Copy link
Member

Choose a reason for hiding this comment

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

what's the behavior if both account_name and resource_group_name are None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I will add one more condition for the function although account-name is required for all commands. 😊

namespace.resource_group_name = _query_account_rg(cmd.cli_ctx, namespace.account_name)[0]


def process_resource_group(cmd, namespace):
Expand Down