-
Notifications
You must be signed in to change notification settings - Fork 16
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
EVEREST-107 | API server code refactor & RBAC unit tests #896
Draft
mayankshah1607
wants to merge
43
commits into
main
Choose a base branch
from
EVEREST-107-api-refactoring
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mayankshah1607
force-pushed
the
EVEREST-107-api-refactoring
branch
2 times, most recently
from
December 11, 2024 08:36
af4294d
to
939db3d
Compare
mayankshah1607
changed the title
EVEREST-107 | WIP
EVEREST-107 | API server code refactor & RBAC unit tests
Dec 11, 2024
mayankshah1607
force-pushed
the
EVEREST-107-api-refactoring
branch
from
December 11, 2024 13:57
dd216b6
to
a61bfb0
Compare
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
Signed-off-by: Mayank Shah <[email protected]>
mayankshah1607
force-pushed
the
EVEREST-107-api-refactoring
branch
from
December 12, 2024 10:30
e2250da
to
08023cc
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor the API server code.
Why?
In its current state, all the API logic is embedded directly into its respective API handler methods. With the addition of the RBAC feature, it seems that the code for different functionalities have intertwined with each other, resulting in code that is very tightly coupled. This has made it harder to include useful unit-testing and could even make it challenging to extend the code with new features in the future.
Key concerns:
enforce
methods (for explicit permissions)enforce
methods, but within validation functions like this.Proposed refactor
This code architecture proposed in this PR takes inspiration from a very common design pattern called chain of responsibility.
The key idea is simple:
Such a design has some advantages:
For example, see the newly added RBAC test for the BackupStorages API. The unit test is very simple, easy to understand and requires mocking only 1 dependency, i.e, the "next" handler.
Implementation details
Handler
- this interface contains the methods that will be called by the API. Each method corresponds to one API call.Handler
interface.validation
handler, then toRBAC
handler and finally tok8s
handler