-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate_infra.ps1
29 lines (23 loc) · 1014 Bytes
/
validate_infra.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Get input from pipeline step
param (
[Parameter(Mandatory)][string]$Cloud="Azure"
)
# Install the Pester module from PowerShell Gallery
Install-Module -Name Pester -Scope CurrentUser -Force
# Read the project config file
$jsonPath = ".\" + $Cloud.ToLower() + '\config.json'
$config = Get-Content -Path $jsonPath | ConvertFrom-Json
# Adjust for differernt Cloud vendors
$SubscriptionName = $config.SubscriptionName
$ResourceName = $config.$ResourceName
$ResourceLocation = $config.$ResourceLocation
$EnvironmentName = $config.EnvironmentName
$ProjectName = $config.ProjectName
$ResourceTags = @{
EnvironmentName = $EnvironmentName
ProjectName = $ProjectName
}
# For each test in the profile, invoke the pester tests
Write-Output "Running on $Cloud using Subscription $SubscriptionName under the $EnvironmentName environment for the $ProjectName Project"
# Example (base it on Cloud value)
Invoke-Pester -Script $Cloud\rg.Tests.ps1 $SubscriptionName $ResourceName $ResourceLocation $ResourceTags