Replies: 3 comments
-
|
Hi @jenshu, Saw this issue a while ago, and I just tried to brainstorm a bit about it, especially looking at the API guidelines you posted. The main questions I see coming up from your examples are things like:
One way to move this forward might be to make the expectations more explicit in the API guidelines, for example, spelling out when If it would be helpful, I’d be glad to draft a documentation-focused update to Happy to follow whatever direction makes the most sense for the task though. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @Mike-4-prog thanks for the offer! I think that before we update the docs, we need to come to a consensus on what the guidelines should be. I think I'm going to convert this to a discussion so that maintainers and others can weigh in. Once we've made a decision, we'd be glad to have you update the docs if you are interested! |
Beta Was this translation helpful? Give feedback.
-
|
cc @howardjohn @shashankram @lgadban as well since this has come up a couple of times. Would be good to formalize our guidance on defaulting here. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently/historically we've handled default values in our API in a few different ways:
+kubebuilder:defaultmarker in the API docs (which will set a default value in the CRD); in the code, assume that the value is always set (i.e. no need for nil checks or further defaulting in the code)+kubebuilder:defaultin the API and add redundant defaulting in the code (in this case, it's possible for the defaults in the CRD and code to get out of sync, and one can argue that the defaulting in code is unnecessary since the field will already have a default from the CRD)We should come up with a formalized policy on how to deal with defaults, and update the API guidelines and code to follow the policy (possibly even add a linter if applicable).
Keep in mind the following scenarios:
Beta Was this translation helpful? Give feedback.
All reactions