-
Notifications
You must be signed in to change notification settings - Fork 27
feat: add CEL validation rules to MemberCluster taint API types #478
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,6 @@ import ( | |
|
|
||
| clusterv1beta1 "github.com/kubefleet-dev/kubefleet/apis/cluster/v1beta1" | ||
| "github.com/kubefleet-dev/kubefleet/pkg/utils" | ||
| "github.com/kubefleet-dev/kubefleet/pkg/utils/validator" | ||
|
|
||
| fleetnetworkingv1alpha1 "go.goms.io/fleet-networking/api/v1alpha1" | ||
| ) | ||
|
|
@@ -78,14 +77,8 @@ func (v *memberClusterValidator) Handle(ctx context.Context, req admission.Reque | |
| return admission.Allowed("Member cluster is ready to leave") | ||
| } | ||
|
|
||
| if err := v.decoder.Decode(req, &mc); err != nil { | ||
| klog.ErrorS(err, "Failed to decode member cluster object for validating fields", "userName", req.UserInfo.Username, "groups", req.UserInfo.Groups) | ||
| return admission.Errored(http.StatusBadRequest, err) | ||
| } | ||
|
|
||
| if err := validator.ValidateMemberCluster(mc); err != nil { | ||
| klog.V(2).ErrorS(err, "Member cluster has invalid fields, request is denied", "operation", req.Operation, "memberCluster", mcObjectName) | ||
| return admission.Denied(err.Error()) | ||
| } | ||
| // Taint validation is now handled by CRD-level CEL validation rules. | ||
| // CREATE/UPDATE requests with invalid taints are rejected at schema | ||
| // validation time before reaching this webhook. | ||
| return admission.Allowed("Member cluster has valid fields") | ||
|
Comment on lines
+80
to
83
|
||
| } | ||
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.
The CEL validation for name and label seem too complex ? Currently we depend on validation functions provided by k8s which guarantee that we are following established conventions once this CEL validation is merged we would also need to maintain consistency between our validation and k8s (very unlikely but still something to keep in mind)