Skip to content

Commit bae3d8d

Browse files
committed
update
1 parent 62347fa commit bae3d8d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

eng/scripts/Armstrong-Validation.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,29 @@ function Ensure-Armstrong-Installed {
115115
function Validate-Terraform-Error($repoPath, $filePath) {
116116
$fileDirectory = (Split-Path -Parent $filePath)
117117
$outputDirectory = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName())
118+
$result = @()
118119

119120
try {
120121
if (!(Test-Path -Path $outputDirectory)) {
121-
New-Item -Path $outputDirectory -ItemType Directory
122+
New-Item -Path $outputDirectory -ItemType Directory *> $null
122123
# run armstrong credscan
123124
$specPath = Join-Path -Path $repoPath -ChildPath "specification"
124125
LogInfo "armstrong credscan -working-dir $fileDirectory -swagger-repo $specPath -output-dir $outputDirectory"
125126
armstrong credscan -working-dir $fileDirectory -swagger-repo $specPath -output-dir $outputDirectory
126127
}
127128

128-
$result = @()
129129
# error reports are stored in a directory named armstrong_credscan_<timestamp>
130130
Get-ChildItem -Path $outputDirectory -Directory -Filter "armstrong_credscan_*" | ForEach-Object {
131131
$errorJsonPath = Join-Path -Path $_.FullName -ChildPath "errors.json"
132132
if (Test-Path -Path $errorJsonPath) {
133133
Get-Content -Path $errorJsonPath -Raw | ConvertFrom-Json | ForEach-Object {
134-
$result += "$_"
134+
$properties = $_.PSObject.Properties
135+
$item = "Error Item:"
136+
foreach ($property in $properties) {
137+
$item += "`n $($property.Name): $($property.Value)"
138+
}
139+
140+
$result += $item
135141
}
136142
}
137143
}
@@ -181,7 +187,7 @@ else {
181187
if ($terraformErrors.Count -gt 0) {
182188
$errorString = "Armstrong Validation failed for some files. To fix, address the following errors: `n"
183189
$errorString += $terraformErrors -join "`n"
184-
LogError $errorString
190+
Write-Error $errorString
185191

186192
LogJobFailure
187193
exit 1

0 commit comments

Comments
 (0)