enterprise-contract / ec-cli

Enterprise Contract command line interface
https://enterprisecontract.dev/docs/ec-cli/main/index.html
Apache License 2.0
26 stars 25 forks source link

Use new template utils for inspect policy also #1644

Closed simonbaird closed 1 month ago

simonbaird commented 2 months ago

The new templating helpers were introduced in #1631. I want to use the same technique in some older templating.

This required a little refactor of the helpers because we want to be able to use io.Writer directly rather than write to a buffer.

Also add some extra unit tests.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 80.13%. Comparing base (5585270) to head (f6555f3).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/graphs/tree.svg?width=650&height=150&src=pr&token=CY5ORXJB33&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract)](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) ```diff @@ Coverage Diff @@ ## main #1644 +/- ## ========================================== - Coverage 80.14% 80.13% -0.01% ========================================== Files 65 65 Lines 4779 4788 +9 ========================================== + Hits 3830 3837 +7 - Misses 949 951 +2 ``` | [Flag](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | Coverage Δ | | |---|---|---| | [generative](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | `80.13% <88.23%> (-0.01%)` | :arrow_down: | | [integration](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | `80.13% <88.23%> (-0.01%)` | :arrow_down: | | [unit](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | `80.13% <88.23%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | Coverage Δ | | |---|---|---| | [internal/opa/output.go](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644?src=pr&el=tree&filepath=internal%2Fopa%2Foutput.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract#diff-aW50ZXJuYWwvb3BhL291dHB1dC5nbw==) | `92.30% <75.00%> (-3.53%)` | :arrow_down: | | [internal/utils/templates.go](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644?src=pr&el=tree&filepath=internal%2Futils%2Ftemplates.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract#diff-aW50ZXJuYWwvdXRpbHMvdGVtcGxhdGVzLmdv) | `56.89% <92.30%> (+3.95%)` | :arrow_up: |
codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 86.81%. Comparing base (5585270) to head (8769eb7).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/graphs/tree.svg?width=650&height=150&src=pr&token=CY5ORXJB33&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract)](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) ```diff @@ Coverage Diff @@ ## main #1644 +/- ## ========================================== + Coverage 80.14% 86.81% +6.67% ========================================== Files 65 76 +11 Lines 4779 5128 +349 ========================================== + Hits 3830 4452 +622 + Misses 949 676 -273 ``` | [Flag](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | Coverage Δ | | |---|---|---| | [acceptance](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | `72.06% <47.05%> (?)` | | | [generative](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | `80.13% <88.23%> (-0.01%)` | :arrow_down: | | [integration](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | `80.13% <88.23%> (-0.01%)` | :arrow_down: | | [unit](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | `80.13% <88.23%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract) | Coverage Δ | | |---|---|---| | [internal/opa/output.go](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644?src=pr&el=tree&filepath=internal%2Fopa%2Foutput.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract#diff-aW50ZXJuYWwvb3BhL291dHB1dC5nbw==) | `92.30% <75.00%> (-3.53%)` | :arrow_down: | | [internal/utils/templates.go](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644?src=pr&el=tree&filepath=internal%2Futils%2Ftemplates.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract#diff-aW50ZXJuYWwvdXRpbHMvdGVtcGxhdGVzLmdv) | `56.89% <92.30%> (+3.95%)` | :arrow_up: | ... and [41 files with indirect coverage changes](https://app.codecov.io/gh/enterprise-contract/ec-cli/pull/1644/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=enterprise-contract)