-
Notifications
You must be signed in to change notification settings - Fork 284
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
Add management cluster name validation to controller #4901
Conversation
/hold |
Codecov Report
@@ Coverage Diff @@
## main #4901 +/- ##
==========================================
+ Coverage 71.61% 71.66% +0.04%
==========================================
Files 419 420 +1
Lines 34198 34210 +12
==========================================
+ Hits 24492 24515 +23
+ Misses 8177 8167 -10
+ Partials 1529 1528 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
f70fc60
to
eaacb4c
Compare
/unhold |
@@ -67,7 +67,7 @@ func newVsphereClusterReconcilerTest(t *testing.T, objs ...runtime.Object) *vsph | |||
Add(anywherev1.VSphereDatacenterKind, reconciler). | |||
Build() | |||
|
|||
r := controllers.NewClusterReconciler(cl, ®istry, iam) | |||
r := controllers.NewClusterReconciler(cl, ®istry, iam, clusters.NewClusterValidator(cl)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use the mock cluster validator for the tests in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh looks like I missed this file, thanks for pointing it out!
eaacb4c
to
7066352
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
// ClusterValidator runs cluster level preflight validations before it goes to provider reconciler. | ||
type ClusterValidator interface { | ||
ValidateManagementClusterName(ctx context.Context, log logr.Logger, cluster *anywherev1.Cluster) error | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may clash with the ClusterValidator located in the e2e tests, as it serves a similar purpose. The idea was to use it in the main code eventually, so we may have to merge them at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be fine for now because they are independent enough, don't expect the interface to clash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment FYI
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vivek-koppuru The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
1 similar comment
/retest |
Issue #, if available:
Description of changes:
This is the same validation from #4596 except from the controller side. Made some minor refactoring as well as fix a mockgen issue due to golang/mock#494, from which I followed https://github.com/golang/mock#reflect-vendoring-error
Chose to do validation in controller instead of webhook as we have access to client there that will allow us to retrieve the older object.
Testing (if applicable):
functional testing and unit testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.