Skip to content

Commit cc905c8

Browse files
enhancement: support separate starter module upgrade (#110)
# Pull Request ## Description This change improves the upgrade process to be able to auto upgrade the bootstrap and starter modules independently. ## License By submitting this pull request, I confirm that my contribution is made under the terms of the projects associated license.
1 parent d131152 commit cc905c8

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

src/ALZ/Private/Deploy-Accelerator-Helpers/Invoke-FullUpgrade.ps1

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,40 @@ function Invoke-FullUpgrade {
3232
if ($PSCmdlet.ShouldProcess("Upgrade Release", "Operation")) {
3333

3434
# Run upgrade for bootstrap state
35-
$wasUpgraded = Invoke-Upgrade `
35+
$bootstrapWasUpgraded = Invoke-Upgrade `
36+
-moduleType "bootstrap" `
3637
-targetDirectory $bootstrapPath `
3738
-targetFolder $bootstrapModuleFolder `
3839
-cacheFileName "terraform.tfstate" `
3940
-release $bootstrapRelease `
4041
-autoApprove:$autoApprove.IsPresent
4142

42-
if($wasUpgraded) {
43+
if($bootstrapWasUpgraded) {
4344
# Run upgrade for interface inputs
4445
Invoke-Upgrade `
4546
-targetDirectory $bootstrapPath `
4647
-cacheFileName $interfaceCacheFileName `
4748
-release $bootstrapRelease `
48-
-autoApprove:$wasUpgraded | Out-String | Write-Verbose
49+
-autoApprove:$bootstrapWasUpgraded | Out-String | Write-Verbose
4950

5051
# Run upgrade for bootstrap inputs
5152
Invoke-Upgrade `
5253
-targetDirectory $bootstrapPath `
5354
-cacheFileName $bootstrapCacheFileName `
5455
-release $bootstrapRelease `
55-
-autoApprove:$wasUpgraded | Out-String | Write-Verbose
56+
-autoApprove:$bootstrapWasUpgraded | Out-String | Write-Verbose
57+
}
5658

57-
# Run upgrade for starter
58-
Invoke-Upgrade `
59-
-targetDirectory $starterPath `
60-
-cacheFileName $starterCacheFileName `
61-
-release $starterRelease `
62-
-autoApprove:$wasUpgraded | Out-String | Write-Verbose
59+
# Run upgrade for starter
60+
$starterWasUpgraded = Invoke-Upgrade `
61+
-moduleType "starter" `
62+
-targetDirectory $starterPath `
63+
-cacheFileName $starterCacheFileName `
64+
-release $starterRelease `
65+
-autoApprove:$autoApprove.IsPresent | Out-String | Write-Verbose
6366

64-
Write-InformationColored "AUTOMATIC UPGRADE: Upgrade complete. If any starter files have been updated, you will need to remove branch protection in order for the Terraform apply to succeed." -ForegroundColor Yellow -InformationAction Continue
67+
if($starterWasUpgraded -or $bootstrapWasUpgraded) {
68+
Write-InformationColored "AUTOMATIC UPGRADE: Upgrade complete. If any starter files have been updated, you will need to remove branch protection in order for the Terraform apply to succeed." -NewLineBefore -ForegroundColor Yellow -InformationAction Continue
6569
}
6670
}
6771
}

src/ALZ/Private/Deploy-Accelerator-Helpers/Invoke-Upgrade.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
function Invoke-Upgrade {
22
[CmdletBinding(SupportsShouldProcess = $true)]
33
param (
4+
[Parameter(Mandatory = $false)]
5+
[string] $moduleType,
6+
47
[Parameter(Mandatory = $false)]
58
[string] $targetDirectory,
69

@@ -54,7 +57,7 @@ function Invoke-Upgrade {
5457
if($autoApprove) {
5558
$upgrade = "upgrade"
5659
} else {
57-
Write-InformationColored "AUTOMATIC UPGRADE: We found version $previousVersion that has been previously run. You can upgrade from this version to the new version $currentVersion" -ForegroundColor Yellow -InformationAction Continue
60+
Write-InformationColored "AUTOMATIC UPGRADE: We found version $previousVersion of the $moduleType module that has been previously run. You can upgrade from this version to the new version $currentVersion" -NewLineBefore -ForegroundColor Yellow -InformationAction Continue
5861
$upgrade = Read-Host "If you would like to upgrade, enter 'upgrade' or just hit 'enter' to continue with a new environment. (upgrade/exit)"
5962
}
6063

src/ALZ/Private/Deploy-Accelerator-Helpers/New-Bootstrap.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,8 @@ function New-Bootstrap {
5454
$bootstrapCacheFileName = "bootstrap-cache.json"
5555
$starterCacheFileName = "starter-cache.json"
5656
$interfaceCachePath = Join-Path -Path $bootstrapPath -ChildPath $interfaceCacheFileName
57-
$interfaceCachedConfig = Get-ALZConfig -configFilePath $interfaceCachePath
5857
$bootstrapCachePath = Join-Path -Path $bootstrapPath -ChildPath $bootstrapCacheFileName
59-
$bootstrapCachedConfig = Get-ALZConfig -configFilePath $bootstrapCachePath
6058
$starterCachePath = Join-Path -Path $starterPath -ChildPath $starterCacheFileName
61-
$starterCachedConfig = Get-ALZConfig -configFilePath $starterCachePath
62-
6359
$bootstrapModulePath = Join-Path -Path $bootstrapPath -ChildPath $bootstrapDetails.Value.location
6460

6561
Write-Verbose "Bootstrap Module Path: $bootstrapModulePath"
@@ -76,6 +72,11 @@ function New-Bootstrap {
7672
-starterCacheFileName $starterCacheFileName `
7773
-autoApprove:$autoApprove.IsPresent
7874

75+
# Get cached inputs
76+
$interfaceCachedConfig = Get-ALZConfig -configFilePath $interfaceCachePath
77+
$bootstrapCachedConfig = Get-ALZConfig -configFilePath $bootstrapCachePath
78+
$starterCachedConfig = Get-ALZConfig -configFilePath $starterCachePath
79+
7980
# Get starter module
8081
$starter = ""
8182
$starterModulePath = ""

0 commit comments

Comments
 (0)