Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions src/azure-cli-core/azure/cli/core/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ def execute(self, args):

if hasattr(expanded_arg, '_subscription'):
cmd_copy.cli_ctx.data['subscription_id'] = expanded_arg._subscription # pylint: disable=protected-access
self.cli_ctx.data['subscription_id'] = expanded_arg._subscription # pylint: disable=protected-access
Comment thread
evelyn-ys marked this conversation as resolved.
Outdated

self._validation(expanded_arg)
jobs.append((expanded_arg, cmd_copy))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ def keyvault_data_plane_factory(cli_ctx, _):
def get_token(server, resource, scope): # pylint: disable=unused-argument
import adal
try:
return Profile(cli_ctx=cli_ctx).get_raw_token(resource)[0]
return Profile(cli_ctx=cli_ctx).get_raw_token(resource=resource,
subscription=cli_ctx.data.get('subscription_id'))[0]
Comment thread
evelyn-ys marked this conversation as resolved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[0] is magic code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I just keep it as it is

except adal.AdalError as err:
# pylint: disable=no-member
if (hasattr(err, 'error_response') and
Expand Down Expand Up @@ -170,7 +171,8 @@ def keyvault_private_data_plane_factory_v7_2_preview(cli_ctx, _):
def get_token(server, resource, scope): # pylint: disable=unused-argument
import adal
try:
return Profile(cli_ctx=cli_ctx).get_raw_token(resource)[0]
return Profile(cli_ctx=cli_ctx).get_raw_token(resource=resource,
subscription=cli_ctx.data.get('subscription_id'))[0]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cli_ctx.data.get('subscription_id'))[0] appears multiple times. Can we extract it to a method? String literal 'subscription_id' is error prone. [0] is magic number.

except adal.AdalError as err:
# pylint: disable=no-member
if (hasattr(err, 'error_response') and
Expand Down