Skip to content

Commit

Permalink
Save changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredfholgate committed Nov 18, 2024
1 parent f97cee1 commit b9ee27a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function Convert-ParametersToInputConfig {
Write-Verbose "Alias $parameterAlias exists in input config, renaming..."
$configItem = $inputConfig.PSObject.Properties | Where-Object { $_.Name -eq $parameterAlias }
$inputConfig | Add-Member -NotePropertyName $parameterKey -NotePropertyValue @{
Value = $configItem.Value
Source = "parameter"
Value = $configItem.Value.Value
Source = $configItem.Value.Source
}
$inputConfig.PSObject.Properties.Remove($configItem.Name)
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ function Remove-TerraformMetaFileSet {
"terraform.tfvars",
".terraform.lock.hcl",
"examples",
"yaml.tf"
"yaml.tf",
".alzlib"
),
[Parameter(Mandatory = $false)]
[switch]$writeVerboseLogs
Expand Down
2 changes: 1 addition & 1 deletion src/ALZ/Private/Config-Helpers/Request-SpecialInput.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function Request-SpecialInput {
}

if($type -eq "starter") {
foreach($starter in $starterConfig.starter_modules.PsObject.Properties) {
foreach($starter in $starterConfig.starter_modules.Value.PsObject.Properties) {
if($starter.Name -eq $starterPipelineFolder) {
continue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Get-BootstrapAndStarterConfig {
$bootstrapConfigFullPath = Join-Path $bootstrapPath $bootstrapConfigPath
Write-Verbose "Bootstrap config path $bootstrapConfigFullPath"
$bootstrapConfig = Get-ALZConfig -configFilePath $bootstrapConfigFullPath
$validationConfig = $bootstrapConfig.validators
$validationConfig = $bootstrapConfig.validators.Value

# Get the supported regions and availability zones
Write-Verbose "Getting Supported Regions and Availability Zones with Terraform"
Expand All @@ -40,7 +40,7 @@ function Get-BootstrapAndStarterConfig {
$azureLocationValidator.AllowedValues.Values = $regionsAndZones.supportedRegions

# Get the available bootstrap modules
$bootstrapModules = $bootstrapConfig.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 }
Expand All @@ -55,9 +55,9 @@ function Get-BootstrapAndStarterConfig {
if($null -ne $bootstrapStarterModule) {
# If the bootstrap has starter modules, get the details and url
$hasStarterModule = $true
$starterModules = $bootstrapConfig.PSObject.Properties | Where-Object { $_.Name -eq "starter_modules" }
$starterModules = $bootstrapConfig.starter_modules.Value
$starterModuleType = $bootstrapStarterModule.Value
$starterModuleDetails = $starterModules.Value.PSObject.Properties | Where-Object { $_.Name -eq $starterModuleType }
$starterModuleDetails = $starterModules.PSObject.Properties | Where-Object { $_.Name -eq $starterModuleType }
if($null -eq $starterModuleDetails) {
Write-InformationColored "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..." -ForegroundColor Red -InformationAction Continue
throw
Expand Down
12 changes: 6 additions & 6 deletions src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function New-Bootstrap {
}
}

$chosenStarterConfig = $starterConfig.starter_modules.$($inputConfig.starter_module_name.Value)
$chosenStarterConfig = $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value)

Write-Verbose "Selected Starter: $($inputConfig.starter_module_name.Value))"
$starterModulePath = (Resolve-Path (Join-Path -Path $starterPath -ChildPath $chosenStarterConfig.location)).Path
Expand Down Expand Up @@ -140,7 +140,7 @@ function New-Bootstrap {
}

if($iac -eq "bicep") {
$starterParameters = Convert-BicepConfigToInputConfig -bicepConfig $starterConfig.starter_modules.$($inputConfig.starter_module_name.Value) -validators $validationConfig
$starterParameters = Convert-BicepConfigToInputConfig -bicepConfig $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value) -validators $validationConfig
}
}

Expand Down Expand Up @@ -229,22 +229,22 @@ function New-Bootstrap {
}

if($iac -eq "bicep") {
Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterConfig.starter_modules.$($inputConfig.starter_module_name.Value).deployment_files
Copy-ParametersFileCollection -starterPath $starterModulePath -configFiles $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files
Set-ComputedConfiguration -configuration $starterConfiguration
Edit-ALZConfigurationFilesInPlace -alzEnvironmentDestination $starterModulePath -configuration $starterConfiguration
Write-JsonFile -jsonFilePath $starterBicepVarsPath -configuration $starterConfiguration

# Remove unrequired files
$foldersOrFilesToRetain = $starterConfig.starter_modules.$($inputConfig.starter_module_name.Value).folders_or_files_to_retain
$foldersOrFilesToRetain = $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).folders_or_files_to_retain
$foldersOrFilesToRetain += "parameters.json"
$foldersOrFilesToRetain += "config"
$foldersOrFilesToRetain += "starter-cache.json"

foreach($deployment_file in $starterConfig.starter_modules.$($inputConfig.starter_module_name.Value).deployment_files) {
foreach($deployment_file in $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).deployment_files) {
$foldersOrFilesToRetain += $deployment_file.templateParametersSourceFilePath
}

$subFoldersOrFilesToRemove = $starterConfig.starter_modules.$($inputConfig.starter_module_name.Value).subfolders_or_files_to_remove
$subFoldersOrFilesToRemove = $starterConfig.starter_modules.Value.$($inputConfig.starter_module_name.Value).subfolders_or_files_to_remove

Remove-UnrequiredFileSet -path $starterModulePath -foldersOrFilesToRetain $foldersOrFilesToRetain -subFoldersOrFilesToRemove $subFoldersOrFilesToRemove -writeVerboseLogs:$writeVerboseLogs.IsPresent
}
Expand Down

0 comments on commit b9ee27a

Please sign in to comment.