Skip to content

Commit be6dd07

Browse files
KirtiWandharesrimathiS
authored andcommitted
Update AzureRM.TemplateValidator.psm1 (#59)
1 parent d7e54ca commit be6dd07

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

TemplateValidator/AzureRM.TemplateValidator.psm1

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@ table td:nth-child(3){white-space:pre-line}
219219
$reportHtml = $title + $validationSummary + $reportXml.OuterXml|Out-String
220220
ConvertTo-Html $postContent -head $head -Body $reportHtml | out-File $Report
221221
}
222+
$reportFilePath = Join-Path $PSScriptRoot $Report
223+
Write-Output "Validation Summary:
224+
`Passed: $passedCount
225+
`NotSupported: $notSupportedCount
226+
`Exception: $exceptionCount
227+
`Warning: $warningCount
228+
`Recommend: $recommendCount
229+
`Total Templates: $totalCount"
230+
Write-Output "Report available at - $reportFilePath"
222231
}
223232

224233
function Get-NestedTemplates
@@ -835,30 +844,32 @@ function ValidateResource
835844
}
836845
else
837846
{
838-
$supportedVersions = @()
839-
foreach ($ver in $supportedType.versions)
840-
{
841-
$supportedVersions +=[version]$ver
842-
}
847+
$supportedVersions = $supportedType.versions
843848
if ($templateextVersion -notin $supportedVersions)
844849
{
845-
if ($templateextVersion.Split(".").Count -eq 2) {$templateextVersion = $templateextVersion + ".0.0" }
846-
$v = [version]$templateextVersion
847-
if ($v -notin $supportedVersions)
850+
if ($templateextVersion.Split(".").Count -eq 2)
851+
{
852+
$templateextVersion = $templateextVersion + ".0.0"
853+
}
854+
elseif ($templateextVersion.Split(".").Count -eq 3)
848855
{
849-
$autoupgradeSupported = $supportedVersions| Where-Object { ($_.Major -eq $v.Major) -and ($_.Minor -gt $v.Minor) }
856+
$templateextVersion = $templateextVersion + ".0"
857+
}
858+
if ($templateextVersion -notin $supportedVersions)
859+
{
860+
$autoupgradeSupported = $supportedVersions | Where-Object { (([version]$_).Major -eq ([version]$templateextVersion).Major) -and (([version]$_).Minor -ge ([version]$templateextVersion).Minor) }
850861
if ($autoupgradeSupported)
851862
{
852863
if ((-not $resource.properties.autoupgrademinorversion) -or ($resource.properties.autoupgrademinorversion -eq $false))
853864
{
854-
$msg = "Warning: Exact Match for VMExtension version: $templateextPublisher\$templateextType\$templateextVersion not found in $supportedVersions. It is recommended to set autoupgrademinorversion property to true"
865+
$msg = "Warning: Exact Match for VMExtension version ($templateextPublisher\$templateextType\$templateextVersion) not found in supported versions ($supportedVersions). It is recommended to set autoupgrademinorversion property to true."
855866
Write-warning $msg
856867
$resourceOutput += $msg
857868
}
858869
}
859870
else
860871
{
861-
$msg = "Warning: VMExtension version: $templateextPublisher\$templateextType\$templateextVersion not found in $supportedVersions."
872+
$msg = "Warning: VMExtension version ($templateextPublisher\$templateextType\$templateextVersion) not found in supported versions ($supportedVersions)."
862873
Write-Warning $msg
863874
$resourceOutput += $msg
864875
}
@@ -1130,4 +1141,4 @@ function ValidateResource
11301141
}
11311142
}
11321143
return $resourceOutput
1133-
}
1144+
}

0 commit comments

Comments
 (0)