forked from microsoft/kiota
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-is-suppressed.ps1
executable file
·42 lines (35 loc) · 1.66 KB
/
get-is-suppressed.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env pwsh
param(
[Parameter(Mandatory = $true)][string]$descriptionUrl,
[Parameter(Mandatory = $true)][string]$language,
[string]$kind = "integration"
)
if ([string]::IsNullOrEmpty($descriptionUrl)) {
Write-Error "Description URL is empty"
exit 1
}
if ([string]::IsNullOrEmpty($language)) {
Write-Error "Language is empty"
exit 1
}
$configPath = Join-Path -Path $PSScriptRoot -ChildPath "config.json"
$jsonValue = Get-Content -Path $configPath -Raw | ConvertFrom-Json
$descriptionValue = $jsonValue.psobject.properties.Where({ $_.name -eq $descriptionUrl }).value
if ($null -ne $descriptionValue) {
if ($kind -eq "integration" -and $descriptionValue.PSObject.Properties.Name -contains "Suppressions") {
$languageInformation = $descriptionValue.Suppressions | Where-Object { $_.Language -eq $language -or $_.Language -eq "all" } | Select-Object -First 1
if ($null -ne $languageInformation) {
Write-Warning "Suppressed $descriptionUrl for $language, rationale: $($languageInformation.Rationale)"
return $true
}
}
elseif ($kind -eq "idempotency" -and $descriptionValue.PSObject.Properties.Name -contains "IdempotencySuppressions") {
$languageInformation = $descriptionValue.IdempotencySuppressions | Where-Object { $_.Language -eq $language -or $_.Language -eq "all" } | Select-Object -First 1
if ($null -ne $languageInformation) {
Write-Warning "Suppressed $descriptionUrl for $language, rationale: $($languageInformation.Rationale)"
return $true
}
}
}
Write-Information "No suppression found for $descriptionUrl for $language"
return $false