Skip to content

Commit

Permalink
Changes to move az cli commands to caller script and other review com…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
praveenkuttappan authored and azure-sdk committed May 25, 2021
1 parent 500875d commit 3a31880
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
28 changes: 7 additions & 21 deletions eng/common/scripts/Helpers/ApiView-Helpers.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Map-LanguageToAPiview-Filter($language)
function MapLanguageName($language)
{
$lang = $language
# Update language name to match those in API cosmos DB. Cosmos SQL is case sensitive and handling this within the query makes it slow.
Expand All @@ -17,23 +17,11 @@ function Map-LanguageToAPiview-Filter($language)
return $lang
}

function Check-ApiReviewStatus($packageName, $packageVersion, $language)
function Check-ApiReviewStatus($packageName, $packageVersion, $language, $url, $apiKey)
{
# Get API view URL and API Key to check status
Write-Host "Checking API review status"
try
{
az login -o none
$url = az keyvault secret show --name "APIURL" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
$apiKey = az keyvault secret show --name "APIKEY" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
}
catch
{
Write-Host "Failed to get APIView URL and API Key from Keyvault AzureSDKPrepRelease-KV. Please check and ensure you have access to this Keyvault as reader."
Write-Host "You can check http://aka.ms/azsdk/engsys/apireview/faq for more details."
}

$lang = Map-LanguageToAPiview-Filter -language $language
$lang = MapLanguageName -language $language
$headers = @{ "ApiKey" = $apiKey }
$body = @{
language = $lang
Expand All @@ -43,22 +31,20 @@ function Check-ApiReviewStatus($packageName, $packageVersion, $language)

try
{
$Response = Invoke-WebRequest $url -Method 'GET' -Headers $headers -Body $body
if ($Response.StatusCode -eq '200')
$response = Invoke-WebRequest $url -Method 'GET' -Headers $headers -Body $body
if ($response.StatusCode -eq '200')
{
Write-Host "API Review is approved for package $($packageName)"
return $true
}
else
{
Write-Host "API Review is not approved for package $($packageName). Please get automatic API review approved by architects."
Write-Warning "API Review is not approved for package $($packageName). Release pipeline will fail if API review is not approved."
Write-Host "You can check http://aka.ms/azsdk/engsys/apireview/faq for more details on API Approval."
}
}
catch
{
Write-Host "Exception details: $($_.Exception.Response)"
Write-Host "Failed to check API review status for package $($PackageName). You can check http://aka.ms/azsdk/engsys/apireview/faq for more details on API Approval."
Write-Warning "Failed to check API review status for package $($PackageName). You can check http://aka.ms/azsdk/engsys/apireview/faq for more details on API Approval."
}
return $false
}
19 changes: 14 additions & 5 deletions eng/common/scripts/Prepare-Release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,21 @@ if ($LASTEXITCODE -ne 0) {

# Check API status if version is GA
if (!$newVersionParsed.IsPrerelease)
{
$isApproved = Check-ApiReviewStatus -PackageName $packageProperties.Name -packageVersion $newVersion -Language $LanguageDisplayName
if (!$isApproved)
{
try
{
az account show *> $null
if (!$?) {
Write-Host 'Running az login...'
az login *> $null
}
$url = az keyvault secret show --name "APIURL" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
$apiKey = az keyvault secret show --name "APIKEY" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
Check-ApiReviewStatus -PackageName $packageProperties.Name -packageVersion $newVersion -Language $LanguageDisplayName -url $url -apiKey $apiKey
}
catch
{
Write-Error "API review is not approved in APIView system."
exit 1
Write-Warning "Failed to get APIView URL and API Key from Keyvault AzureSDKPrepRelease-KV. Please check and ensure you have access to this Keyvault as reader."
}
}

Expand Down

0 comments on commit 3a31880

Please sign in to comment.