Skip to content

Commit

Permalink
fix: PowerShell formatting - 4 spaces tab alignment (#2471)
Browse files Browse the repository at this point in the history
## Description

Disable `editor.detectIndentation` vscode setting for PowerShell files
to allow 4 spaces tab to be effective
Reformat all .ps1 files
> Note: only contains formatting changes

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.network.nat-gateway](https://github.com/eriqua/bicep-registry-modules/actions/workflows/avm.res.network.nat-gateway.yml/badge.svg?branch=fix%2Fps-formatting&event=page_build)](https://github.com/eriqua/bicep-registry-modules/actions/workflows/avm.res.network.nat-gateway.yml)
|
|
[![avm.res.compute.virtual-machine-scale-set](https://github.com/eriqua/bicep-registry-modules/actions/workflows/avm.res.compute.virtual-machine-scale-set.yml/badge.svg?branch=fix%2Fps-formatting)](https://github.com/eriqua/bicep-registry-modules/actions/workflows/avm.res.compute.virtual-machine-scale-set.yml)
|
|
[![avm.res.analysis-services.server](https://github.com/eriqua/bicep-registry-modules/actions/workflows/avm.res.analysis-services.server.yml/badge.svg?branch=fix%2Fps-formatting)](https://github.com/eriqua/bicep-registry-modules/actions/workflows/avm.res.analysis-services.server.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [x] Update to CI Environment or utilities (Non-module affecting
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

## Checklist

- [ ] I'm sure there are no other open Pull Requests for the same
update/change
- [ ] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [ ] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->

---------

Co-authored-by: Alexander Sehr <[email protected]>
  • Loading branch information
eriqua and AlexanderSehr authored Jul 5, 2024
1 parent c853198 commit 1ccb706
Show file tree
Hide file tree
Showing 42 changed files with 2,978 additions and 2,977 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"editor.insertSpaces": true,
"editor.tabSize": 4,
"files.encoding": "utf8bom",
"files.insertFinalNewline": true
"files.insertFinalNewline": true,
"editor.detectIndentation": false // VS Code will not detect indentation/tab/space from the file and use settings editor.insertSpaces and editor.tabSize instead
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,64 @@ $newScopes = $env:exportScopes.Split('|') | Where-Object $validateScopes | ForEa

# Get storage context
$storageContext = @{
Context = New-AzStorageContext -StorageAccountName $env:storageAccountName -UseConnectedAccount
Container = $env:containerName
Context = New-AzStorageContext -StorageAccountName $env:storageAccountName -UseConnectedAccount
Container = $env:containerName
}

# Download existing settings, if they exist
$blob = Get-AzStorageBlobContent @storageContext -Blob $fileName -Destination $filePath -Force
if ($blob) {
Write-Output 'Existing settings.json file found. Updating...'
$text = Get-Content $filePath -Raw
Write-Output '---------'
Write-Output $text
Write-Output '---------'
$json = $text | ConvertFrom-Json
Write-Output 'Existing settings.json file found. Updating...'
$text = Get-Content $filePath -Raw
Write-Output '---------'
Write-Output $text
Write-Output '---------'
$json = $text | ConvertFrom-Json

# Rename exportScopes to scopes + convert to object array
if ($json.exportScopes) {
Write-Output ' Updating exportScopes...'
if ($json.exportScopes[0] -is [string]) {
Write-Output ' Converting string array to object array...'
$json.exportScopes = $json.exportScopes | Where-Object $validateScopes | ForEach-Object { @{ scope = $_ } }
if (-not ($json.exportScopes -is [array])) {
Write-Output ' Converting single object to object array...'
$json.exportScopes = @($json.exportScopes)
}
}
# Rename exportScopes to scopes + convert to object array
if ($json.exportScopes) {
Write-Output ' Updating exportScopes...'
if ($json.exportScopes[0] -is [string]) {
Write-Output ' Converting string array to object array...'
$json.exportScopes = $json.exportScopes | Where-Object $validateScopes | ForEach-Object { @{ scope = $_ } }
if (-not ($json.exportScopes -is [array])) {
Write-Output ' Converting single object to object array...'
$json.exportScopes = @($json.exportScopes)
}
}

Write-Output " Renaming to 'scopes'..."
$json | Add-Member -MemberType NoteProperty -Name scopes -Value $json.exportScopes
$json.PSObject.Properties.Remove('exportScopes')
}
Write-Output " Renaming to 'scopes'..."
$json | Add-Member -MemberType NoteProperty -Name scopes -Value $json.exportScopes
$json.PSObject.Properties.Remove('exportScopes')
}
}

# Set default if not found
if (!$json) {
Write-Output 'No existing settings.json file found. Creating new file...'
$json = [ordered]@{
'$schema' = 'https://aka.ms/finops/hubs/settings-schema'
type = 'HubInstance'
version = ''
learnMore = 'https://aka.ms/finops/hubs'
scopes = @()
}
Write-Output 'No existing settings.json file found. Creating new file...'
$json = [ordered]@{
'$schema' = 'https://aka.ms/finops/hubs/settings-schema'
type = 'HubInstance'
version = ''
learnMore = 'https://aka.ms/finops/hubs'
scopes = @()
}
}

# Updating settings
Write-Output "Updating version to $env:ftkVersion..."
$json.version = $env:ftkVersion
if ($newScopes) {
Write-Output "Merging $($newScopes.Count) scopes..."
$json.scopes = Compare-Object -ReferenceObject $json.scopes -DifferenceObject $newScopes -Property scope -PassThru -IncludeEqual
Write-Output "Merging $($newScopes.Count) scopes..."
$json.scopes = Compare-Object -ReferenceObject $json.scopes -DifferenceObject $newScopes -Property scope -PassThru -IncludeEqual

# Remove the SideIndicator property from the Compare-Object output
$json.scopes | ForEach-Object { $_.PSObject.Properties.Remove('SideIndicator') } | ConvertTo-Json
# Remove the SideIndicator property from the Compare-Object output
$json.scopes | ForEach-Object { $_.PSObject.Properties.Remove('SideIndicator') } | ConvertTo-Json

if (-not ($json.scopes -is [array])) {
$json.scopes = @($json.scopes)
}
Write-Output "$($json.scopes.Count) scopes found."
if (-not ($json.scopes -is [array])) {
$json.scopes = @($json.scopes)
}
Write-Output "$($json.scopes.Count) scopes found."
}
$text = $json | ConvertTo-Json
Write-Output '---------'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
$DeploymentScriptOutputs = @{}

$adfParams = @{
ResourceGroupName = $env:DataFactoryResourceGroup
DataFactoryName = $env:DataFactoryName
ResourceGroupName = $env:DataFactoryResourceGroup
DataFactoryName = $env:DataFactoryName
}

# Delete old triggers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
Param(
[switch] $Stop
[switch] $Stop
)
# Init outputs
$DeploymentScriptOutputs = @{}

if (-not $Stop) {
Start-Sleep -Seconds 10
Start-Sleep -Seconds 10
}

# Loop through triggers
$env:Triggers.Split('|') `
| ForEach-Object {
$trigger = $_
if ($Stop) {
Write-Host "Stopping trigger $trigger..." -NoNewline
$triggerOutput = Stop-AzDataFactoryV2Trigger `
-ResourceGroupName $env:DataFactoryResourceGroup `
-DataFactoryName $env:DataFactoryName `
-Name $trigger `
-Force `
-ErrorAction SilentlyContinue
} else {
Write-Host "Starting trigger $trigger..." -NoNewline
$triggerOutput = Start-AzDataFactoryV2Trigger `
-ResourceGroupName $env:DataFactoryResourceGroup `
-DataFactoryName $env:DataFactoryName `
-Name $trigger `
-Force
}
if ($triggerOutput) {
Write-Host 'done'
} else {
Write-Host 'failed'
}
$DeploymentScriptOutputs[$trigger] = $triggerOutput
$trigger = $_
if ($Stop) {
Write-Host "Stopping trigger $trigger..." -NoNewline
$triggerOutput = Stop-AzDataFactoryV2Trigger `
-ResourceGroupName $env:DataFactoryResourceGroup `
-DataFactoryName $env:DataFactoryName `
-Name $trigger `
-Force `
-ErrorAction SilentlyContinue
} else {
Write-Host "Starting trigger $trigger..." -NoNewline
$triggerOutput = Start-AzDataFactoryV2Trigger `
-ResourceGroupName $env:DataFactoryResourceGroup `
-DataFactoryName $env:DataFactoryName `
-Name $trigger `
-Force
}
if ($triggerOutput) {
Write-Host 'done'
} else {
Write-Host 'failed'
}
$DeploymentScriptOutputs[$trigger] = $triggerOutput
}

if ($Stop) {
Start-Sleep -Seconds 10
Start-Sleep -Seconds 10
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Param(
[string]$subscriptionId,
[string]$resourceProviders
[string]$subscriptionId,
[string]$resourceProviders
)

$ErrorActionPreference = 'SilentlyContinue'
Expand All @@ -18,81 +18,81 @@ $DeploymentScriptOutputs = @{}
##############################################

if ($providers.Count -gt 0) {
foreach ($provider in $providers.keys) {
try {
# Registering resource providers
$providerStatus = (Get-AzResourceProvider -ListAvailable | Where-Object ProviderNamespace -EQ $provider).registrationState
# Check if the providered is registered
if ($providerStatus -eq 'NotRegistered') {
Write-Output "`n Registering the '$provider' provider"
if (Register-AzResourceProvider -ProviderNamespace $provider) {
Write-Output "`n The registration for provider'$provider' has started successfully"
} else {
Write-Output "`n The '$provider' provider has not been registered successfully"
$failedProviders += ",$provider"
}
} elseif ($providerStatus -eq 'Registering') {
Write-Output "`n The '$provider' provider is in registering state"
$failedProviders += ",$provider"
} elseif ( $null -eq $providerStatus) {
Write-Output "`n There was a problem registering the '$provider' provider. Please make sure this provider namespace is valid"
$failedProviders += ",$provider"
}

if ($failedProviders.length -gt 0) {
$output = $failedProviders.substring(1)
} else {
$output = 'No failures'
}
$DeploymentScriptOutputs['failedProvidersRegistrations'] = $output
} catch {
Write-Output "`n There was a problem registering the '$provider' provider. Please make sure this provider namespace is valid"
$failedProviders += ",$provider"
if ($failedProviders.length -gt 0) {
$output = $failedProviders.substring(1)
}
$DeploymentScriptOutputs['failedProvidersRegistrations'] = $output
}
# Registering resource providers features
$features = $providers[$provider]
if ($features.length -gt 0) {
foreach ($feature in $features) {
foreach ($provider in $providers.keys) {
try {
# Define variables
$featureStatus = (Get-AzProviderFeature -ListAvailable | Where-Object FeatureName -EQ $feature).RegistrationState
# Check if the feature is registered
if ($featureStatus -eq 'NotRegistered' -or $featureStatus -eq 'Unregistered') {
Write-Output "`n Registering the '$feature' feature"
if (Register-AzProviderFeature -FeatureName $feature -ProviderNamespace $provider) {
Write-Output "`n The The registration for feature '$feature' has started successfully"
# Registering resource providers
$providerStatus = (Get-AzResourceProvider -ListAvailable | Where-Object ProviderNamespace -EQ $provider).registrationState
# Check if the providered is registered
if ($providerStatus -eq 'NotRegistered') {
Write-Output "`n Registering the '$provider' provider"
if (Register-AzResourceProvider -ProviderNamespace $provider) {
Write-Output "`n The registration for provider'$provider' has started successfully"
} else {
Write-Output "`n The '$provider' provider has not been registered successfully"
$failedProviders += ",$provider"
}
} elseif ($providerStatus -eq 'Registering') {
Write-Output "`n The '$provider' provider is in registering state"
$failedProviders += ",$provider"
} elseif ( $null -eq $providerStatus) {
Write-Output "`n There was a problem registering the '$provider' provider. Please make sure this provider namespace is valid"
$failedProviders += ",$provider"
}

if ($failedProviders.length -gt 0) {
$output = $failedProviders.substring(1)
} else {
Write-Output "`n The '$feature' feature has not been registered successfully"
$failedFeatures += ",$feature"
$output = 'No failures'
}
} elseif ($null -eq $featureStatus) {
Write-Output "`n The '$feature' feature doesn't exist."
$failedFeatures += ",$feature"
}
if ($failedFeatures.length -gt 0) {
$output = $failedFeatures.substring(1)
} else {
$output = 'No failures'
}
$DeploymentScriptOutputs['failedFeaturesRegistrations'] = $output
$DeploymentScriptOutputs['failedProvidersRegistrations'] = $output
} catch {
Write-Output "`n There was a problem registering the '$feature' feature. Please make sure this feature name is valid"
$failedFeatures += ",$feature"
if ($failedFeatures.length -gt 0) {
$output = $failedFeatures.substring(1)
}
$DeploymentScriptOutputs['failedFeaturesRegistrations'] = $output
Write-Output "`n There was a problem registering the '$provider' provider. Please make sure this provider namespace is valid"
$failedProviders += ",$provider"
if ($failedProviders.length -gt 0) {
$output = $failedProviders.substring(1)
}
$DeploymentScriptOutputs['failedProvidersRegistrations'] = $output
}
# Registering resource providers features
$features = $providers[$provider]
if ($features.length -gt 0) {
foreach ($feature in $features) {
try {
# Define variables
$featureStatus = (Get-AzProviderFeature -ListAvailable | Where-Object FeatureName -EQ $feature).RegistrationState
# Check if the feature is registered
if ($featureStatus -eq 'NotRegistered' -or $featureStatus -eq 'Unregistered') {
Write-Output "`n Registering the '$feature' feature"
if (Register-AzProviderFeature -FeatureName $feature -ProviderNamespace $provider) {
Write-Output "`n The The registration for feature '$feature' has started successfully"
} else {
Write-Output "`n The '$feature' feature has not been registered successfully"
$failedFeatures += ",$feature"
}
} elseif ($null -eq $featureStatus) {
Write-Output "`n The '$feature' feature doesn't exist."
$failedFeatures += ",$feature"
}
if ($failedFeatures.length -gt 0) {
$output = $failedFeatures.substring(1)
} else {
$output = 'No failures'
}
$DeploymentScriptOutputs['failedFeaturesRegistrations'] = $output
} catch {
Write-Output "`n There was a problem registering the '$feature' feature. Please make sure this feature name is valid"
$failedFeatures += ",$feature"
if ($failedFeatures.length -gt 0) {
$output = $failedFeatures.substring(1)
}
$DeploymentScriptOutputs['failedFeaturesRegistrations'] = $output
}
}
} else {
$output = 'No failures'
$DeploymentScriptOutputs['failedFeaturesRegistrations'] = $output
}
}
} else {
$output = 'No failures'
$DeploymentScriptOutputs['failedFeaturesRegistrations'] = $output
}
}
} else {
Write-Output "`n No providers or features to register"
Write-Output "`n No providers or features to register"
}
Loading

0 comments on commit 1ccb706

Please sign in to comment.