-
Notifications
You must be signed in to change notification settings - Fork 20
fix: fix the validation webhook #359
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
base: main
Are you sure you want to change the base?
fix: fix the validation webhook #359
Conversation
Signed-off-by: Ryan Zhang <yangzhangrice@hotmail.com>
zhiying-lin
left a comment
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.
Need to update our e2e join & leave tests
| "sigs.k8s.io/controller-runtime/pkg/webhook/admission" | ||
| ) | ||
|
|
||
| func TestHandleDeleteServiceExportValidation(t *testing.T) { |
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.
| func TestHandleDeleteServiceExportValidation(t *testing.T) { | |
| func TestHandle_Delete(t *testing.T) { |
nit
| networkingEnabled bool | ||
| expectAllowed bool | ||
| expectedMessageSubstr string | ||
| validationMode clusterv1beta1.DeleteValidationMode |
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.
| networkingEnabled bool | |
| expectAllowed bool | |
| expectedMessageSubstr string | |
| validationMode clusterv1beta1.DeleteValidationMode | |
| networkingEnabled bool | |
| validationMode clusterv1beta1.DeleteValidationMode | |
| wantAllowed bool | |
| wantMessageSubstr string |
prefer "want" instead of expected
Where you would write “actual” and “expected”, prefer using the words “got” and “want”, respectively.
https://google.github.io/styleguide/go/decisions#got-before-want
|
|
||
| resp := validator.Handle(context.Background(), req) | ||
| if resp.Allowed != tc.expectAllowed { | ||
| t.Fatalf("expected allowed=%t but got response: %+v", tc.expectAllowed, resp) |
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.
| t.Fatalf("expected allowed=%t but got response: %+v", tc.expectAllowed, resp) | |
| t.Fatalf("Handle() got response: %+v, want allowed %t", resp, tc.expectAllowed) |
Test outputs should output the actual value that the function returned before printing the value that was expected. A usual format for printing test outputs is “YourFunc(%v) = %v, want %v”.
| } | ||
| if tc.expectedMessageSubstr != "" { | ||
| if resp.Result == nil || !strings.Contains(resp.Result.Message, tc.expectedMessageSubstr) { | ||
| t.Fatalf("expected message to contain %q but got: %v", tc.expectedMessageSubstr, resp.Result) |
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.
| t.Fatalf("expected message to contain %q but got: %v", tc.expectedMessageSubstr, resp.Result) | |
| t.Fatalf("Handle() got response result: %v, want contain: %q", resp.Result, tc.expectedMessageSubstr) |
Description of your changes
Skip the serviceExport check if the neworking is not enabled.
Fixes: When trhe networking is not enabled. The list serviceExport call fails
I have:
make reviewableto ensure this PR is ready for review.How has this code been tested
Special notes for your reviewer