-
Notifications
You must be signed in to change notification settings - Fork 422
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
✨ Return error when CRD has multiple versions marked for storage #820
Conversation
Welcome @lauchokyip! |
Hi @lauchokyip. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lauchokyip The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cc @camilamacedo86 |
/cc @estroz |
packages[0].AddError(fmt.Errorf("CRD for %s has no storage version", groupKind)) | ||
errs = append(errs, fmt.Errorf("CRD for %s has no storage version", groupKind)) |
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 was this changed?
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.
can we pass the package in here and use AddError as before?
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.
@vincepri I was following this PR
https://github.com/kubernetes-sigs/controller-tools/pull/399/files#diff-05d11052b3234e4c8ce76c9362508cbd5c3f275a76ee2513240234ed879cb2b5L151-R163
Should I stick with that approach or the one you suggested? I think both should work
See the comment belowThere 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.
@vincepri I wouldn't recommend to pass the package into the function because it would complicate the unit test writing ( need to setup a package loader and make it harder to compare the error string. In addition to that, the package loader would throw more error if the user has not have the package installed) . I would keep the function loosely coupled by not including package
. Both should achieve the some results
Please let me know what you think
if hasStorage { | ||
errs = append(errs, fmt.Errorf("CRD for %s has more than one storage version", groupKind)) |
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.
Could we collect all the storage versions in a set and error out with information on where the storage flag is set?
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.
@vincepri
Wondering how should the map looks like? map[bool]bool
? The value we are checking are just boolean value with the same type
https://github.com/kubernetes-sigs/controller-tools/pull/820/files#diff-a205d1d131ac7079cecfe9264fd82b9c7b56f982a42b4085fc4a963734cb9c2cR101-R106
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.
sets.New[String] should do it?
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 there is a misunderstanding here.
when you loop through different version, it would be something like v1
, v2
, v3
, and if we put them all in the set, it would be something like set{"v1,"v2", "v3"}
. Enough though the version is not duplicated, there are still possible that v1 has storageversion set and v2 has storageversion set. Storage Version is a boolean value, not a string, making it a map would be map{"v1": true,"v2": true, "v3": false}
, I don't think there is a need to use a set or map.
We would only need to check if the boolean is triggered twice, that should be more than enough
Please take a look at the unit test https://github.com/kubernetes-sigs/controller-tools/pull/820/files#diff-a205d1d131ac7079cecfe9264fd82b9c7b56f982a42b4085fc4a963734cb9c2cR100 , the Version is a string and the Storage is a boolean
/ok-to-test |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
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. |
Continue the work from #399, which will be beneficial for this kubebuilder issue kubernetes-sigs/kubebuilder#2589 too