-
Notifications
You must be signed in to change notification settings - Fork 194
Resolve PowerShell lint errors and enable CI enforcement #1988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,7 +136,7 @@ | |
| function New-FinOpsCostExport | ||
| { | ||
| [Diagnostics.CodeAnalysis.SuppressMessage("PSReviewUnusedParameter", "", Justification = "False positive rule")] | ||
| [CmdletBinding(DefaultParameterSetName = "Scheduled")] | ||
| [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = "Scheduled")] | ||
| param | ||
| ( | ||
| [Parameter(Mandatory = $true)] | ||
|
|
@@ -446,23 +446,26 @@ function New-FinOpsCostExport | |
| } | ||
|
|
||
| # Create/update export | ||
| $createResponse = Invoke-Rest -Method PUT -Uri $uri -Body $properties @commandDetails | ||
| if ($createResponse.Failure) | ||
| if ($PSCmdlet.ShouldProcess($Name, 'Create cost export')) | ||
| { | ||
| Write-Error "Unable to create export $Name in scope $Scope. Error: $($createResponse.Content.error.message) ($($createResponse.Content.error.code))" -ErrorAction Stop | ||
| return | ||
| } | ||
| $createResponse = Invoke-Rest -Method PUT -Uri $uri -Body $properties @commandDetails | ||
| if ($createResponse.Failure) | ||
| { | ||
|
Comment on lines
+449
to
+453
|
||
| Write-Error "Unable to create export $Name in scope $Scope. Error: $($createResponse.Content.error.message) ($($createResponse.Content.error.code))" -ErrorAction Stop | ||
| return | ||
| } | ||
|
|
||
| # Run now if requested | ||
| if ($Backfill -gt 0 -and $OneTime -eq $false) | ||
| { | ||
| Start-FinOpsCostExport -Name $Name -Scope $Scope -Backfill $Backfill | ||
| } | ||
| elseif ($Execute -eq $true -or $OneTime -eq $true) | ||
| { | ||
| Start-FinOpsCostExport -Name $Name -Scope $Scope | ||
| } | ||
| # Run now if requested | ||
| if ($Backfill -gt 0 -and $OneTime -eq $false) | ||
| { | ||
| Start-FinOpsCostExport -Name $Name -Scope $Scope -Backfill $Backfill | ||
| } | ||
| elseif ($Execute -eq $true -or $OneTime -eq $true) | ||
| { | ||
| Start-FinOpsCostExport -Name $Name -Scope $Scope | ||
| } | ||
|
|
||
| return (Get-FinOpsCostExport -Name $Name -Scope $Scope -ApiVersion $ApiVersion) | ||
| return (Get-FinOpsCostExport -Name $Name -Scope $Scope -ApiVersion $ApiVersion) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,8 +103,8 @@ function Remove-FinOpsHub | |
| } | ||
|
|
||
| # List all resources to be deleted | ||
| Write-Host "The following resources will be deleted:" | ||
| $resources | ForEach-Object { Write-Host "- $($_.ResourceId)" } | ||
| Write-Information "The following resources will be deleted:" | ||
| $resources | ForEach-Object { Write-Information "- $($_.ResourceId)" } | ||
|
Comment on lines
+106
to
+107
|
||
|
|
||
| # Prompt the user for confirmation | ||
| if ($PSCmdlet.ShouldProcess($Name, 'DeleteFinOpsHub')) | ||
|
|
@@ -165,7 +165,7 @@ function Remove-FinOpsHub | |
| # Delete the resource | ||
| Write-Verbose -Message "Deleting resource: $($resource.Name)" | ||
| Remove-AzResource -ResourceId $resource.ResourceId -Force -ErrorAction Stop | ||
| Write-Host "Deleted resource: $($resource.Name)" | ||
| Write-Information "Deleted resource: $($resource.Name)" | ||
| } | ||
| catch | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| ο»Ώ# Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| <# | ||
|
|
@@ -53,7 +53,7 @@ | |
| function Start-FinOpsCostExport | ||
| { | ||
| [OutputType([bool])] | ||
| [cmdletBinding()] | ||
| [CmdletBinding(SupportsShouldProcess)] | ||
| param | ||
| ( | ||
| [Parameter(Mandatory = $true)] | ||
|
|
@@ -146,6 +146,12 @@ function Start-FinOpsCostExport | |
| { | ||
| Write-Verbose "Exporting $($StartDate) - $($EndDate)" | ||
| } | ||
|
|
||
| if (-not $PSCmdlet.ShouldProcess($Name, 'Run cost export')) | ||
|
Comment on lines
146
to
+150
|
||
| { | ||
| return $false | ||
| } | ||
|
|
||
| do | ||
| { | ||
| # Report progress | ||
|
|
@@ -173,15 +179,15 @@ function Start-FinOpsCostExport | |
| $firstDay = $StartDate | ||
| $lastDay = $EndDate | ||
| } | ||
|
|
||
| # Ensure end date is not in the future | ||
| $today = (Get-Date).ToUniversalTime().Date | ||
| if ($lastDay -ge $today) | ||
| { | ||
| Write-Verbose "Adjusting end date to yesterday as it cannot be in the future." | ||
| $lastDay = $today.AddDays(-1) | ||
| } | ||
|
|
||
| $body = @{ timePeriod = @{ from = $firstDay.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'"); to = $lastDay.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'") } } | ||
| Write-Verbose "Executing $($firstDay.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'")) to $($lastDay.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'")) export $runpath" | ||
| } | ||
|
|
@@ -224,7 +230,7 @@ function Start-FinOpsCostExport | |
| { | ||
| # If not retrying, then track the success | ||
| $success = $success -and $response.Success | ||
|
|
||
| # Only increment month if not throttled | ||
| $monthToExport += 1 | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR description indicates a changelog update is "not needed", but this PR changes user-facing PowerShell command behavior (ShouldProcess/OutputType/WhatIf semantics) and CI behavior. Per the repo guidance for PRs targeting
dev, external-facing changes should be captured indocs-mslearn/toolkit/changelog.md(seedocs-wiki/Branching-strategy.mdaround thedevrequirements).