Skip to content
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

Merged
merged 2 commits into from
Jun 27, 2019

Conversation

damemi
Copy link
Contributor

@damemi damemi commented Jun 19, 2019

Currently the +optional and +nullable markers don't work. I've fixed optional by making sure the FieldOnlyMarkers slice that was added in #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.

However, I still can't get nullable to be generated in the output CRD, so I would appreciate some input on this

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 19, 2019
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 19, 2019
@damemi damemi force-pushed the fix-tags branch 2 times, most recently from 99519a8 to 1680e04 Compare June 19, 2019 16:23
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 19, 2019
@damemi
Copy link
Contributor Author

damemi commented Jun 19, 2019

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 nullable: true being set on fields that have it, but still not showing up in the final generated output. Also if I manually set propSchema.Nullable = true around that area, I do see nullable in the generated output. But not if I put it in a conditional (ie, checking for field.Markers.Get("nullable"), which returns true and sets the schema, but not in the final output)

@damemi damemi changed the title [wip] 🐛Add FieldOnlyMarkers to AllDefinitions and update Nullable 🐛Add FieldOnlyMarkers to AllDefinitions and update Nullable Jun 19, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 19, 2019
@damemi
Copy link
Contributor Author

damemi commented Jun 21, 2019

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, fine with me.

Copy link
Contributor

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

@DirectXMan12
Copy link
Contributor

Adding a test case to the integration test data (recently merged, in pkg/crd/testdata). Otherwise lgtm.

damemi and others added 2 commits June 27, 2019 14:54
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.
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 27, 2019
@DirectXMan12
Copy link
Contributor

added test case, instructions for updating the integration test.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 27, 2019
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 27, 2019
@k8s-ci-robot k8s-ci-robot merged commit cf8f8c9 into kubernetes-sigs:master Jun 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants