-
-
Notifications
You must be signed in to change notification settings - Fork 303
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
kube-derive: Disable option_nullable
for CRD generation
#1079
Conversation
I am curious to see if this affects options when running patches. Have you tried experimenting with the |
I have yet to look into the (failing) tests and examples, I mainly opened this for initial discussion, I'll look into it when I get a bit more time. But this change fixed my schema and by the looks of it didn't break anything. |
@clux I forgot about this PR, rebased it. Looks like tests are passing, windows is failing due to missing OpenSSL and coverage failed but all tests passed? I've been running this change in 2 controllers for a while now and didn't have any issues. |
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.
Reading up on this, yes, it seems like it's the right thing to set it to false
. Rust convention is generally to treat null
the same as None
which is almost always deserialized from both null
and missing.
option_nullable
for CRD generationoption_nullable
for CRD generation
option_nullable
for CRD generationoption_nullable
for CRD generation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1079 +/- ##
==========================================
+ Coverage 73.47% 73.52% +0.04%
==========================================
Files 68 68
Lines 5354 5364 +10
==========================================
+ Hits 3934 3944 +10
Misses 1420 1420
|
One other minor point; since by default we are taking out |
Signed-off-by: David Herberth <github@dav1d.de>
I've added a |
yeah, that looks great. Completeness of options in tests so at least people can figure out how to do it, even though we think it's not a common use case. |
That's what I get for adding last second docs, because what can go wrong with docs...
|
Signed-off-by: David Herberth <github@dav1d.de>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
Ran this through some more controllers at $dayjob and noticing that this PR can cause actually issues when you do a server side apply patch on a crd struct with naked options :( Example: api.patch_status(&name, &serverside, &status_struct) where status struct had: struct MyStatus {
pub last_success: Option<Attempt>
} with an unset
this can be fixed by avoiding serializing explicit nulls: struct MyStatus {
+ #[serde(skip_serializing_if = "Option::is_none")]
pub last_success: Option<Attempt>
} which is more inline with how most kubernetes structs work, but unfortunately a little more breaking than intended. |
Mh, that's not good. Not sure what we can do, maybe can hack something togethere where option becomes I think marking it not as nullable is still the correct thing, but it clashing with serde's default behaviour is quite unfortunate. Shall I open a revert PR? |
Not sure. Many Kubernetes resources already implement that skip behaviour (e.g. k8s-openapi#PodSpec), or kopium generated, so it's mostly down to individual CRDs in the wild. We could just focus on telling people to use |
)" This reverts commit 2968e3e.
)" This reverts commit 2968e3e. Signed-off-by: David Herberth <github@dav1d.de>
Fixes: #1078
Check the related issue for discussion.
See https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#defaulting-and-nullable for what this option does.