Repository navigation
🐛 Add apiextensions JSON type to known_types.go - #277
Conversation
|
|
||
| "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1": func(p *Parser, pkg *loader.Package) { | ||
| p.Schemata[TypeIdent{Name: "JSON", Package: pkg}] = apiext.JSONSchemaProps{ | ||
| Type: "string", |
There was a problem hiding this comment.
I'm not 100% sure if the type here should be string or something else - the existing Golang code doesn't actually specify.
cc @sttts any ideas?
There was a problem hiding this comment.
type string is wrong. This is arbitrary JSON, like RawExtension but without Type/ObjectMeta.
There was a problem hiding this comment.
After some testing, I've updated this to object. I think this is correct, although it may not accept data which is a string whereas it probably should given JSON is meant to be completely unstructured.
What's the proper way to set this? It looks like the Kubernetes APIServer exposes an object with a field named Raw of type string in the OpenAPI schema for RawExtension which I think would also be incorrect?
There was a problem hiding this comment.
Also object is wrong. This is pure JSON, any type. In other words, no type should be set at all.
But you have to set x-kubernetes-preserve-unknown-fields: true.
There was a problem hiding this comment.
apiext.JSONSchemaProps{
XPreserveUnknownFields: true,
}
There was a problem hiding this comment.
👍 thanks, so it seems like this requires #276 then!
e758b14 to
401683e
Compare
|
I've updated our repo (cert-manager/cert-manager#1946) to use this, however now run into an issue when installing these CRDs on anything older than Kubernetes 1.15, presumably because the new field on the CRD does not exist before 1.15. With preserveUnknownFields eventually flipping to For controller-tools specifically, I'm not sure how best to proceed. It'd be great if this sort of thing can be handled, but in reality it can't be handled properly yet, so maybe this patch should also be skipped until 1.14 is EOL 🙄 |
What is the issue? Unsupported fields are ignored by the API server. |
|
unsupported fields are ignored by the server, but hated by kubectl due to client-side schema validation, which is on by default. Everyone always seems to forget that, and then it causes headaches down the line. |
|
kubebuilder needs a mode for pruned CRDs. In that case, the |
|
We have 1.15 types now, so this can be updated /hold until then |
401683e to
300f61b
Compare
|
lgtm |
|
Looks like this is ready for merge now, just needs lgtm and approved labels! 😄 /hold cancel |
|
/assign @DirectXMan12 |
3ef7111 to
d30e5fc
Compare
|
Updated to inline the function, mind taking another look @DirectXMan12? |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12, munnerz The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Adds support for the apiextensions-apiserver JSON type.
Without this patch I get the following error:
/cc @DirectXMan12