-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Core} Refactor code for passing arguments #30300
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
Conversation
️✔️AzureCLI-FullTest
|
|
Hi @jiasli, |
️✔️AzureCLI-BreakingChangeTest
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
| user_type = account[_USER_ENTITY][_USER_TYPE] | ||
| username_or_sp_id = account[_USER_ENTITY][_USER_NAME] | ||
| tenant_id = tenant_id if tenant_id else account[_TENANT_ID] | ||
| tenant_id = tenant_id or account[_TENANT_ID] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not
x or y: if x is true, then x, else y
0f28626 to
d2707ea
Compare
| external_credentials = [] | ||
| for external_tenant in external_tenants: | ||
| external_credentials.append(self._create_credential(account, external_tenant, client_id=client_id)) | ||
| external_credentials.append(self._create_credential(account, tenant_id=external_tenant)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_create_credential() defines tenant_id as a keyword argument:
| def _create_credential(self, account, tenant_id=None, client_id=None): |
Calling _create_credential() should follow the same pattern.
|
|
||
|
|
||
| def _create_identity_instance(cli_ctx, *args, **kwargs): | ||
| def _create_identity_instance(cli_ctx, authority, tenant_id=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very limited args (actually only one - authority) and kwargs are used:
It's better to be explicit.
https://peps.python.org/pep-0020/
Explicit is better than implicit.
d2707ea to
b12ac18
Compare
|
|
||
| def get_login_credentials(self, resource=None, client_id=None, subscription_id=None, aux_subscriptions=None, | ||
| aux_tenants=None): | ||
| def get_login_credentials(self, resource=None, subscription_id=None, aux_subscriptions=None, aux_tenants=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client_id should not be supported by get_login_credentials().
| return None, None | ||
|
|
||
| def _create_credential(self, account, tenant_id=None, client_id=None): | ||
| def _create_credential(self, account, tenant_id=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client_id is used in here, need to be reverted in the future: https://github.com/Azure/azure-cli/pull/30302/files#diff-242cdb28a28d3ff1d8467d2416389e39c0d149dab437550d6a6e88cca877c220R461
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no guarantee when #30302 will be merged. Better to keep the code clean for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's possibility that client_id is needed in the future, I agree with Hang that we can keep it for now. There's no harm to leave it as it is, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, changed as requested, but client_id will only be supported by get_raw_token(), not get_login_credentials(), so I am still removing it from get_login_credentials().
b12ac18 to
5decba3
Compare
5decba3 to
4fc8040
Compare

Related command
az loginDescription
Refactor code for passing arguments.
Pave way for
az account get-access-token: Add--client-idargument #30301