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

🐛 fix index out of range panic when annotation is not in 'key=value' format #764

Merged

Conversation

lianghao208
Copy link
Member

@lianghao208 lianghao208 commented Jan 18, 2023

When using

+kubebuilder:metadata:annotations="api-approved.kubernetes.io=xxx"

#691 in CRD struct files to generate api-approved annotation, if the annotation is not in metadata:annotations:"xxx=xxx" format, eg:

+kubebuilder:metadata:annotations="api-approved.kubernetes.io: xxx"

it triggers index out of range panic.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 18, 2023
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 18, 2023
@lianghao208 lianghao208 changed the title fix: fix index out of range panic when annotation is not in 'key=value' format bug: fix index out of range panic when annotation is not in 'key=value' format Jan 18, 2023
@lianghao208 lianghao208 changed the title bug: fix index out of range panic when annotation is not in 'key=value' format 🐛 fix index out of range panic when annotation is not in 'key=value' format Jan 18, 2023
@lianghao208 lianghao208 force-pushed the fix-annotation-validation branch 2 times, most recently from e419c12 to 7c7b6ee Compare January 18, 2023 09:39
@JoelSpeed
Copy link
Contributor

Code changes look ok, are there any test cases for the annotation marker that we can update to make sure this is working as expected/we don't regress in the future?

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

That shows great 🥇

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 18, 2023
@lianghao208
Copy link
Member Author

Code changes look ok, are there any test cases for the annotation marker that we can update to make sure this is working as expected/we don't regress in the future?
@JoelSpeed I will add some test cases to cover this scenario

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 19, 2023
@lianghao208
Copy link
Member Author

@JoelSpeed I've add some test cases to cover, PTAL, thanks!

@lianghao208 lianghao208 force-pushed the fix-annotation-validation branch 2 times, most recently from 3ff3df6 to 9c90660 Compare January 19, 2023 03:45
pkg/crd/parser_integration_test.go Outdated Show resolved Hide resolved
pkg/crd/parser_integration_test.go Outdated Show resolved Hide resolved
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

@JoelSpeed,

Great point 👍 I think all is good to fly now.

/lgtm

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

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

/lgtm

@camilamacedo86 camilamacedo86 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 23, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: camilamacedo86, lianghao208

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 merged commit 705eb93 into kubernetes-sigs:master Jan 23, 2023
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants