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

[improvement] adding verified clients for validation webhooks #520

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

Conversation

unnatiagg
Copy link
Contributor

@unnatiagg unnatiagg commented Sep 25, 2024

What this PR does / why we need it:
To create verified linodeclients for validation webhooks, we need to have CredRef api tokens for various resources.
This PR tries to create verified clients if the CredRef is set on a particular resource.

To use the K8s client in the validation webhooks, this PR setups up the webhook like func (r *LinodeCluster) SetupWebhookWithManager(mgr ctrl.Manager) error { return ctrl.NewWebhookManagedBy(mgr). For(r). WithValidator(&linodeClusterValidator{Client: mgr.GetClient()}). Complete() }

instead of the approach used previously where the resource itself extends the var _ webhook.Validator = &LinodeCluster{}

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #
All the testcase suites have been updated to use these Validators instead.

Special notes for your reviewer:

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 48.57143% with 90 lines in your changes missing coverage. Please review.

Project coverage is 64.73%. Comparing base (acc1084) to head (2882d22).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
api/v1alpha2/linodecluster_webhook.go 43.24% 18 Missing and 3 partials ⚠️
api/v1alpha2/linodemachine_webhook.go 47.50% 18 Missing and 3 partials ⚠️
api/v1alpha2/linodeplacementgroup_webhook.go 41.66% 18 Missing and 3 partials ⚠️
api/v1alpha2/linodevpc_webhook.go 44.73% 18 Missing and 3 partials ⚠️
api/v1alpha2/webhook_helpers.go 75.00% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #520      +/-   ##
==========================================
- Coverage   65.50%   64.73%   -0.77%     
==========================================
  Files          78       78              
  Lines        4090     4180      +90     
==========================================
+ Hits         2679     2706      +27     
- Misses       1167     1213      +46     
- Partials      244      261      +17     

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

@unnatiagg unnatiagg changed the title [improvement] adding verfied clients for validation webhooks [improvement] adding verified clients for validation webhooks Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants