Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .azuredevops/pipelineTemplates/module.jobs.validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,19 @@ jobs:
ScriptType: InlineScript
pwsh: true
inline: |
$moduleFolderPaths = @(Join-Path '$(moduleRepoRoot)' '${{ parameters.modulePath }}')
$moduleFolderPaths += (Get-ChildItem $moduleFolderPaths -Recurse -Directory -Force).FullName | Where-Object {
(Get-ChildItem $_ -File -Depth 0 -Include @('deploy.json', 'deploy.bicep') -Force).Count -gt 0
}
Write-Verbose "Execute tests in path(s):" -Verbose
foreach($moduleFolderPath in $moduleFolderPaths) {
Write-Verbose "- [($moduleFolderPath]" -Verbose
}

Invoke-Pester -Configuration @{
Run = @{
Container = New-PesterContainer -Path (Join-Path '$(moduleRepoRoot)' 'arm' '.global' 'global.module.tests.ps1') -Data @{
moduleFolderPaths = Join-Path '$(moduleRepoRoot)' '${{ parameters.modulePath }}'
moduleFolderPaths = $moduleFolderPaths
}
}
Filter = @{
Expand Down Expand Up @@ -225,10 +234,19 @@ jobs:
ScriptType: InlineScript
pwsh: true
inline: |
$moduleFolderPaths = @(Join-Path '$(moduleRepoRoot)' '${{ parameters.modulePath }}')
$moduleFolderPaths += (Get-ChildItem $moduleFolderPaths -Recurse -Directory -Force).FullName | Where-Object {
(Get-ChildItem $_ -File -Depth 0 -Include @('deploy.json', 'deploy.bicep') -Force).Count -gt 0
}
Write-Verbose "Execute tests in path(s):" -Verbose
foreach($moduleFolderPath in $moduleFolderPaths) {
Write-Verbose "- [($moduleFolderPath]" -Verbose
}

Invoke-Pester -Configuration @{
Run = @{
Container = New-PesterContainer -Path (Join-Path '$(moduleRepoRoot)' 'arm' '.global' 'global.module.tests.ps1') -Data @{
moduleFolderPaths = Join-Path '$(moduleRepoRoot)' '${{ parameters.modulePath }}'
moduleFolderPaths = $moduleFolderPaths
}
}
Filter = @{
Expand Down
24 changes: 21 additions & 3 deletions .github/actions/templates/validateModulePester/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@ runs:
- name: 'Run global tests via Pester'
shell: pwsh
run: |
$moduleFolderPaths = @(Join-Path $env:GITHUB_WORKSPACE "${{ inputs.modulePath }}")
$moduleFolderPaths += (Get-ChildItem $moduleFolderPaths -Recurse -Directory -Force).FullName | Where-Object {
(Get-ChildItem $_ -File -Depth 0 -Include @('deploy.json', 'deploy.bicep') -Force).Count -gt 0
}
Write-Verbose "Execute tests in path(s):" -Verbose
foreach($moduleFolderPath in $moduleFolderPaths) {
Write-Verbose "- [($moduleFolderPath]" -Verbose
}

# --------------------- #
# INVOKE PESTER TEST(S) #
# Invoke Pester test(s) #
# --------------------- #
Invoke-Pester -Configuration @{
Run = @{
Container = New-PesterContainer -Path 'arm/.global/global.module.tests.ps1' -Data @{
moduleFolderPaths = Join-Path $env:GITHUB_WORKSPACE "${{ inputs.modulePath }}"
moduleFolderPaths = $moduleFolderPaths
}
}
Filter = @{
Expand Down Expand Up @@ -64,13 +73,22 @@ runs:
- name: 'Run API tests via Pester'
shell: pwsh
run: |
$moduleFolderPaths = @(Join-Path $env:GITHUB_WORKSPACE "${{ inputs.modulePath }}")
$moduleFolderPaths += (Get-ChildItem $moduleFolderPaths -Recurse -Directory -Force).FullName | Where-Object {
(Get-ChildItem $_ -File -Depth 0 -Include @('deploy.json', 'deploy.bicep') -Force).Count -gt 0
}
Write-Verbose "Execute tests in path(s):" -Verbose
foreach($moduleFolderPath in $moduleFolderPaths) {
Write-Verbose "- [($moduleFolderPath]" -Verbose
}

# --------------------- #
# Invoke Pester test(s) #
# --------------------- #
Invoke-Pester -Configuration @{
Run = @{
Container = New-PesterContainer -Path 'arm/.global/global.module.tests.ps1' -Data @{
moduleFolderPaths = Join-Path $env:GITHUB_WORKSPACE "${{ inputs.modulePath }}"
moduleFolderPaths = $moduleFolderPaths
}
}
Filter = @{
Expand Down
38 changes: 23 additions & 15 deletions arm/.global/global.module.tests.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Requires -Version 7

param (
[array] $moduleFolderPaths = ((Get-ChildItem (Split-Path (Get-Location) -Parent) -Recurse -Directory -Force).FullName | Where-Object {
[array] $moduleFolderPaths = ((Get-ChildItem (Split-Path $PSScriptRoot -Parent) -Recurse -Directory -Force).FullName | Where-Object {
(Get-ChildItem $_ -File -Depth 0 -Include @('deploy.json', 'deploy.bicep') -Force).Count -gt 0
})
)
Expand Down Expand Up @@ -45,17 +45,23 @@ Describe 'File/folder tests' -Tag Modules {

It '[<moduleFolderName>] Module should contain a [.parameters] folder' -TestCases $moduleFolderTestCases {
param( [string] $moduleFolderPath )
(Test-Path (Join-Path -Path $moduleFolderPath '.parameters')) | Should -Be $true
if ((Split-Path (Split-Path $moduleFolderPath -Parent) -Leaf) -like 'Microsoft.*') {
(Test-Path (Join-Path -Path $moduleFolderPath '.parameters')) | Should -Be $true
} else {
$true | Should -Be $true
}
}
}

Context '.parameters folder' {

$folderTestCases = [System.Collections.ArrayList]@()
foreach ($moduleFolderPath in $moduleFolderPaths) {
$folderTestCases += @{
moduleFolderName = $moduleFolderPath.Replace('\', '/').Split('/arm/')[1]
moduleFolderPath = $moduleFolderPath
if (Test-Path (Join-Path $moduleFolderPath '.paramateres')) {
$folderTestCases += @{
moduleFolderName = $moduleFolderPath.Replace('\', '/').Split('/arm/')[1]
moduleFolderPath = $moduleFolderPath
}
}
}

Expand Down Expand Up @@ -402,16 +408,18 @@ Describe 'Deployment template tests' -Tag Template {
$TemplateFile_AllParameterNames = $templateFile_Parameters.Keys | Sort-Object
$TemplateFile_RequiredParametersNames = ($templateFile_Parameters.Keys | Where-Object { -not $templateFile_Parameters[$_].ContainsKey('defaultValue') }) | Sort-Object

$ParameterFilePaths = (Get-ChildItem (Join-Path -Path $moduleFolderPath -ChildPath '.parameters' -AdditionalChildPath '*parameters.json') -Recurse -Force).FullName
foreach ($ParameterFilePath in $ParameterFilePaths) {
$parameterFile_AllParameterNames = ((Get-Content $ParameterFilePath) | ConvertFrom-Json -AsHashtable).parameters.Keys | Sort-Object
$parameterFileTestCases += @{
parameterFile_Path = $ParameterFilePath
parameterFile_Name = Split-Path $ParameterFilePath -Leaf
parameterFile_AllParameterNames = $parameterFile_AllParameterNames
templateFile_AllParameterNames = $TemplateFile_AllParameterNames
templateFile_RequiredParametersNames = $TemplateFile_RequiredParametersNames
tokenSettings = $Settings.parameterFileTokens
if (Test-Path (Join-Path $moduleFolderPath '.parameters')) {
$ParameterFilePaths = (Get-ChildItem (Join-Path -Path $moduleFolderPath -ChildPath '.parameters' -AdditionalChildPath '*parameters.json') -Recurse -Force).FullName
foreach ($ParameterFilePath in $ParameterFilePaths) {
$parameterFile_AllParameterNames = ((Get-Content $ParameterFilePath) | ConvertFrom-Json -AsHashtable).parameters.Keys | Sort-Object
$parameterFileTestCases += @{
parameterFile_Path = $ParameterFilePath
parameterFile_Name = Split-Path $ParameterFilePath -Leaf
parameterFile_AllParameterNames = $parameterFile_AllParameterNames
templateFile_AllParameterNames = $TemplateFile_AllParameterNames
templateFile_RequiredParametersNames = $TemplateFile_RequiredParametersNames
tokenSettings = $Settings.parameterFileTokens
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ resource extension 'Microsoft.Compute/virtualMachineScaleSets/extensions@2021-07
output extensionName string = extension.name

@description('The ResourceId of the extension')
output extensionId string = extension.id
output extensionResourceId string = extension.id

@description('The name of the Resource Group the extension was created in.')
output extensionResourceGroup string = resourceGroup().name
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This module deploys a virtual machine scale set extension.
| `cuaId` | string | | | Optional. Customer Usage Attribution id (GUID). This GUID must be previously registered |
| `enableAutomaticUpgrade` | bool | | | Required. Indicates whether the extension should be automatically upgraded by the platform if there is a newer version of the extension available |
| `forceUpdateTag` | string | | | Optional. How the extension handler should be forced to update even if the extension configuration has not changed |
| `name` | string | | | Required. The name of the virtual machine extension |
| `name` | string | | | Required. The name of the virtual machine scale set extension |
| `protectedSettings` | secureObject | `{object}` | | Optional. Any object that contains the extension specific protected settings |
| `publisher` | string | | | Required. The name of the extension handler publisher |
| `settings` | object | `{object}` | | Optional. Any object that contains the extension specific settings |
Expand All @@ -29,9 +29,9 @@ This module deploys a virtual machine scale set extension.

| Output Name | Type | Description |
| :-- | :-- | :-- |
| `extensionId` | string | The ResourceId of the extension |
| `extensionName` | string | The name of the extension |
| `extensionResourceGroup` | string | The name of the Resource Group the extension was created in. |
| `extensionResourceId` | string | The resource ID of the extension |

## Template references

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,14 @@ var upgradeSettings = {
maxSurge: maxSurge
}

@description('Optional. Customer Usage Attribution ID (GUID). This GUID must be previously registered')
param cuaId string = ''

module pid_cuaId '.bicep/nested_cuaId.bicep' = if (!empty(cuaId)) {
name: 'pid-${cuaId}'
params: {}
}

resource managedCluster 'Microsoft.ContainerService/managedClusters@2021-08-01' existing = {
name: managedClusterName
}
Expand Down
Loading