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

❇️ pkg/internal/codegen/parse: "Title" CRD validation annotation #182

Closed
wants to merge 2 commits into from

Conversation

estroz
Copy link
Contributor

@estroz estroz commented Apr 10, 2019

This PR implements the SchemaProps.Title field as an annotation: +kubebuilder:validation:Title="some title", where the quoted string following = is stripped of surrounding quotes and interpreted literally as a field's title. This validation is not inherited by child props.

Reference: #156 (comment)

/cc @mengqiy @DirectXMan12 @droot

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: estroz
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: droot

If they are not already assigned, you can assign the PR to them by writing /assign @droot in a comment when ready.

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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 10, 2019
Copy link
Contributor

@DirectXMan12 DirectXMan12 left a comment

Choose a reason for hiding this comment

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

no general objections, but the string parsing logic is a bit wonky

title := strings.TrimSpace(strings.Join(parts[1:], " "))
if len(title) > 2 {
// Remove beginning and ending quote from non-empty strings.
if title[0] == '"' {
Copy link
Contributor

Choose a reason for hiding this comment

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

this accepts Title=foo", which doesn't seem to be valid. Also, Title=f should probably be valid. I think we may need to hold on here a bit and define more format parsing semantics for our markers (I've got some stuff in the works that I'll post soon).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could simply require string fields be wrapped in "" and anything inside will be interpreted literally.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've got parsing logic written. We should be consistent across our different annotations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has it been merged?

Copy link
Contributor

Choose a reason for hiding this comment

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

not yet, it's part of a broader overhaul being tracked on the crdgenerator feature branch

@estroz estroz changed the title ✨ pkg/internal/codegen/parse: "Title" CRD validation annotation ❇️ pkg/internal/codegen/parse: "Title" CRD validation annotation Apr 11, 2019
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 11, 2019
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 9, 2019
@k8s-ci-robot
Copy link
Contributor

@estroz: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@DirectXMan12
Copy link
Contributor

this is integrated into v0.2.0, so it should be all set now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

None yet

3 participants