-
Notifications
You must be signed in to change notification settings - Fork 426
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
🐛Add FieldOnlyMarkers to AllDefinitions and update Nullable #228
Conversation
99519a8
to
1680e04
Compare
Want to note that in debugging this, by inspecting the schema props around here https://github.com/kubernetes-sigs/controller-tools/blob/master/pkg/crd/schema.go#L378 I do see |
Update: the nullable problem I saw is fixed by #226 |
@@ -222,6 +224,6 @@ func (m Type) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error { | |||
func (m Type) ApplyFirst() {} | |||
|
|||
func (m Nullable) ApplyToSchema(schema *v1beta1.JSONSchemaProps) error { | |||
schema.Nullable = bool(m) | |||
schema.Nullable = true |
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.
why true? Can we write nullable: false
?
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 currently // +nullable
is only used to set nullable: true
, and as we've seen a lack of this field already implies that it cannot be nullable. Also, if we do want to allow // +nullable=false
then all other existing usages of the nullable tag would have to be updated to // +nullable=true
, or they would raise a missing parameter error when being parsed.
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.
ok, fine with me.
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.
you could technically make this a bool pointer if you wanted that
Adding a test case to the integration test data (recently merged, in |
Currently the `+optional` and `+nullable` markers don't work. I've fixed `optional` by making sure the `FieldOnlyMarkers` slice that was added in kubernetes-sigs#211 actually gets added to `AllDefinitions`. In the current code, `+nullable` would actually only be recognized as `+kubebuilder:validation:Nullable=true`, so I'm updating this to be more consistent with what's expected for that marker.
The parser integration test now has a better message about what to do if the output changes and how to regenerate it.
added test case, instructions for updating the integration test. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: damemi, DirectXMan12 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Currently the
+optional
and+nullable
markers don't work. I've fixedoptional
by making sure theFieldOnlyMarkers
slice that was added in #211 actually gets added toAllDefinitions
. In the current code,+nullable
would actually only be recognized as+kubebuilder:validation:Nullable=true
, so I'm updating this to be more consistent with what's expected for that marker.However, I still can't get nullable to be generated in the output CRD, so I would appreciate some input on this