Skip to content
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

As 'Summary' option does not work #1702

Closed
avernigora-clgx opened this issue Dec 13, 2023 · 5 comments
Closed

As 'Summary' option does not work #1702

avernigora-clgx opened this issue Dec 13, 2023 · 5 comments
Assignees

Comments

@avernigora-clgx
Copy link

Description of the issue

-As Summary option does not work. It still produces the full output instead of the summary

To Reproduce

image

image

Copy link
Contributor

Thanks for raising your first issue, the team appreciates the time you have taken 😉

@BernieWhite BernieWhite self-assigned this Dec 14, 2023
@BernieWhite
Copy link
Member

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.

@avernigora-clgx
Copy link
Author

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

@avernigora-clgx
Copy link
Author

avernigora-clgx commented Dec 15, 2023

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

@BernieWhite
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants