@@ -115,23 +115,29 @@ function Ensure-Armstrong-Installed {
115
115
function Validate-Terraform-Error ($repoPath , $filePath ) {
116
116
$fileDirectory = (Split-Path - Parent $filePath )
117
117
$outputDirectory = [System.IO.Path ]::Combine([System.IO.Path ]::GetTempPath(), [System.IO.Path ]::GetRandomFileName())
118
+ $result = @ ()
118
119
119
120
try {
120
121
if (! (Test-Path - Path $outputDirectory )) {
121
- New-Item - Path $outputDirectory - ItemType Directory
122
+ New-Item - Path $outputDirectory - ItemType Directory * > $null
122
123
# run armstrong credscan
123
124
$specPath = Join-Path - Path $repoPath - ChildPath " specification"
124
125
LogInfo " armstrong credscan -working-dir $fileDirectory -swagger-repo $specPath -output-dir $outputDirectory "
125
126
armstrong credscan - working- dir $fileDirectory - swagger- repo $specPath - output- dir $outputDirectory
126
127
}
127
128
128
- $result = @ ()
129
129
# error reports are stored in a directory named armstrong_credscan_<timestamp>
130
130
Get-ChildItem - Path $outputDirectory - Directory - Filter " armstrong_credscan_*" | ForEach-Object {
131
131
$errorJsonPath = Join-Path - Path $_.FullName - ChildPath " errors.json"
132
132
if (Test-Path - Path $errorJsonPath ) {
133
133
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
135
141
}
136
142
}
137
143
}
@@ -181,7 +187,7 @@ else {
181
187
if ($terraformErrors.Count -gt 0 ) {
182
188
$errorString = " Armstrong Validation failed for some files. To fix, address the following errors: `n "
183
189
$errorString += $terraformErrors -join " `n "
184
- LogError $errorString
190
+ Write-Error $errorString
185
191
186
192
LogJobFailure
187
193
exit 1
0 commit comments