-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Azure:main' into tpatterson/fix-write-deadlock
- Loading branch information
Showing
12 changed files
with
161 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
function Generate-AadToken ($TenantId, $ClientId, $ClientSecret) | ||
{ | ||
$LoginAPIBaseURI = "https://login.microsoftonline.com/$TenantId/oauth2/token" | ||
|
||
$headers = @{ | ||
"content-type" = "application/x-www-form-urlencoded" | ||
} | ||
|
||
$body = @{ | ||
"grant_type" = "client_credentials" | ||
"client_id" = $ClientId | ||
"client_secret" = $ClientSecret | ||
"resource" = "api://repos.opensource.microsoft.com/audience/7e04aa67" | ||
} | ||
Write-Host "Generating aad token..." | ||
$resp = Invoke-RestMethod $LoginAPIBaseURI -Method 'POST' -Headers $headers -Body $body | ||
return $resp.access_token | ||
} | ||
|
||
function GetMsAliasFromGithub ($TenantId, $ClientId, $ClientSecret, $GithubUser) | ||
{ | ||
$OpensourceAPIBaseURI = "https://repos.opensource.microsoft.com/api/people/links/github/$GithubUser" | ||
|
||
$Headers = @{ | ||
"Content-Type" = "application/json" | ||
"api-version" = "2019-10-01" | ||
} | ||
|
||
try { | ||
$opsAuthToken = Generate-AadToken -TenantId $TenantId -ClientId $ClientId -ClientSecret $ClientSecret | ||
$Headers["Authorization"] = "Bearer $opsAuthToken" | ||
Write-Host "Fetching aad identity for github user: $GithubUser" | ||
$resp = Invoke-RestMethod $OpensourceAPIBaseURI -Method 'GET' -Headers $Headers | ||
} | ||
catch { | ||
Write-Error $_ | ||
return $null | ||
} | ||
|
||
$resp | Write-Verbose | ||
|
||
if ($resp.aad) { | ||
Write-Host "Fetched aad identity $($resp.aad.alias) for github user $GithubUser." | ||
return $resp.aad.alias | ||
} | ||
Write-Error "Failed to retrieve the aad identity from given github user: $GithubName" | ||
return $null | ||
} | ||
|
||
function GetPrimaryCodeOwner ($TargetDirectory) | ||
{ | ||
$codeOwnerArray = &"$PSScriptRoot/../get-codeowners.ps1" -TargetDirectory $TargetDirectory | ||
if ($codeOwnerArray) { | ||
Write-Host "Code Owners are $codeOwnerArray." | ||
return $codeOwnerArray[0] | ||
} | ||
Write-Error "No code owner found in $TargetDirectory." | ||
return $null | ||
} |
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
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 |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
package internal | ||
|
||
const ( | ||
version = "v0.2.1" //nolint | ||
version = "v0.2.2" //nolint | ||
) |
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