Skip to content

Commit

Permalink
fix: Fixed diverse typos and incorrect references in scripts (#4047)
Browse files Browse the repository at this point in the history
## Description

Fixed diverse typos and incorrect references in scripts
Fun fact: The branch name has a typo too. You're welcome.

## Pipeline Reference

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

- Not added as the changes are almost all in failure states 
- The one excemption is the image template removal which is also in a
tough spot as its currently not deployable

Just for fun:

[![avm.res.analysis-services.server](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.analysis-services.server.yml/badge.svg?branch=users%2Falsehr%2FtypoeResponse)](https://github.com/Azure/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
  • Loading branch information
AlexanderSehr authored Dec 23, 2024
1 parent baa5bac commit 6439544
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ function Invoke-ResourceRemoval {

$resourceGroupName = $ResourceId.Split('/')[4]
$resourceName = Split-Path $ResourceId -Leaf
$subscriptionId = $ResourceId.Split('/')[2]

# Remove resource
if ($PSCmdlet.ShouldProcess("Image Template [$resourceName]", 'Remove')) {
Expand All @@ -179,22 +180,22 @@ function Invoke-ResourceRemoval {
Method = 'GET'
Path = '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.VirtualMachineImages/imageTemplates/{2}?api-version=2022-07-01' -f $subscriptionId, $resourceGroupName, $resourceName
}
$getReponse = Invoke-AzRestMethod @getRequestInputObject
$getResponse = Invoke-AzRestMethod @getRequestInputObject

if ($getReponse.StatusCode -eq 400) {
if ($getResponse.StatusCode -eq 400) {
# Invalid request
throw ($imageTgetReponseemplate.Content | ConvertFrom-Json).error.message
} elseif ($getReponse.StatusCode -eq 404) {
throw ($getResponse.Content | ConvertFrom-Json).error.message
} elseif ($getResponse.StatusCode -eq 404) {
# Resource not found, removal was successful
$templateExists = $false
} elseif ($getReponse.StatusCode -eq '200') {
} elseif ($getResponse.StatusCode -eq '200') {
# Resource still around - try again
$templateExists = $true
Write-Verbose (' [⏱️] Waiting {0} seconds for Image Template to be removed. [{1}/{2}]' -f $retryInterval, $retryCount, $retryLimit) -Verbose
Start-Sleep -Seconds $retryInterval
$retryCount++
} else {
throw ('Failed request. Response: [{0}]' -f ($getReponse | Out-String))
throw ('Failed request. Response: [{0}]' -f ($getResponse | Out-String))
}
} while ($templateExists -and $retryCount -lt $retryLimit)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function Clear-ManagementGroupDeploymentHistory {
# Load helper functions
. (Join-Path (Split-Path $PSScriptRoot) 'helper' 'Split-Array.ps1')

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # Enables web reponse
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # Enables web response
$deploymentThreshold = (Get-Date).AddDays(-1 * $maxDeploymentRetentionInDays)

$getInputObject = @{
Expand All @@ -61,7 +61,7 @@ function Clear-ManagementGroupDeploymentHistory {
}

if (($response | Get-Member -MemberType 'NoteProperty').Name -notcontains 'value') {
throw ('Fetching deployments failed with error [{0}]' -f ($reponse | Out-String))
throw ('Fetching deployments failed with error [{0}]' -f ($response | Out-String))
}

Write-Verbose ('Found [{0}] deployments in management group [{1}]' -f $response.value.Count, $ManagementGroupId) -Verbose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function Clear-SubscriptionDeploymentHistory {
# Load helper functions
. (Join-Path (Split-Path $PSScriptRoot) 'helper' 'Split-Array.ps1')

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # Enables web reponse
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # Enables web response
$deploymentThreshold = (Get-Date).AddDays(-1 * $maxDeploymentRetentionInDays)

# Setting context explicitely in case the principal has permissions on multiple
Expand All @@ -60,7 +60,7 @@ function Clear-SubscriptionDeploymentHistory {
$response = Invoke-RestMethod @getInputObject

if (($response | Get-Member -MemberType 'NoteProperty').Name -notcontains 'value') {
throw ('Fetching deployments failed with error [{0}]' -f ($reponse | Out-String))
throw ('Fetching deployments failed with error [{0}]' -f ($response | Out-String))
}

Write-Verbose ('Found [{0}] deployments in subscription [{1}]' -f $response.value.Count, $subscriptionId) -Verbose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,14 @@ Describe 'Module tests' -Tag 'Module' {
# Compare
$filesAreTheSame = $fileHashBefore -eq $fileHashAfter
if (-not $filesAreTheSame) {
$diffReponse = git diff $readMeFilePath
Write-Warning ($diffReponse | Out-String) -Verbose
$diffResponse = git diff $readMeFilePath
Write-Warning ($diffResponse | Out-String) -Verbose

# Reset readme file to original state
git checkout HEAD -- $readMeFilePath
}

$mdFormattedDiff = ($diffReponse -join '</br>') -replace '\|', '\|'
$mdFormattedDiff = ($diffResponse -join '</br>') -replace '\|', '\|'
$filesAreTheSame | Should -Be $true -Because ('The file hashes before and after applying the `/utilities/tools/Set-AVMModule.ps1` and more precisely the `/utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1` function should be identical and should not have diff </br><pre>{0}</pre>. Please re-run the `Set-AVMModule` function for this module.' -f $mdFormattedDiff)
}
}
Expand Down
4 changes: 2 additions & 2 deletions utilities/tools/Invoke-WorkflowsFailedJobsReRun.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function Get-GitHubModuleWorkflowList {
}

if (-not $response.workflows) {
Write-Error "Request failed. Reponse: [$response]"
Write-Error "Request failed. Response: [$response]"
}

$allWorkflows += $response.workflows | Select-Object -Property @('id', 'name', 'path', 'badge_url', 'state') | Where-Object {
Expand Down Expand Up @@ -206,7 +206,7 @@ function Get-GitHubModuleWorkflowLatestRun {
}

if (-not $response.workflow_runs) {
Write-Error "Request failed. Reponse: [$response]"
Write-Error "Request failed. Response: [$response]"
}

return $response.workflow_runs | Select-Object -Property @('id', 'name', 'path', 'status', 'head_branch', 'created_at', 'run_number', 'run_attempt', 'conclusion')
Expand Down
2 changes: 1 addition & 1 deletion utilities/tools/Invoke-WorkflowsForBranch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function Get-GitHubModuleWorkflowList {
}

if (-not $response.workflows) {
Write-Error "Request failed. Reponse: [$response]"
Write-Error "Request failed. Response: [$response]"
}

$allWorkflows += $response.workflows | Select-Object -Property @('id', 'name', 'path', 'badge_url', 'state') | Where-Object {
Expand Down

0 comments on commit 6439544

Please sign in to comment.