AdmissionController question - We’re trying to implement a validation admission webhook on top of an existing resource type. The idea is to layer this new webhook on top of the existing CRD webhook (which is also using a knative controller) to add extra optional validation.
Our hope was to use the existing
validation.NewAdmissionController so we could reuse all the webhook config reconciling behavior, but we can’t use the existing CRD types directly since Knative will just invoke the CRDs Validatable interface.
One idea we had to get around this was to set up the handlers to point to a new type that embeds the underlying CRD - e.g. something like:
```
type customMyKindValidate struct {
v1beta1.MyKind
}
func (*customMyKindValidate) Validate(ctx context.Context) *apis.FieldError {
...
}
validation.NewAdmissionController(ctx,
name,
"/validate",
v1beta1.SchemeGroupVersion.WithKind("MyKind"): &customMyKindValidate{},
...
)
```
We weren’t sure if this was the best approach since we’d have to reimplement client-go generated funcs like `DeepObjectCopy` for things to play nice.
We're also looking at the
Callback type and could just remarshal the Unstructured type into the expected type, but we weren't sure if this was a good fit either.
Thoughts on either approach? Is there something else we should consider instead?