-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix] Do not specify --tenant flag when fetching managed identity acc…
…ess token from the CLI (#748) ## Changes Ports databricks/databricks-sdk-go#1021 to the Python SDK. The Azure CLI's az account get-access-token command does not allow specifying --tenant flag if it is authenticated via the CLI. Fixes #742. ## Tests Unit tests ensure that all expected cases are treated as managed identities. - [ ] `make test` run locally - [ ] `make fmt` applied - [ ] relevant integration tests applied
- Loading branch information
Showing
4 changed files
with
109 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
#!/usr/bin/env pwsh | ||
|
||
# If the arguments are "account show", return the account details. | ||
if ($args[0] -eq "account" -and $args[1] -eq "show") { | ||
$output = @{ | ||
environmentName = "AzureCloud" | ||
id = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" | ||
isDefault = $true | ||
name = "Pay-As-You-Go" | ||
state = "Enabled" | ||
tenantId = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" | ||
user = @{ | ||
name = if ($env:AZ_USER_NAME) { $env:AZ_USER_NAME } else { "[email protected]" } | ||
type = if ($env:AZ_USER_TYPE) { $env:AZ_USER_TYPE } else { "user" } | ||
} | ||
} | ||
$output | ConvertTo-Json | ||
exit 0 | ||
} | ||
|
||
if ($env:WARN) { | ||
Write-Error "WARNING: $env:WARN" | ||
} | ||
|
@@ -30,6 +48,16 @@ foreach ($arg in $Args) { | |
} | ||
} | ||
|
||
# If FAIL_IF_TENANT_ID_SET is set & --tenant-id is passed, fail. | ||
if ($env:FAIL_IF_TENANT_ID_SET) { | ||
foreach ($arg in $args) { | ||
if ($arg -eq "--tenant-id" -or $arg -like "--tenant*") { | ||
Write-Error "ERROR: Tenant shouldn't be specified for managed identity account" | ||
exit 1 | ||
} | ||
} | ||
} | ||
|
||
try { | ||
$EXP = (Get-Date).AddSeconds($env:EXPIRE -as [int]) | ||
} catch { | ||
|