Skip to content

Commit 62347fa

Browse files
committed
update
1 parent 0755ad3 commit 62347fa

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

eng/pipelines/armstrong-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- script: |
1515
go version
16-
go install github.com/azure/armstrong@109e9a46faa57c2c5af762019342dff3030f7d79
16+
go install github.com/azure/armstrong@67fe406e78e3b94075932add869f8b11fb4dd0a6
1717
echo '##vso[task.prependpath]$(HOME)/go/bin'
1818
displayName: 'Setup dependencies'
1919

eng/scripts/Armstrong-Validation.ps1

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function Get-ChangedTerraformFiles($changedFiles = (Get-ChangedFiles)) {
8383
$changedFiles = Get-ChangedFilesUnderSpecification $changedFiles
8484

8585
$changedSwaggerFiles = $changedFiles.Where({
86+
# since `git diff` returns paths with `/`, use the following code to match the `main.tf`
8687
$_.EndsWith("/main.tf")
8788
})
8889

@@ -113,27 +114,31 @@ function Ensure-Armstrong-Installed {
113114

114115
function Validate-Terraform-Error($repoPath, $filePath) {
115116
$fileDirectory = (Split-Path -Parent $filePath)
116-
117-
$outputDirectory = Join-Path -Path $fileDirectory -ChildPath "58d50903-36e9-4f57-a1e5-f246d7ecdec0"
118-
119-
if (!(Test-Path -Path $outputDirectory)) {
120-
New-Item -Path $outputDirectory -ItemType Directory
121-
# run armstrong credscan
122-
$specPath = Join-Path -Path $repoPath -ChildPath "specification"
123-
LogInfo "armstrong credscan -working-dir $fileDirectory -swagger-repo $specPath -output-dir $outputDirectory"
124-
armstrong credscan -working-dir $fileDirectory -swagger-repo $specPath -output-dir $outputDirectory
125-
}
126-
127-
$result = @()
128-
# error reports are stored in a directory named armstrong_credscan_<timestamp>
129-
Get-ChildItem -Path $outputDirectory -Directory -Filter "armstrong_credscan_*" | ForEach-Object {
130-
$errorJsonPath = Join-Path -Path $_.FullName -ChildPath "errors.json"
131-
if (Test-Path -Path $errorJsonPath) {
132-
Get-Content -Path $errorJsonPath -Raw | ConvertFrom-Json | ForEach-Object {
133-
$result += "$_"
117+
$outputDirectory = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName())
118+
119+
try {
120+
if (!(Test-Path -Path $outputDirectory)) {
121+
New-Item -Path $outputDirectory -ItemType Directory
122+
# run armstrong credscan
123+
$specPath = Join-Path -Path $repoPath -ChildPath "specification"
124+
LogInfo "armstrong credscan -working-dir $fileDirectory -swagger-repo $specPath -output-dir $outputDirectory"
125+
armstrong credscan -working-dir $fileDirectory -swagger-repo $specPath -output-dir $outputDirectory
126+
}
127+
128+
$result = @()
129+
# error reports are stored in a directory named armstrong_credscan_<timestamp>
130+
Get-ChildItem -Path $outputDirectory -Directory -Filter "armstrong_credscan_*" | ForEach-Object {
131+
$errorJsonPath = Join-Path -Path $_.FullName -ChildPath "errors.json"
132+
if (Test-Path -Path $errorJsonPath) {
133+
Get-Content -Path $errorJsonPath -Raw | ConvertFrom-Json | ForEach-Object {
134+
$result += "$_"
135+
}
134136
}
135137
}
136138
}
139+
finally {
140+
Remove-Item -Path $outputDirectory -Recurse -Force
141+
}
137142

138143
return $result
139144
}

0 commit comments

Comments
 (0)