As 'Summary' option does not work
avernigora-clgx opened this issue · comments
Thanks for raising your first issue, the team appreciates the time you have taken 😉
Thanks @avernigora-clgx for raising an issue. The output you have in the screenshot is expected.
In the summary view today passing rules are compacted into a single item for each resource and errored or failed rules are shown with details.
In the detailed view, each passing or failing/ erroring rule is shown.
While this is the current functionality, what would you like to see in future iterations to make this better?
Also it's worth noting that Assert-PSRule
and Invoke-PSRule
perform similar functions but display output differently. Assert-PSRule
is intended for output in a DevOps pipeline where there is no interactivity of the output but you need as much detail as possible for any issues.
With Invoke-PSRule
is follows normal powershell conventions so you can easily filter out data or change the view.
Perhaps in this case it is a good idea to update documentation, as I expected to se the summary table, as it is described in the doc
But my personal feeling is that it would be great if smth like this worked
$rx = assert-PSRule -InputPath .\hub\main.non-prod.bicepparam -Module 'PSRule.Rules.Azure' -Format File -Baseline 'Azure.Default' -As Summary -Option $option
$rx | where status -eq 'Failed'
So I can work with these outputs as they were normal .net objects
But my personal feeling is that it would be great if smth like this worked
$rx = assert-PSRule -InputPath .\hub\main.non-prod.bicepparam -Module 'PSRule.Rules.Azure' -Format File -Baseline 'Azure.Default' -As Summary -Option $option $rx | where status -eq 'Failed'So I can work with these outputs as they were normal .net objects
@avernigora-clgx For this, use Invoke-PSRule
which provides .NET objects as is expected in PowerShell.
As mentioned, Assert-PSRule
is for DevOps pipelines and integration into Visual Studio Code which only understand text, so formatted output is required.
With Invoke-PSRule
you absolutely can do something like | where Outcome -eq 'Fail'
in the detailed view (not summary). You could apply you own custom formatting.
I think for the most part the docs shows Invoke-PSRule
with the -As Summary
. If there is a specific part in the docs that was unclear let me know.
Also both Assert-PSRule
and Invoke-PSRule
support filtering outcome (status) as parameter -Outcome
. i.e. -Outcome Fail
or -Outcome Fail,Error
.