Skip to content

Commit fe2efdb

Browse files
AlexanderSehreriqua
authored andcommitted
fix: Added -Culture 'en-US' to all Sort-Object operations (Azure#1976)
## Description - Added `-Culture 'en-US'` to all `Sort-Object` operations to mitigate issues some contributors with a different configured culture have - Re-ran the generation for all files (no changes) Related to Azure/ResourceModules#3722, but needs to be fixed there seperately ## Type of Change <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] Update to CI Environment or utlities (Non-module effecting changes) - [ ] Azure Verified Module updates: - [ ] Bugfix containing backwards compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in `version.json`: - [ ] Someone has opened a bug report issue, and I have included "Closes #{bug_report_issue_number}" in the PR description. - [ ] The bug was found by the module author, and no one has opened an issue to report it yet. - [ ] Feature update backwards compatible feature updates, and I have bumped the MINOR version in `version.json`. - [ ] Breaking changes and I have bumped the MAJOR version in `version.json`. - [ ] Update to documentation --------- Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com>
1 parent 2d3f76e commit fe2efdb

19 files changed

+48
-48
lines changed

avm/res/compute/virtual-machine/tests/unit/avm.core.team.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BeforeAll {
1717
. (Join-Path $RepoRootPath 'avm' 'utilities' 'pipelines' 'sharedScripts' 'helper' 'Get-IsParameterRequired.ps1')
1818

1919
if ($moduleFolderPaths.Count -gt 1) {
20-
$topLevelModuleTemplatePath = $moduleFolderPaths | Sort-Object | Select-Object -First 1
20+
$topLevelModuleTemplatePath = $moduleFolderPaths | Sort-Object -Culture 'en-US' | Select-Object -First 1
2121
} else {
2222
$topLevelModuleTemplatePath = $moduleFolderPaths
2323
}

avm/res/network/nat-gateway/tests/unit/avm.core.team.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BeforeAll {
1717
. (Join-Path $RepoRootPath 'avm' 'utilities' 'pipelines' 'sharedScripts' 'helper' 'Get-IsParameterRequired.ps1')
1818

1919
if ($moduleFolderPaths.Count -gt 1) {
20-
$topLevelModuleTemplatePath = $moduleFolderPaths | Sort-Object | Select-Object -First 1
20+
$topLevelModuleTemplatePath = $moduleFolderPaths | Sort-Object -Culture 'en-US' | Select-Object -First 1
2121
} else {
2222
$topLevelModuleTemplatePath = $moduleFolderPaths
2323
}

avm/utilities/pipelines/e2eValidation/resourceRemoval/Initialize-DeploymentRemoval.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ function Initialize-DeploymentRemoval {
134134
if ($PurgeTestResources) {
135135
# Resources
136136
$filteredResourceIds = (Get-AzResource).ResourceId | Where-Object { $_ -like '*dep-*' }
137-
$ResourceIds += ($filteredResourceIds | Sort-Object -Unique)
137+
$ResourceIds += ($filteredResourceIds | Sort-Object -Culture 'en-US' -Unique)
138138

139139
# Resource groups
140140
$filteredResourceGroupIds = (Get-AzResourceGroup).ResourceId | Where-Object { $_ -like '*dep-*' }
141-
$ResourceIds += ($filteredResourceGroupIds | Sort-Object -Unique)
141+
$ResourceIds += ($filteredResourceGroupIds | Sort-Object -Culture 'en-US' -Unique)
142142
}
143143

144144
# Invoke removal

avm/utilities/pipelines/e2eValidation/resourceRemoval/helper/Get-ResourceIdsAsFormattedObjectList.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function Get-ResourceIdsAsFormattedObjectList {
7878
$allResourceGroupResources = Get-AzResource -ResourceGroupName $resourceGroupName -Name '*'
7979
}
8080
$expandedResources = $allResourceGroupResources | Where-Object { $_.ResourceId.startswith($resourceId) }
81-
$expandedResources = $expandedResources | Sort-Object -Descending -Property { $_.ResourceId.Split('/').Count }
81+
$expandedResources = $expandedResources | Sort-Object -Culture 'en-US' -Descending -Property { $_.ResourceId.Split('/').Count }
8282
foreach ($resource in $expandedResources) {
8383
$formattedResources += @{
8484
resourceId = $resource.ResourceId

avm/utilities/pipelines/e2eValidation/resourceRemoval/helper/Remove-Deployment.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function Remove-Deployment {
116116

117117
# Pre-Filter & order items
118118
# ========================
119-
$rawTargetResourceIdsToRemove = $deployedTargetResources | Sort-Object -Property { $_.Split('/').Count } -Descending | Select-Object -Unique
119+
$rawTargetResourceIdsToRemove = $deployedTargetResources | Sort-Object -Culture 'en-US' -Property { $_.Split('/').Count } -Descending | Select-Object -Unique
120120
Write-Verbose ('Total number of deployment target resources after pre-filtering (duplicates) & ordering items [{0}]' -f $rawTargetResourceIdsToRemove.Count) -Verbose
121121

122122
# Format items

avm/utilities/pipelines/platform/Invoke-AvmJsonModuleIndexGeneration.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function Invoke-AvmJsonModuleIndexGeneration {
9898
Write-Error "Error message: $($_.Exception.Message)"
9999
continue
100100
}
101-
$tags = $tagListResponse.tags | Sort-Object
101+
$tags = $tagListResponse.tags | Sort-Object -Culture 'en-US'
102102

103103
$properties = [ordered]@{}
104104
foreach ($tag in $tags) {
@@ -190,7 +190,7 @@ function Invoke-AvmJsonModuleIndexGeneration {
190190
} else {
191191
# If the module exists, merge the tags and properties
192192
$mergedModule = $initialMergeOfJsonFilesData[$module.moduleName]
193-
$mergedModule.tags = @(($mergedModule.tags + $module.tags) | Sort-Object -Unique)
193+
$mergedModule.tags = @(($mergedModule.tags + $module.tags) | Sort-Object -Culture 'en-US' -Unique)
194194

195195
# Merge properties
196196
foreach ($property in $module.properties.PSObject.Properties) {
@@ -205,7 +205,7 @@ function Invoke-AvmJsonModuleIndexGeneration {
205205
$mergedModuleIndexData = $initialMergeOfJsonFilesData.Values
206206

207207
# Sort the modules by their names
208-
$sortedMergedModuleIndexData = $mergedModuleIndexData | Sort-Object moduleName
208+
$sortedMergedModuleIndexData = $mergedModuleIndexData | Sort-Object -Culture 'en-US' -Property 'moduleName'
209209

210210
Write-Verbose "Convert mergedModuleIndexData variable to JSON and save as 'moduleIndex.json'" -Verbose
211211
$sortedMergedModuleIndexData | ConvertTo-Json -Depth 10 | Out-File -FilePath $moduleIndexJsonFilePath

avm/utilities/pipelines/publish/helper/Get-ModulesToPublish.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function Get-TemplateFileToPublish {
102102

103103
$TemplateFilesToPublish = $relevantPaths | ForEach-Object {
104104
Find-TemplateFile -Path $_ -Verbose
105-
} | Sort-Object -Unique -Descending
105+
} | Sort-Object -Culture 'en-US' -Unique -Descending
106106

107107
if ($TemplateFilesToPublish.Count -eq 0) {
108108
Write-Verbose 'No template file found in the modified module.' -Verbose

avm/utilities/pipelines/sharedScripts/Add-YamlListToFile.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function Add-YamlListToFile {
6969
throw "No key-value pairs found in List: $ListName"
7070
}
7171
# Process key value pairs in the list
72-
foreach ($Key in ($KeyValuePair.Keys.split(' ') | Sort-Object)) {
72+
foreach ($Key in ($KeyValuePair.Keys.split(' ') | Sort-Object -Culture 'en-US')) {
7373
Write-Verbose ('Setting environment variable [{0}] with value [{1}]' -f $Key, $KeyValuePair[$Key]) -Verbose
7474
Write-Output "$Key=$($KeyValuePair[$Key])" | Out-File -FilePath $OutputFilePath -Encoding 'utf-8' -Append
7575
}

avm/utilities/pipelines/sharedScripts/Set-EnvironmentOnAgent.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function Install-CustomModule {
6363
$alreadyInstalled = $alreadyInstalled | Where-Object { $_.Version -eq $Module.Version }
6464
} else {
6565
# Get latest in case of multiple
66-
$alreadyInstalled = ($alreadyInstalled | Sort-Object -Property Version -Descending)[0]
66+
$alreadyInstalled = ($alreadyInstalled | Sort-Object -Culture 'en-US' -Property 'Version' -Descending)[0]
6767
}
6868
Write-Verbose ('Module [{0}] already installed with version [{1}]' -f $alreadyInstalled.Name, $alreadyInstalled.Version) -Verbose
6969
continue

avm/utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function Set-ResourceTypesSection {
9595

9696
$RelevantResourceTypeObjects = Get-NestedResourceList $TemplateFileContent | Where-Object {
9797
$_.type -notin $ResourceTypesToExclude -and $_
98-
} | Select-Object 'Type', 'ApiVersion' -Unique | Sort-Object Type -Culture 'en-US'
98+
} | Select-Object 'Type', 'ApiVersion' -Unique | Sort-Object -Culture 'en-US' -Property 'Type'
9999

100100
$ProgressPreference = 'SilentlyContinue'
101101
$VerbosePreference = 'SilentlyContinue'
@@ -277,9 +277,9 @@ function Set-DefinitionSection {
277277
# Filter to relevant items
278278
if (-not $Properties) {
279279
# Top-level invocation
280-
[array] $categoryParameters = $TemplateFileContent.parameters.Values | Where-Object { $_.metadata.description -like "$category. *" } | Sort-Object -Property 'Name' -Culture 'en-US'
280+
[array] $categoryParameters = $TemplateFileContent.parameters.Values | Where-Object { $_.metadata.description -like "$category. *" } | Sort-Object -Culture 'en-US' -Property 'Name'
281281
} else {
282-
$categoryParameters = $Properties.Values | Where-Object { $_.metadata.description -like "$category. *" } | Sort-Object -Property 'Name' -Culture 'en-US'
282+
$categoryParameters = $Properties.Values | Where-Object { $_.metadata.description -like "$category. *" } | Sort-Object -Culture 'en-US' -Property 'Name'
283283
}
284284

285285
$tableSectionContent += @(
@@ -657,13 +657,13 @@ function Set-CrossReferencesSection {
657657
$dependencies = $CrossReferencedModuleList[$FullModuleIdentifier]
658658

659659
if ($dependencies.Keys -contains 'localPathReferences' -and $dependencies['localPathReferences']) {
660-
foreach ($reference in ($dependencies['localPathReferences'] | Sort-Object)) {
660+
foreach ($reference in ($dependencies['localPathReferences'] | Sort-Object -Culture 'en-US')) {
661661
$SectionContent += ("| ``{0}`` | {1} |" -f $reference, 'Local reference')
662662
}
663663
}
664664

665665
if ($dependencies.Keys -contains 'remoteReferences' -and $dependencies['remoteReferences']) {
666-
foreach ($reference in ($dependencies['remoteReferences'] | Sort-Object)) {
666+
foreach ($reference in ($dependencies['remoteReferences'] | Sort-Object -Culture 'en-US')) {
667667
$SectionContent += ("| ``{0}`` | {1} |" -f $reference, 'Remote reference')
668668
}
669669
}
@@ -1283,11 +1283,11 @@ function Set-UsageExamplesSection {
12831283
$moduleNameCamelCase = $First.Tolower() + (Get-Culture).TextInfo.ToTitleCase($Rest) -Replace '-'
12841284
}
12851285

1286-
$testFilePaths = (Get-ChildItem -Path $ModuleRoot -Recurse -Filter 'main.test.bicep').FullName | Sort-Object
1286+
$testFilePaths = (Get-ChildItem -Path $ModuleRoot -Recurse -Filter 'main.test.bicep').FullName | Sort-Object -Culture 'en-US'
12871287

12881288
$RequiredParametersList = $TemplateFileContent.parameters.Keys | Where-Object {
12891289
Get-IsParameterRequired -TemplateFileContent $TemplateFileContent -Parameter $TemplateFileContent.parameters[$_]
1290-
} | Sort-Object
1290+
} | Sort-Object -Culture 'en-US'
12911291

12921292
############################
12931293
## Process test files ##

avm/utilities/pipelines/sharedScripts/helper/ConvertTo-OrderedHashtable.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function ConvertTo-OrderedHashtable {
6363
return $JSONObject # E.g. in primitive data types [1,2,3]
6464
}
6565

66-
foreach ($currentLevelKey in ($JSONObject.Keys | Sort-Object)) {
66+
foreach ($currentLevelKey in ($JSONObject.Keys | Sort-Object -Culture 'en-US')) {
6767

6868
if ($null -eq $JSONObject[$currentLevelKey]) {
6969
# Handle case in which the value is 'null' and hence has no type
@@ -83,7 +83,7 @@ function ConvertTo-OrderedHashtable {
8383
foreach ($array in $arrayElements) {
8484
if ($array.Count -gt 1) {
8585
# Only sort for arrays with more than one item. Otherwise single-item arrays are casted
86-
$array = $array | Sort-Object
86+
$array = $array | Sort-Object -Culture 'en-US'
8787
}
8888
$arrayOutput += , (ConvertTo-OrderedHashtable -JSONInputObject ($array | ConvertTo-Json -Depth 99))
8989
}
@@ -97,13 +97,13 @@ function ConvertTo-OrderedHashtable {
9797
# Case: Primitive data types
9898
$primitiveElements = $JSONObject[$currentLevelKey] | Where-Object { $_.GetType().BaseType.Name -notin @('Array', 'Hashtable') } | ConvertTo-Json -Depth 99 | ConvertFrom-Json -AsHashtable -NoEnumerate -Depth 99
9999
if ($primitiveElements.Count -gt 1) {
100-
$primitiveElements = $primitiveElements | Sort-Object
100+
$primitiveElements = $primitiveElements | Sort-Object -Culture 'en-US'
101101
}
102102
$arrayOutput += $primitiveElements
103103

104104
if ($array.Count -gt 1) {
105105
# Only sort for arrays with more than one item. Otherwise single-item arrays are casted
106-
$arrayOutput = $arrayOutput | Sort-Object
106+
$arrayOutput = $arrayOutput | Sort-Object -Culture 'en-US'
107107
}
108108
$orderedLevel[$currentLevelKey] = $arrayOutput
109109
}

avm/utilities/pipelines/sharedScripts/helper/Get-CrossReferencedModuleList.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ function Get-ReferenceObject {
9696
}
9797

9898
return @{
99-
resourceReferences = $resultSet.resourceReferences | Sort-Object -Unique
100-
remoteReferences = $resultSet.remoteReferences | Sort-Object -Unique
101-
localPathReferences = $resultSet.localPathReferences | Sort-Object -Unique
99+
resourceReferences = $resultSet.resourceReferences | Sort-Object -Culture 'en-US' -Unique
100+
remoteReferences = $resultSet.remoteReferences | Sort-Object -Culture 'en-US' -Unique
101+
localPathReferences = $resultSet.localPathReferences | Sort-Object -Culture 'en-US' -Unique
102102
}
103103
}
104104
#endregion
@@ -155,7 +155,7 @@ function Get-CrossReferencedModuleList {
155155
$moduleTemplatePaths = (Get-ChildItem -Path $path -Recurse -File -Filter '*.bicep').FullName | Where-Object {
156156
# No files inthe [/utilities/tools/] folder and none in the [/tests/] folder
157157
$_ -notmatch '.*[\\|\/]tools[\\|\/].*|.*[\\|\/]tests[\\|\/].*'
158-
} | Sort-Object
158+
} | Sort-Object -Culture 'en-US'
159159
$templateMap = @{}
160160
foreach ($moduleTemplatePath in $moduleTemplatePaths) {
161161
$templateMap[$moduleTemplatePath] = Get-Content -Path $moduleTemplatePath

avm/utilities/pipelines/sharedScripts/helper/Get-SpecsAlignedResourceName.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function Get-SpecsAlignedResourceName {
7676
$rawProviderNamespace, $rawResourceType = $reducedResourceIdentifier -Split '[\/|\\]', 2 # e.g. 'keyvault' & 'vaults/keys'
7777

7878
# Find provider namespace
79-
$foundProviderNamespaceMatches = ($specs.Keys | Sort-Object) | Where-Object { $_ -like "Microsoft.$rawProviderNamespace*" }
79+
$foundProviderNamespaceMatches = ($specs.Keys | Sort-Object -Culture 'en-US') | Where-Object { $_ -like "Microsoft.$rawProviderNamespace*" }
8080

8181
if (-not $foundProviderNamespaceMatches) {
8282
$providerNamespace = "Microsoft.$rawProviderNamespace"
@@ -86,7 +86,7 @@ function Get-SpecsAlignedResourceName {
8686
}
8787

8888
# Find resource type
89-
$innerResourceTypes = $specs[$providerNamespace].Keys | Sort-Object
89+
$innerResourceTypes = $specs[$providerNamespace].Keys | Sort-Object -Culture 'en-US'
9090

9191
$rawResourceTypeElem = $rawResourceType -split '[\/|\\]'
9292
$reducedResourceTypeElements = $rawResourceTypeElem | ForEach-Object { Get-ReducedWordString -StringToReduce $_ }

avm/utilities/pipelines/sharedScripts/tokenReplacement/Convert-TokensInFileList.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function Convert-TokensInFileList {
7070

7171
process {
7272
# Combine All Input Token Types, Remove Duplicates and Only Select entries with on empty values
73-
$FilteredTokens = ($Tokens | Sort-Object -Unique).Clone()
73+
$FilteredTokens = ($Tokens | Sort-Object -Culture 'en-US' -Unique).Clone()
7474
@($FilteredTokens.Keys) | ForEach-Object {
7575
if ([String]::IsNullOrEmpty($FilteredTokens[$_])) {
7676
$FilteredTokens.Remove($_)

avm/utilities/pipelines/staticValidation/compliance/Set-PesterGitHubOutput.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function Set-PesterGitHubOutput {
128128
'| Name | Error | Source |',
129129
'| :-- | :-- | :-- |'
130130
)
131-
foreach ($failedTest in ($failedTests | Sort-Object -Property { $PSItem.ExpandedName })) {
131+
foreach ($failedTest in ($failedTests | Sort-Object -Culture 'en-US' -Property { $PSItem.ExpandedName })) {
132132

133133
$intermediateNameElements = $failedTest.Path
134134
$intermediateNameElements[-1] = '**{0}**' -f $failedTest.ExpandedName
@@ -175,7 +175,7 @@ function Set-PesterGitHubOutput {
175175
'| Name | Source |',
176176
'| :-- | :-- |'
177177
)
178-
foreach ($passedTest in ($passedTests | Sort-Object -Property { $PSItem.ExpandedName }) ) {
178+
foreach ($passedTest in ($passedTests | Sort-Object -Culture 'en-US' -Property { $PSItem.ExpandedName }) ) {
179179

180180
$intermediateNameElements = $passedTest.Path
181181
$intermediateNameElements[-1] = '**{0}**' -f $passedTest.ExpandedName
@@ -221,7 +221,7 @@ function Set-PesterGitHubOutput {
221221
'| Name | Reason | Source |',
222222
'| :-- | :-- | :-- |'
223223
)
224-
foreach ($skippedTest in ($skippedTests | Sort-Object -Property { $PSItem.ExpandedName }) ) {
224+
foreach ($skippedTest in ($skippedTests | Sort-Object -Culture 'en-US' -Property { $PSItem.ExpandedName }) ) {
225225

226226
$intermediateNameElements = $skippedTest.Path
227227
$intermediateNameElements[-1] = '**{0}**' -f $skippedTest.ExpandedName
@@ -269,7 +269,7 @@ function Set-PesterGitHubOutput {
269269
'| Name | Warning | Source |',
270270
'| :-- | :-- | :-- |'
271271
)
272-
foreach ($test in ($testsWithWarnings | Sort-Object -Property { $PSItem.ExpandedName }) ) {
272+
foreach ($test in ($testsWithWarnings | Sort-Object -Culture 'en-US' -Property { $PSItem.ExpandedName }) ) {
273273
foreach ($warning in $test.StandardOutput.Warning) {
274274
$intermediateNameElements = $test.Path
275275
$intermediateNameElements[-1] = '**{0}**' -f $test.ExpandedName

0 commit comments

Comments
 (0)