✨feat: add non-fatal warning system for code generation diagnostics#1416
✨feat: add non-fatal warning system for code generation diagnostics#1416mattsu2020 wants to merge 1 commit into
Conversation
|
Welcome @mattsu2020! |
|
Hi @mattsu2020. 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 Regular contributors should join the org to skip this step. 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mattsu2020 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 |
|
I wonder if producing findings like this should be rather implemented in kube-api-linter @JoelSpeed WDYT? |
|
Thanks I looked into kube-api-linter and I agree this check fits better there than in controller-tools. There is already a I can move the actual API-convention check to kube-api-linter, likely as a |
Add a warning infrastructure that mirrors the existing error reporting system but is non-fatal. The first use case is warning about pointers as map values, which is supported but not recommended per Kubernetes API conventions. - Add Package.Warnings field and AddWarning method to pkg/loader - Add PrintWarnings and VisitPackages helper functions - Add Runtime.PrintWarnings method to pkg/genall - Call PrintWarnings after successful generation in controller-gen - Emit warning when pointers are used as map values in CRD schemas - Add tests for pointer map value warning and non-warning cases
Summary
This PR implements the warning system requested in #434 by adding a non-fatal warning infrastructure that mirrors the existing error reporting system.
Package.Warningsfield andAddWarning()method topkg/loader, following the same error type dispatch pattern asAddError()PrintWarnings()andVisitPackages()helper functions topkg/loaderRuntime.PrintWarnings()method topkg/genalland call it after successful generation incontroller-genmap[string]*string), which is supported but not recommended per Kubernetes API conventionsTest plan
go build ./...passesgo test ./pkg/loader/...— 11/11 passedgo test ./pkg/crd/...— all passed (including newTest_Schema_PointerMapValue_WarningandTest_Schema_NonPointerMapValue_NoWarning)controller-genagainst a type withmap[string]*stringand verify warning output on stderrCloses: #434