Skip to content

refactor: patch with context #732

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

MiahaCybersec
Copy link
Contributor

@MiahaCybersec MiahaCybersec commented Aug 5, 2024

Closes #723

This PR primarily addresses the untestability of the core patch function within Copa. By breaking the code into smaller blocks, the core functionality of Copa can more easily be tested and extended in the future, and bugs should be easier to find.

Copy link

codecov bot commented Aug 5, 2024

Codecov Report

Attention: Patch coverage is 31.85185% with 92 lines in your changes missing coverage. Please review.

Project coverage is 48.76%. Comparing base (74381d3) to head (5edc28a).

Files with missing lines Patch % Lines
pkg/patch/patch.go 31.85% 92 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #732      +/-   ##
==========================================
+ Coverage   46.98%   48.76%   +1.78%     
==========================================
  Files          18       18              
  Lines        2205     2233      +28     
==========================================
+ Hits         1036     1089      +53     
+ Misses       1111     1084      -27     
- Partials       58       60       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@RobertKielty RobertKielty left a comment

Choose a reason for hiding this comment

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

@MiahaCybersec I have submitted some review comments on the tests and code.

This is good work that will make it easier for the Copa project to on-board new contributors, well done!

My requested changes are largely around improving the story telling around how copa works which will benefit both early adopting end-users and new contributors.

I have one question on the TrivyOpts and why that include non-trivy related fields (there's a bk client in there)

The most important thing to do with work like this is to test it extensively and ensure that no behaviour has changed as a result of the submitted changes.

@ashnamehrotra
Copy link
Contributor

LGTM, will wait to merge. @MiahaCybersec @RobertKielty and I discussed adding canary testing before merging large changes.

@MiahaCybersec
Copy link
Contributor Author

Changing PR to draft until it gets further review 👍

@MiahaCybersec MiahaCybersec marked this pull request as draft August 21, 2024 21:31
@MiahaCybersec
Copy link
Contributor Author

Any updates on internal testing for this refactoring PR?

@ashnamehrotra
Copy link
Contributor

@MiahaCybersec we won't be prioritizing a specific internal testing pipeline for this right now. I think if we want to rebase this with new changes for now, the integration tests should be good to test this.

Miaha Cybersec added 10 commits January 26, 2025 19:02
Signed-off-by: Miaha Cybersec <MiahaCybersec@gmail.com>
Signed-off-by: Miaha Cybersec <MiahaCybersec@gmail.com>
Signed-off-by: Miaha Cybersec <MiahaCybersec@gmail.com>
Signed-off-by: Miaha Cybersec <MiahaCybersec@gmail.com>
Signed-off-by: Miaha Cybersec <MiahaCybersec@gmail.com>
Signed-off-by: Miaha Cybersec <MiahaCybersec@gmail.com>
Signed-off-by: Miaha Cybersec <MiahaCybersec@gmail.com>
Signed-off-by: Miaha Cybersec <MiahaCybersec@gmail.com>
…tion

Extracted BuildKit client configurations from TrivyOpts into a new BkClient struct. Updated related functions and tests to accommodate this change, improving modularity and readability.

Signed-off-by: Miaha Cybersec <MiahaCybersec@gmail.com>
Renamed the `TrivyOpts` struct to `ScannerOpts` to better reflect its purpose. Added an explicit channel parameter `ch` for error handling throughout the functions to improve code clarity and maintainability. Added new test cases to cover scenarios with digest-referenced Docker images.

Signed-off-by: Miaha Cybersec <MiahaCybersec@gmail.com>
@MiahaCybersec MiahaCybersec force-pushed the stepwise-refinement-patch-with-context branch from 07ce9b3 to 5edc28a Compare January 27, 2025 01:40
@MiahaCybersec MiahaCybersec marked this pull request as ready for review January 27, 2025 02:07
@MiahaCybersec
Copy link
Contributor Author

MiahaCybersec commented Jan 27, 2025

This PR passes all tests, except for the 4 that are currently failing due to issue #877. Otherwise, it is functionally ready for review by maintainers.

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

Successfully merging this pull request may close these issues.

[REQ] Refactor patchWithContext()
3 participants