🐛 pkg/envtest: validate config when handling CRDs#3512
🐛 pkg/envtest: validate config when handling CRDs#3512orangecms wants to merge 1 commit intokubernetes-sigs:mainfrom
Conversation
|
Welcome @orangecms! |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: orangecms The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @orangecms. 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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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-sigs/prow repository. |
cb6494a to
a8d8086
Compare
The error message is adapted from pkg/client. Otherwise, if nil is passed, it crashes with a longer stack trace. Signed-off-by: Daniel Maslowski <info@orangecms.org>
a8d8086 to
c2f605f
Compare
|
|
||
| // InstallCRDs installs a collection of CRDs into a cluster by reading the crd yaml files from a directory. | ||
| func InstallCRDs(config *rest.Config, options CRDInstallOptions) ([]*apiextensionsv1.CustomResourceDefinition, error) { | ||
| if config == nil { |
There was a problem hiding this comment.
hi @orangecms, thanks for trying to help out but I am not in favor of merging this. Assuming that nil is a valid value for pointer arguments to a function or method when the arg is not explicitly documented as such is generally wrong and a programming mistake. Panicing is how the function signals this so the author can correct that mistake.
If you look at the go stdlib, you will find that nilchecking parameters is not commonly done.
/hold
There was a problem hiding this comment.
Hi, can you help me understand?
pkg/client does have that check, so it would be inconsistent to sometimes have the check, sometimes not.
Wouldn't the error returned be what allows for graceful handling and obtaining an understanding of the error? What would otherwise be the reason to have nil checks, such as in pkg/client?
There was a problem hiding this comment.
Yep, seems to be an oversight, the rest of the codebase doesn't have such checks and we don't plan on changing that.
The error message is adapted from pkg/client.
Otherwise, if nil is passed, it crashes with a longer stack trace.
See https://mastodon.social/@CyReVolt/116507340236420167