Skip to content

Commit

Permalink
Fix local override folder function (#106)
Browse files Browse the repository at this point in the history
# Pull Request

## Description

This is a bug fix for the override folder parameters. These are only
required for e2e testing or customisation.

## License

By submitting this pull request, I confirm that my contribution is made
under the terms of the projects associated license.
  • Loading branch information
jaredfholgate authored Mar 14, 2024
1 parent 6728899 commit e6d3bf0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
27 changes: 24 additions & 3 deletions src/ALZ/Private/New-FolderStructure.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,38 @@ function New-FolderStructure {
[string] $targetFolder,

[Parameter(Mandatory = $false)]
[string] $sourceFolder
[string] $sourceFolder,

[Parameter(Mandatory = $false)]
[string] $overrideSourceDirectoryPath = ""
)

if ($PSCmdlet.ShouldProcess("ALZ-Terraform module configuration", "modify")) {
Write-Verbose "Downloading modules to $targetDirectory"

if(!($release.StartsWith("v")) -and ($release -ne "latest")) {
$release = "v$release"
}

$releaseTag = Get-GithubRelease -githubRepoUrl $url -targetDirectory $targetDirectory -moduleSourceFolder $sourceFolder -moduleTargetFolder $targetFolder -release $release
$path = Join-Path $targetDirectory $targetFolder $releaseTag
$releaseTag = ""
$path = ""

if($overrideSourceDirectoryPath -ne "") {
$releaseTag = "local"
$path = Join-Path $targetDirectory $targetFolder $releaseTag

if(Test-Path $path) {
Write-Verbose "Folder $path already exists, so not copying files."
} else {
Write-InformationColored "Copying files from $overrideSourceDirectoryPath to $path" -ForegroundColor Green -InformationAction Continue
New-Item -Path $path -ItemType "Directory"
Copy-Item -Path "$overrideSourceDirectoryPath/$sourceFolder/*" -Destination "$path" -Recurse | Out-String | Write-Verbose
}

} else {
$releaseTag = Get-GithubRelease -githubRepoUrl $url -targetDirectory $targetDirectory -moduleSourceFolder $sourceFolder -moduleTargetFolder $targetFolder -release $release
$path = Join-Path $targetDirectory $targetFolder $releaseTag
}

Write-Verbose "Version $releaseTag is located in $path"

Expand Down
18 changes: 10 additions & 8 deletions src/ALZ/Public/New-ALZEnvironment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ function New-ALZEnvironment {
}

# Download the bootstrap modules
$bootstrapReleaseTag = "local"
$bootstrapPath = $bootstrapModuleOverrideFolderPath
$bootstrapReleaseTag = ""
$bootstrapPath = ""
$bootstrapTargetFolder = "bootstrap"

if($bootstrapModuleOverrideFolderPath -eq "" -and !$isLegacyBicep) {
if(!$isLegacyBicep) {
$versionAndPath = $null

Write-InformationColored "Checking and Downloading the bootstrap module..." -ForegroundColor Green -NewLineBefore -InformationAction Continue
Expand All @@ -159,7 +159,8 @@ function New-ALZEnvironment {
-url $bootstrapModuleUrl `
-release $bootstrapRelease `
-targetFolder $bootstrapTargetFolder `
-sourceFolder $bootstrapSourceFolder
-sourceFolder $bootstrapSourceFolder `
-overrideSourceDirectoryPath $bootstrapModuleOverrideFolderPath
}
$bootstrapReleaseTag = $versionAndPath.releaseTag
$bootstrapPath = $versionAndPath.path
Expand Down Expand Up @@ -234,10 +235,10 @@ function New-ALZEnvironment {
}

# Download the starter modules
$starterReleaseTag = "local"
$starterPath = $starterModuleOverrideFolderPath
$starterReleaseTag = ""
$starterPath = ""

if($starterModuleOverrideFolderPath -eq "" -and ($hasStarterModule -or $isLegacyBicep)) {
if(($hasStarterModule -or $isLegacyBicep)) {
$versionAndPath = $null

Write-InformationColored "Checking and Downloading the starter module..." -ForegroundColor Green -NewLineBefore -InformationAction Continue
Expand All @@ -250,7 +251,8 @@ function New-ALZEnvironment {
-url $starterModuleUrl `
-release $starterRelease `
-targetFolder $starterModuleTargetFolder `
-sourceFolder $starterModuleSourceFolder
-sourceFolder $starterModuleSourceFolder `
-overrideSourceDirectoryPath $starterModuleOverrideFolderPath
}

$starterReleaseTag = $versionAndPath.releaseTag
Expand Down

0 comments on commit e6d3bf0

Please sign in to comment.