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

chore: refactor complex implementation of request-processing filters #1333

Merged
merged 56 commits into from
Oct 30, 2024

Conversation

samayer12
Copy link
Collaborator

Description

This PR is part of the effort to reduce complexity in the code. Instead of using ternaries that are chained together, this refactor introduces a FilterChain analagous to what you might see in the Spring Framework to achieve the same outcome, improving readability and maintenance.

Related Issue

Relates to #1248

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other (security config, docs update, etc)

Checklist before merging

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 97.34043% with 5 lines in your changes missing coverage. Please review.

Project coverage is 79.36%. Comparing base (2686fa3) to head (2b6ea1e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/lib/filter/logMessages.ts 92.30% 4 Missing ⚠️
src/lib/filter/filtersWithLogs.ts 98.83% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1333      +/-   ##
==========================================
+ Coverage   78.02%   79.36%   +1.34%     
==========================================
  Files          35       38       +3     
  Lines        1670     1793     +123     
  Branches      371      363       -8     
==========================================
+ Hits         1303     1423     +120     
- Misses        365      368       +3     
  Partials        2        2              
Files with missing lines Coverage Δ
src/lib/filter/adjudicators.ts 100.00% <100.00%> (ø)
src/lib/filter/filterChain.ts 100.00% <100.00%> (ø)
src/lib/filter/shouldSkipRequest.ts 100.00% <100.00%> (ø)
src/lib/helpers.ts 97.19% <ø> (ø)
src/lib/mutate-processor.ts 9.09% <100.00%> (ø)
src/lib/types.ts 100.00% <ø> (ø)
src/lib/validate-processor.ts 13.15% <100.00%> (ø)
src/lib/filter/filtersWithLogs.ts 98.83% <98.83%> (ø)
src/lib/filter/logMessages.ts 92.30% <92.30%> (ø)

@samayer12
Copy link
Collaborator Author

To troubleshoot CI issues locally, download the controller and image artifact from build.

Copy link
Collaborator

@cmwylie19 cmwylie19 left a comment

Choose a reason for hiding this comment

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

Nice this looks good now. Glad you got to get into the filter code.

@cmwylie19 cmwylie19 added this to the v0.39.0 milestone Oct 30, 2024
@btlghrants btlghrants merged commit 58633b8 into main Oct 30, 2024
45 of 46 checks passed
@btlghrants btlghrants deleted the 1248-refactor-complexity-warnings branch October 30, 2024 14:23
@cmwylie19 cmwylie19 restored the 1248-refactor-complexity-warnings branch November 6, 2024 15:13
@samayer12 samayer12 mentioned this pull request Nov 6, 2024
5 tasks
cmwylie19 pushed a commit that referenced this pull request Nov 6, 2024
## Description

Reverts filter-chaining from #1333 due to regressions, but keeps
subsequent work.

End to End Test:  <!-- if applicable -->  
(See [Pepr Excellent
Examples](https://github.com/defenseunicorns/pepr-excellent-examples))

## Related Issue

Relates to #1248 
Closes #1389 

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

## Checklist before merging
- [x] Unit,
[Journey](https://github.com/defenseunicorns/pepr/tree/main/journey),
[E2E Tests](https://github.com/defenseunicorns/pepr-excellent-examples),
[docs](https://github.com/defenseunicorns/pepr/tree/main/docs),
[adr](https://github.com/defenseunicorns/pepr/tree/main/adr) added or
updated as needed
- [x] [Contributor Guide
Steps](https://docs.pepr.dev/main/contribute/#submitting-a-pull-request)
followed
github-merge-queue bot pushed a commit that referenced this pull request Dec 5, 2024
… processing (#1402)

## Description

The adjudicators are untyped, which caused complications when merging PR
#1333. We should use TypeScript to enforce typing so that any refactors
to filtering are based upon a solid foundation that does not require
intermediate kludges with the typing system.

End to End Test:  <!-- if applicable -->  
(See [Pepr Excellent
Examples](https://github.com/defenseunicorns/pepr-excellent-examples))

## Related Issue

Relates to #1248, #1406, #1407, #1408, #1409, #1397

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Other (security config, docs update, etc)

## Checklist before merging
- [x] Unit,
[Journey](https://github.com/defenseunicorns/pepr/tree/main/journey),
[E2E Tests](https://github.com/defenseunicorns/pepr-excellent-examples),
[docs](https://github.com/defenseunicorns/pepr/tree/main/docs),
[adr](https://github.com/defenseunicorns/pepr/tree/main/adr) added or
updated as needed
- [x] [Contributor Guide
Steps](https://docs.pepr.dev/main/contribute/#submitting-a-pull-request)
followed

---------

Co-authored-by: Case Wylie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants