Skip to content

Commit 8313d67

Browse files
Fixing subscription values (#34)
# Pull Request ## Issue Fixes #33 Fixes #32 ## Description Changes to ensure that subscription ids persist as an array when only one value remains. Handling case insensitive deduplication of subscription ids. Fixes a part of the ReadMe.md (probably more work required, but fixing a small part of that document) ## License By submitting this pull request, I confirm that my contribution is made under the terms of the projects associated license.
1 parent 48b0965 commit 8313d67

File tree

4 files changed

+121
-22
lines changed

4 files changed

+121
-22
lines changed

README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66

77
## Synopsis
88

9-
This is a PowerShell module that provides a set of cmdlets to manage Azure Landing Zones.
9+
This is a PowerShell module that provides a set of cmdlets to create and manage Azure Landing Zones.
1010

1111
## Description
1212

13-
This module provides a set of cmdlets to manage Azure Landing Zones.
13+
This module provides a set of cmdlets to create and manage Azure Landing Zones.
1414

1515
## Why
1616

17-
The goal of this project it is to make easy to get started with Azure Landing Zones and to speed up some basic tasks that you would be using while managing your Azure Landing Zones.
17+
The goal of this project it is to make easy to get started with Azure Landing Zones and to speed up some basic tasks that you would need to perform whilst managing your Azure Landing Zones.
1818

1919
## Getting Started
2020

2121
### Prerequisites
2222

23-
In order to use this module you will need powershell 7.1 or higher.
23+
In order to use this module you will need PowerShell 7.1 or higher.
2424

2525
### Installation
2626

@@ -32,24 +32,31 @@ Install-Module -Name ALZ
3232

3333
### Quick start
3434

35-
Before start o utilize the functionality of the module you can verify if you have all the prerequisites installed, with the built in command:
35+
Before you start you can utilize the functionality of the module to verify if you have all the prerequisites installed with the built in command:
3636

3737
```powershell
38-
Test-ALZPrerequisites
38+
Test-ALZRequirement
3939
```
4040

41-
#### Create a new Azure Landing Zone Environment
41+
Currently this tests for:
4242

43-
```powershell
43+
* Supported minimum PowerShell version
44+
* Azure PowerShell Module
45+
* Git
46+
* Azure CLI
47+
* Bicep
4448

49+
#### Create a new Azure Landing Zone Environment
4550

51+
```powershell
52+
New-ALZEnvironment -o <output_directory>
4653
```
4754

4855
## Development
4956

50-
### Prerequisites
57+
### Development Prerequisites
5158

52-
In order to develop this module you will need powershell 7.1 or higher.
59+
In order to develop this module you will need PowerShell 7.1 or higher.
5360

5461
### Commands to install a build locally
5562

@@ -61,22 +68,16 @@ Import-Module .\src\Artifacts\ALZ.psd1 -Force
6168

6269
## Contributing
6370

64-
This project welcomes contributions and suggestions. Most contributions require you to agree to a
65-
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
71+
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
6672
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
6773

68-
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
69-
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
70-
provided by the bot. You will only need to do this once across all repos using our CLA.
74+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
7175

7276
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
73-
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
74-
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
77+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
7578

7679
## Trademarks
7780

78-
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
79-
trademarks or logos is subject to and must follow
80-
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
81+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
8182
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
82-
Any use of third-party trademarks or logos are subject to those third-party's policies.
83+
Any use of third-party trademarks or logos are subject to those third-party's policies.

src/ALZ/Assets/alz-bicep-config/v0.14.1-pre.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
340340
},
341341
"AllSubscriptionIds": {
342342
"Type": "Computed",
343-
"Process": "@($args | Select-Object -Unique)",
343+
"Process": "@($args | ForEach-Object { $_.ToLower() } | Select-Object -Unique)",
344344
"Value": [
345345
"{%ManagementSubscriptionId%}",
346346
"{%ConnectivitySubscriptionId%}",

src/ALZ/Private/Edit-ALZConfigurationFilesInPlace.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function Edit-ALZConfigurationFilesInPlace {
7171
if ($null -ne $configKey.Value.Process) {
7272
$scriptBlock = [ScriptBlock]::Create($configKey.Value.Process)
7373
$formattedValues = Invoke-Command -ScriptBlock $scriptBlock -ArgumentList $formattedValues
74+
$formattedValues = @($formattedValues)
7475
}
7576

7677
$bicepConfigNode[$leafPropertyName] = $formattedValues

src/Tests/Unit/Private/Edit-ALZConfigurationFilesInPlace.Tests.ps1

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,103 @@ InModuleScope 'ALZ' {
531531
-Scope It
532532
}
533533

534+
It 'Computed, Processed array values replace values correctly in a case insensitive deduplication.' {
535+
$config = [pscustomobject]@{
536+
Nested = [pscustomobject]@{
537+
Type = "Computed"
538+
Description = "A Test Value"
539+
Process = '@($args | ForEach-Object { $_.ToLower() } | Select-Object -Unique)'
540+
Value = @(
541+
"A",
542+
"a",
543+
"A",
544+
"a"
545+
)
546+
Targets = @(
547+
[pscustomobject]@{
548+
Name = "parValue.value"
549+
Destination = "Parameters"
550+
})
551+
}
552+
}
553+
554+
$fileContent = '{
555+
"parameters": {
556+
"parValue": {
557+
"value": []
558+
}
559+
}
560+
}'
561+
562+
$expectedContent = '{
563+
"parameters": {
564+
"parValue": {
565+
"value": [ "a" ]
566+
}
567+
}
568+
}'
569+
570+
Mock -CommandName Get-Content -ParameterFilter { $Path -eq $testFile1Name } -MockWith {
571+
$fileContent
572+
}
573+
574+
$expectedContent = Format-ExpectedResult -expectedJson $expectedContent
575+
576+
Edit-ALZConfigurationFilesInPlace -alzEnvironmentDestination '.' -configuration $config
577+
578+
Should -Invoke -CommandName Out-File `
579+
-ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
580+
-Scope It
581+
}
582+
583+
It 'Computed, Processed array values replace values correctly and keep array type when only one item remains.' {
584+
$config = [pscustomobject]@{
585+
Nested = [pscustomobject]@{
586+
Type = "Computed"
587+
Description = "A Test Value"
588+
Process = '@($args | Select-Object -Unique)'
589+
Value = @(
590+
"1",
591+
"1",
592+
"1"
593+
)
594+
Targets = @(
595+
[pscustomobject]@{
596+
Name = "parValue.value"
597+
Destination = "Parameters"
598+
})
599+
}
600+
}
601+
602+
$fileContent = '{
603+
"parameters": {
604+
"parValue": {
605+
"value": []
606+
}
607+
}
608+
}'
609+
610+
$expectedContent = '{
611+
"parameters": {
612+
"parValue": {
613+
"value": [ "1" ]
614+
}
615+
}
616+
}'
617+
618+
Mock -CommandName Get-Content -ParameterFilter { $Path -eq $testFile1Name } -MockWith {
619+
$fileContent
620+
}
621+
622+
$expectedContent = Format-ExpectedResult -expectedJson $expectedContent
623+
624+
Edit-ALZConfigurationFilesInPlace -alzEnvironmentDestination '.' -configuration $config
625+
626+
Should -Invoke -CommandName Out-File `
627+
-ParameterFilter { $FilePath -eq $testFile1Name -and $InputObject -eq $expectedContent } `
628+
-Scope It
629+
}
630+
534631
It 'Computed, Processed values replace values correctly' {
535632
$config = [pscustomobject]@{
536633
Nested = [pscustomobject]@{

0 commit comments

Comments
 (0)