Skip to content

Commit d12c1b6

Browse files
authored
Add step to conditionally create cicd directories (#65)
# Pull Request ## Description Description of changes: Currently, both CICD directories are created irrespective of user input. This PR adds condition to only create specific CICD directory that user specifies during New-ALZEnvironment cmdlet. ## License By submitting this pull request, I confirm that my contribution is made under the terms of the projects associated license.
1 parent 0ff188d commit d12c1b6

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/ALZ/Private/New-ALZDirectoryEnvironment.ps1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ function New-ALZDirectoryEnvironment {
55
[Alias("Output")]
66
[Alias("OutputDirectory")]
77
[Alias("O")]
8-
[string] $alzEnvironmentDestination
8+
[string] $alzEnvironmentDestination,
9+
[string] $alzCicdDestination
910
)
1011
# Create destination file structure
1112
$gitHubPipeline = Join-Path $alzEnvironmentDestination ".github" "workflows"
@@ -15,8 +16,8 @@ function New-ALZDirectoryEnvironment {
1516
$upstream = Join-Path $alzEnvironmentDestination "upstream-releases"
1617

1718
New-Item -ItemType Directory -Path $alzEnvironmentDestination -Force | Out-String | Write-Verbose
18-
New-Item -ItemType Directory -Path $gitHubPipeline -Force | Out-String | Write-Verbose
19-
New-Item -ItemType Directory -Path $azureDevOpsPipeline -Force | Out-String | Write-Verbose
19+
$cicd = if ($alzCicdDestination -eq "github") { $gitHubPipeline } else { $azureDevOpsPipeline }
20+
New-Item -ItemType Directory -Path $cicd -Force | Out-String | Write-Verbose
2021
New-Item -ItemType Directory -Path $config -Force | Out-String | Write-Verbose
2122
New-Item -ItemType Directory -Path $upstream -Force | Out-String | Write-Verbose
2223
New-Item -ItemType Directory -Path $configModules -Force | Out-String | Write-Verbose

src/ALZ/Public/New-ALZEnvironment.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function New-ALZEnvironment {
5454

5555
$bicepConfig = Get-ALZBicepConfig -alzBicepVersion $alzBicepVersion
5656

57-
New-ALZDirectoryEnvironment -alzEnvironmentDestination $alzEnvironmentDestination | Out-String | Write-Verbose
57+
New-ALZDirectoryEnvironment -alzEnvironmentDestination $alzEnvironmentDestination -alzCicdDestination $alzCicdPlatform | Out-String | Write-Verbose
5858

5959
$alzEnvironmentDestinationInternalCode = Join-Path $alzEnvironmentDestination "upstream-releases"
6060

src/Tests/Unit/Private/New-ALZDirectoryEnvironment.Tests.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ InModuleScope 'ALZ' {
2727
New-ALZDirectoryEnvironment -OutputDirectory $basePath
2828
Should -Invoke -CommandName New-Item -ParameterFilter { $Path -eq './config' }
2929
Should -Invoke -CommandName New-Item -ParameterFilter { $Path -eq $(Join-Path $basePath 'upstream-releases') } -Exactly 1
30-
Should -Invoke -CommandName New-Item -ParameterFilter { $Path -eq $(Join-Path $basePath '.github' 'workflows') } -Exactly 1
31-
Should -Invoke -CommandName New-Item -ParameterFilter { $Path -eq $(Join-Path $basePath '.azuredevops' 'pipelines') } -Exactly 1
30+
Should -Invoke -CommandName New-Item -ParameterFilter { $Path -eq $(Join-Path $basePath '.github' 'workflows') -or $Path -eq $(Join-Path $basePath '.azuredevops' 'pipelines') } -Exactly 1
3231
Should -Invoke -CommandName New-Item -ParameterFilter { $Path -eq $(Join-Path $basePath 'config') } -Exactly 1
3332
}
3433
}

0 commit comments

Comments
 (0)