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 validation for customresourcedefintions #45556

Merged
merged 1 commit into from
May 11, 2017

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented May 9, 2017

Add basic validation for customresource definitions.

@adohe if you had review bandwidth, this is a relatively small one.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 9, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels May 9, 2017
ret := genericvalidation.NameIsDNSSubdomain(name, prefix)
requiredName := obj.Spec.Names.Plural + "." + obj.Spec.Group
if name != requiredName {
ret = append(ret, fmt.Sprintf(`must be spec.names.plural+"."+spec.group `))
Copy link
Contributor

Choose a reason for hiding this comment

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

no space after group

return allErrs
}

func ValidateCustomResourceNames(names *apiextensions.CustomResourceNames, fldPath *field.Path) field.ErrorList {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to allow empty Kind and Plural? Plural could be derived from the CustomResource name, but Kind?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want to allow empty Kind and Plural? Plural could be derived from the CustomResource name, but Kind?

This used by status validation too. Status may not have all these field set. If they are set, they must be valid, but if they are not set how to handle that varies with where the field is embedded. See the spec validation above.

Also, no information is derived post-defaulting: #45561

@sttts
Copy link
Contributor

sttts commented May 10, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 10, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deads2k, sttts
We suggest the following additional approver: smarterclayton

Assign the PR to them by writing /assign @smarterclayton in a comment when ready.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@sttts sttts added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels May 10, 2017
@deads2k
Copy link
Contributor Author

deads2k commented May 10, 2017

its the api-extensions thing again: #45490 approving

@deads2k deads2k added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 10, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 3126e73 into kubernetes:master May 11, 2017
@deads2k deads2k deleted the tpr-10-validation branch August 3, 2017 20:08
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. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants