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

Change default validate image output to text #1893

Merged

Conversation

simonbaird
Copy link
Member

The previous default was json.

There was one change in the unit tests required to make the tests pass. I'm not 100% sure why that was needed (or rather why it wasn't needed before), but my understanding is that the fs and the ctx was being reused between two test cases and it was causing problems somehow.

I did look at the task definition also, but the output is specified explicitly, so should be no change needed.

Ref: https://issues.redhat.com/browse/EC-758

Copy link

codecov bot commented Aug 28, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.81%. Comparing base (9ec0992) to head (902d6ec).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
internal/applicationsnapshot/report.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1893      +/-   ##
==========================================
+ Coverage   80.79%   80.81%   +0.01%     
==========================================
  Files          68       68              
  Lines        5050     5050              
==========================================
+ Hits         4080     4081       +1     
+ Misses        970      969       -1     
Flag Coverage Δ
generative 80.81% <0.00%> (+0.01%) ⬆️
integration 80.81% <0.00%> (+0.01%) ⬆️
unit 80.81% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/applicationsnapshot/report.go 72.04% <0.00%> (ø)

... and 1 file with indirect coverage changes

@simonbaird
Copy link
Member Author

For once I think I will pay attention to the CodeCov complaint.

@simonbaird simonbaird marked this pull request as draft August 28, 2024 13:26
The same mocked validator was used in many places with a lot of
copy/pasted code, so I wanted to clean that up.

Not directly related to, but done while while working on...
Ref: https://issues.redhat.com/browse/EC-758
The previous default was json.

There was one change in the unit tests required to make the tests
pass. I'm not 100% sure why that was needed (or rather why it wasn't
needed before), but my understanding is that the fs and the ctx was
being reused between two test cases and it was causing problems
somehow.

I did look at the task definition also, but the output is specified
explicitly, so should be no change needed.

Ref: https://issues.redhat.com/browse/EC-758
Motivated by CodeCov complaining about one uncovered code path.

I decided to test the output with and without --show-successes. It's
perhaps more than was needed, but actually this is the first unit
test coverage of the validate image text output, (existing coverage
is all in the acceptance tests), so I think it's worthwhile.

Ref: https://issues.redhat.com/browse/EC-758
Fix a little text output glitch when --show-successes is not set.

Note: I realized that `or` in a go template can take more than two
parameters, so that's why the nested or was removed.

Drive-by fix while working on...
Ref: https://issues.redhat.com/browse/EC-758
@simonbaird simonbaird force-pushed the default-to-text-output branch from 7b0baa6 to 902d6ec Compare August 28, 2024 18:34
@simonbaird
Copy link
Member Author

I fixed a few annoyances and added some more test coverage. Will take out of draft when it goes green.

@simonbaird simonbaird marked this pull request as ready for review August 28, 2024 19:48
@simonbaird
Copy link
Member Author

Now I'm pretty sure the CodeCov complaint is wrong. 🤔 🤷

@@ -166,7 +166,7 @@ func NewReport(snapshot string, components []Component, policy policy.Policy, da
// WriteAll writes the report to all the given targets.
func (r Report) WriteAll(targets []string, p format.TargetParser) (allErrors error) {
if len(targets) == 0 {
targets = append(targets, JSON)
targets = append(targets, Text)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The significant functional change.

@simonbaird simonbaird merged commit 5280fef into enterprise-contract:main Aug 29, 2024
11 of 12 checks passed
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

Successfully merging this pull request may close these issues.

2 participants