-
Notifications
You must be signed in to change notification settings - Fork 80
Add an optional workload type field in the component workload spec. #198
Add an optional workload type field in the component workload spec. #198
Conversation
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 idea is really good and interesting, This could also fix #182 I think.
@@ -139,5 +139,5 @@ func (h *ValidatingHandler) InjectDecoder(d *admission.Decoder) error { | |||
// Register will regsiter application configuration validation to webhook | |||
func Register(mgr manager.Manager) { | |||
server := mgr.GetWebhookServer() | |||
server.Register("/validating-applicationconfigurations", &webhook.Admission{Handler: &ValidatingHandler{}}) | |||
server.Register("/validating-core-oam-dev-v1alpha2-applicationconfigurations", &webhook.Admission{Handler: &ValidatingHandler{}}) |
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 would vote for /v1alpha2/validating-applicationconfigurations
if we want to add version in path.
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 we need to come up with a uniformed way for webhooks register in vela. Let's add a PR after this
} | ||
if content[TypeField] != nil { | ||
allErrs = append(allErrs, field.Invalid(fldPath.Child("workload"), obj.Spec.Workload, | ||
fmt.Sprintf("the workload `%+v` is not a CR", obj.Spec.Workload))) |
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.
fmt.Sprintf("the workload `%+v` is not a CR", obj.Spec.Workload))) | |
fmt.Sprintf("the workload `%+v` is not a K8s CR", obj.Spec.Workload))) |
|
||
// ValidateUpdate validates the Component on update | ||
func ValidateUpdate(r *v1alpha2.Component, _ *v1alpha2.Component) field.ErrorList { | ||
validatelog.Info("validate update", "name", r.Name) |
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 validate the same thing like ValidateCreate
Is this PR ready for review? |
ad1378a
to
3c01d27
Compare
The test took me some time to add |
8ffd901
to
36d9a48
Compare
var _ inject.Client = &ValidatingHandler{} | ||
|
||
// InjectClient injects the client into the ComponentValidatingHandler | ||
func (h *ValidatingHandler) InjectClient(c client.Client) error { | ||
h.Client = c | ||
return nil | ||
} | ||
*/ |
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.
don't we need them?
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.
not for the validating handler
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.
Generally LGTM, good job
9a35637
to
4224c23
Compare
Signed-off-by: Ryan Zhang <yangzhangrice@hotmail.com>
4224c23
to
41eb0c6
Compare
Signed-off-by: Ryan Zhang <yangzhangrice@hotmail.com>
Use component webhooks to mutate and validate the component workload spec when workload "type" is used instead of a full CR.
Unit tests added
manually E2E tested