-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathGet-BootstrapAndStarterConfig.ps1
More file actions
70 lines (60 loc) · 3.3 KB
/
Get-BootstrapAndStarterConfig.ps1
File metadata and controls
70 lines (60 loc) · 3.3 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function Get-BootstrapAndStarterConfig {
[CmdletBinding(SupportsShouldProcess = $true)]
param(
[Parameter(Mandatory = $false)]
[string]$iac,
[Parameter(Mandatory = $false)]
[string]$bootstrap,
[Parameter(Mandatory = $false)]
[string]$bootstrapPath,
[Parameter(Mandatory = $false)]
[string]$bootstrapConfigPath,
[Parameter(Mandatory = $false)]
[string]$toolsPath
)
if ($PSCmdlet.ShouldProcess("Get Configuration for Bootstrap and Starter", "modify")) {
$hasStarterModule = $false
$starterModuleUrl = ""
$starterModuleSourceFolder = ""
$starterReleaseArtifactName = ""
$starterConfigFilePath = ""
$bootstrapDetails = $null
# Get the bootstrap configuration
$bootstrapConfigFullPath = Join-Path $bootstrapPath $bootstrapConfigPath
Write-Verbose "Bootstrap config path $bootstrapConfigFullPath"
$bootstrapConfig = Get-ALZConfig -configFilePath $bootstrapConfigFullPath
# Get the available bootstrap modules
$bootstrapModules = $bootstrapConfig.bootstrap_modules.Value
# Get the bootstrap details and validate it exists (use alias for legacy values)
$bootstrapDetails = $bootstrapModules.PsObject.Properties | Where-Object { $_.Name -eq $bootstrap -or $bootstrap -in $_.Value.aliases }
if($null -eq $bootstrapDetails) {
Write-ToConsoleLog "The bootstrap type '$bootstrap' that you have selected does not exist. Please try again with a valid bootstrap type..." -IsError
throw
}
# Get the starter modules for the selected bootstrap if it has any
$bootstrapStarterModule = $bootstrapDetails.Value.PSObject.Properties | Where-Object { $_.Name -eq "starter_modules" }
if($null -ne $bootstrapStarterModule) {
# If the bootstrap has starter modules, get the details and url
$hasStarterModule = $true
$starterModules = $bootstrapConfig.starter_modules.Value
$starterModuleType = $bootstrapStarterModule.Value
$starterModuleDetails = $starterModules.PSObject.Properties | Where-Object { $_.Name -eq $starterModuleType }
if($null -eq $starterModuleDetails) {
Write-ToConsoleLog "The starter modules '$($starterModuleType)' for the bootstrap type '$bootstrap' that you have selected does not exist. This could be an issue with your custom configuration, please check and try again..." -IsError
throw
}
$starterModuleUrl = $starterModuleDetails.Value.$iac.url
$starterModuleSourceFolder = $starterModuleDetails.Value.$iac.release_artifact_root_path
$starterReleaseArtifactName = $starterModuleDetails.Value.$iac.release_artifact_name
$starterConfigFilePath = $starterModuleDetails.Value.$iac.release_artifact_config_file
}
return @{
bootstrapDetails = $bootstrapDetails
hasStarterModule = $hasStarterModule
starterModuleUrl = $starterModuleUrl
starterModuleSourceFolder = $starterModuleSourceFolder
starterReleaseArtifactName = $starterReleaseArtifactName
starterConfigFilePath = $starterConfigFilePath
}
}
}