Sync eng/common directory with azure-sdk-tools for PR 2847 (#3455)
* Add extra group conditions, template consolidation * Module fixes. Enable provisioner identity permissions via opensource api. Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
parent
282ed53068
commit
077d6c97be
@ -1,11 +1,11 @@
|
||||
function Generate-AadToken ($TenantId, $ClientId, $ClientSecret)
|
||||
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
|
||||
@ -17,8 +17,9 @@ function Generate-AadToken ($TenantId, $ClientId, $ClientSecret)
|
||||
return $resp.access_token
|
||||
}
|
||||
|
||||
function GetMsAliasFromGithub ($TenantId, $ClientId, $ClientSecret, $GithubUser)
|
||||
function GetMsAliasFromGithub ([string]$TenantId, [string]$ClientId, [string]$ClientSecret, [string]$GithubUser)
|
||||
{
|
||||
# API documentation (out of date): https://github.com/microsoft/opensource-management-portal/blob/main/docs/api.md
|
||||
$OpensourceAPIBaseURI = "https://repos.opensource.microsoft.com/api/people/links/github/$GithubUser"
|
||||
|
||||
$Headers = @{
|
||||
@ -31,8 +32,7 @@ function GetMsAliasFromGithub ($TenantId, $ClientId, $ClientSecret, $GithubUser)
|
||||
$Headers["Authorization"] = "Bearer $opsAuthToken"
|
||||
Write-Host "Fetching aad identity for github user: $GithubUser"
|
||||
$resp = Invoke-RestMethod $OpensourceAPIBaseURI -Method 'GET' -Headers $Headers -MaximumRetryCount 3
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
Write-Warning $_
|
||||
return $null
|
||||
}
|
||||
@ -47,7 +47,30 @@ function GetMsAliasFromGithub ($TenantId, $ClientId, $ClientSecret, $GithubUser)
|
||||
return $null
|
||||
}
|
||||
|
||||
function GetPrimaryCodeOwner ($TargetDirectory)
|
||||
function GetAllGithubUsers ([string]$TenantId, [string]$ClientId, [string]$ClientSecret)
|
||||
{
|
||||
# API documentation (out of date): https://github.com/microsoft/opensource-management-portal/blob/main/docs/api.md
|
||||
$OpensourceAPIBaseURI = "https://repos.opensource.microsoft.com/api/people/links"
|
||||
|
||||
$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 all github alias links"
|
||||
$resp = Invoke-RestMethod $OpensourceAPIBaseURI -Method 'GET' -Headers $Headers -MaximumRetryCount 3
|
||||
} catch {
|
||||
Write-Warning $_
|
||||
return $null
|
||||
}
|
||||
|
||||
return $resp
|
||||
}
|
||||
|
||||
function GetPrimaryCodeOwner ([string]$TargetDirectory)
|
||||
{
|
||||
$codeOwnerArray = &"$PSScriptRoot/../get-codeowners.ps1" -TargetDirectory $TargetDirectory
|
||||
if ($codeOwnerArray) {
|
||||
|
||||
@ -5,4 +5,4 @@ param (
|
||||
|
||||
. (Join-Path $PSScriptRoot Helpers PSModule-Helpers.ps1)
|
||||
|
||||
Install-ModuleIfNotInstalled "Az" $AzModuleVersion | Import-Module
|
||||
Install-ModuleIfNotInstalled "Az" $AzModuleVersion | Import-Module
|
||||
|
||||
@ -4,10 +4,10 @@ Updates package README.md for publishing to docs.microsoft.com
|
||||
|
||||
.DESCRIPTION
|
||||
Given a PackageInfo .json file, format the package README.md file with metadata
|
||||
and other information needed to release reference docs:
|
||||
and other information needed to release reference docs:
|
||||
|
||||
* Adjust README.md content to include metadata
|
||||
* Insert the package verison number in the README.md title
|
||||
* Insert the package verison number in the README.md title
|
||||
* Copy file to the appropriate location in the documentation repository
|
||||
* Copy PackageInfo .json file to the metadata location in the reference docs
|
||||
repository. This enables the Docs CI build to onboard packages which have not
|
||||
@ -18,7 +18,7 @@ List of locations of the artifact information .json file. This is usually stored
|
||||
in build artifacts under packages/PackageInfo/<package-name>.json. Can also be
|
||||
a single item.
|
||||
|
||||
.PARAMETER DocRepoLocation
|
||||
.PARAMETER DocRepoLocation
|
||||
Location of the root of the docs.microsoft.com reference doc location. Further
|
||||
path information is provided by $GetDocsMsMetadataForPackageFn
|
||||
|
||||
@ -47,7 +47,7 @@ param(
|
||||
[array]$PackageInfoJsonLocations,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$DocRepoLocation,
|
||||
[string]$DocRepoLocation,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Language,
|
||||
@ -104,12 +104,12 @@ function GetAdjustedReadmeContent($ReadmeContent, $PackageInfo, $PackageMetadata
|
||||
$replacementPattern = "`${1}$tag"
|
||||
$ReadmeContent = $ReadmeContent -replace $releaseReplaceRegex, $replacementPattern
|
||||
}
|
||||
|
||||
|
||||
# Get the first code owners of the package.
|
||||
Write-Host "Retrieve the code owner from $($PackageInfo.DirectoryPath)."
|
||||
$author = GetPrimaryCodeOwner -TargetDirectory $PackageInfo.DirectoryPath
|
||||
$author = GetPrimaryCodeOwner -TargetDirectory $PackageInfo.DirectoryPath
|
||||
if (!$author) {
|
||||
$author = "ramya-rao-a"
|
||||
$author = "ramya-rao-a"
|
||||
$msauthor = "ramyar"
|
||||
}
|
||||
else {
|
||||
@ -148,10 +148,10 @@ function GetPackageInfoJson ($packageInfoJsonLocation) {
|
||||
$packageInfoJson = Get-Content $packageInfoJsonLocation -Raw
|
||||
$packageInfo = ConvertFrom-Json $packageInfoJson
|
||||
if ($packageInfo.DevVersion) {
|
||||
# If the package is of a dev version there may be language-specific needs to
|
||||
# specify the appropriate version. For example, in the case of JS, the dev
|
||||
# If the package is of a dev version there may be language-specific needs to
|
||||
# specify the appropriate version. For example, in the case of JS, the dev
|
||||
# version is always 'dev' when interacting with NPM.
|
||||
if ($GetDocsMsDevLanguageSpecificPackageInfoFn -and (Test-Path "Function:$GetDocsMsDevLanguageSpecificPackageInfoFn")) {
|
||||
if ($GetDocsMsDevLanguageSpecificPackageInfoFn -and (Test-Path "Function:$GetDocsMsDevLanguageSpecificPackageInfoFn")) {
|
||||
$packageInfo = &$GetDocsMsDevLanguageSpecificPackageInfoFn $packageInfo
|
||||
} else {
|
||||
# Default: use the dev version from package info as the version for
|
||||
@ -162,16 +162,16 @@ function GetPackageInfoJson ($packageInfoJsonLocation) {
|
||||
return $packageInfo
|
||||
}
|
||||
|
||||
function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation, $packageInfo) {
|
||||
function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation, $packageInfo) {
|
||||
$originalVersion = [AzureEngSemanticVersion]::ParseVersionString($packageInfo.Version)
|
||||
$packageMetadataArray = (Get-CSVMetadata).Where({ $_.Package -eq $packageInfo.Name -and $_.Hide -ne 'true' -and $_.New -eq 'true' })
|
||||
if ($packageInfo.Group) {
|
||||
$packageMetadataArray = ($packageMetadataArray).Where({$_.GroupId -eq $packageInfo.Group})
|
||||
}
|
||||
if ($packageMetadataArray.Count -eq 0) {
|
||||
if ($packageMetadataArray.Count -eq 0) {
|
||||
LogWarning "Could not retrieve metadata for $($packageInfo.Name) from metadata CSV. Using best effort defaults."
|
||||
$packageMetadata = $null
|
||||
} elseif ($packageMetadataArray.Count -gt 1) {
|
||||
} elseif ($packageMetadataArray.Count -gt 1) {
|
||||
LogWarning "Multiple metadata entries for $($packageInfo.Name) in metadata CSV. Using first entry."
|
||||
$packageMetadata = $packageMetadataArray[0]
|
||||
} else {
|
||||
@ -199,10 +199,10 @@ function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation, $packageInfo)
|
||||
Write-Warning "$($packageInfo.Name) does not have Readme file. Skipping update readme."
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
$readmeContent = Get-Content $packageInfo.ReadMePath -Raw
|
||||
$outputReadmeContent = ""
|
||||
if ($readmeContent) {
|
||||
$outputReadmeContent = ""
|
||||
if ($readmeContent) {
|
||||
$outputReadmeContent = GetAdjustedReadmeContent $readmeContent $packageInfo $packageMetadata
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user