-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Implement subscription filter on az login #33122
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
base: feat/subscription-filtering
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -152,7 +152,9 @@ def login(self, | |||||||||||||||||
| allow_no_subscriptions=False, | ||||||||||||||||||
| use_cert_sn_issuer=None, | ||||||||||||||||||
| show_progress=False, | ||||||||||||||||||
| claims_challenge=None): | ||||||||||||||||||
| claims_challenge=None, | ||||||||||||||||||
| skip_subscription_discovery=False, | ||||||||||||||||||
| default_subscription=None): | ||||||||||||||||||
| """ | ||||||||||||||||||
| For service principal, `password` is a dict returned by ServicePrincipalAuth.build_credential | ||||||||||||||||||
| """ | ||||||||||||||||||
|
|
@@ -198,15 +200,25 @@ def login(self, | |||||||||||||||||
| else: | ||||||||||||||||||
| credential = identity.get_service_principal_credential(username) | ||||||||||||||||||
|
|
||||||||||||||||||
| if tenant: | ||||||||||||||||||
| is_bare_mode = skip_subscription_discovery and not default_subscription | ||||||||||||||||||
|
|
||||||||||||||||||
| if skip_subscription_discovery and default_subscription: | ||||||||||||||||||
| # Fast path: fetch only the specified subscription (1 API call) | ||||||||||||||||||
| subscriptions = subscription_finder.find_specific_subscriptions( | ||||||||||||||||||
| tenant, credential, [default_subscription]) | ||||||||||||||||||
| elif is_bare_mode: | ||||||||||||||||||
| # Bare mode: no ARM subscription calls. Tenant-level account will be creatd below | ||||||||||||||||||
| subscriptions = [] | ||||||||||||||||||
| subscription_finder.tenants.append(tenant) | ||||||||||||||||||
| elif tenant: | ||||||||||||||||||
|
Comment on lines
+203
to
+213
|
||||||||||||||||||
| subscriptions = subscription_finder.find_using_specific_tenant(tenant, credential) | ||||||||||||||||||
| else: | ||||||||||||||||||
| subscriptions = subscription_finder.find_using_common_tenant(username, credential) | ||||||||||||||||||
|
|
||||||||||||||||||
| if not subscriptions and not allow_no_subscriptions: | ||||||||||||||||||
| if not subscriptions and not allow_no_subscriptions and not is_bare_mode: | ||||||||||||||||||
|
||||||||||||||||||
| if not subscriptions and not allow_no_subscriptions and not is_bare_mode: | |
| if not subscriptions and not allow_no_subscriptions and not is_bare_mode: | |
| if skip_subscription_discovery and default_subscription: | |
| # Fast-path error: a specific subscription was requested but could not be retrieved | |
| raise CLIError( | |
| "The subscription '{}' could not be retrieved for '{}'. " | |
| "Ensure the subscription exists and that you have access to it.".format( | |
| default_subscription, username)) |
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.
Typo in comment: "creatd" should be "created".