api/krusty: add SuppressDeprecationWarnings option to suppress lib warnings#6159
Conversation
When kustomize is used as a Go library, deprecation warnings about fields like 'bases', 'vars', 'patchesJson6902', etc. are printed to os.Stderr unconditionally. For library consumers that manage their own output, this produces unwanted noise that cannot be suppressed. Add SuppressDeprecationWarnings bool to krusty.Options. When true, the fmt.Fprintf(os.Stderr, ...) calls inside KustTarget.Load are skipped. The default is false, preserving existing behavior. Fixes kubernetes-sigs#5452 Signed-off-by: santoshguru-11 <darbhasantosh11@gmail.com>
|
Invalid commit message issues detected Invalid commit messagesKeywords which can automatically close issues and hashtag(#) mentions are not allowed.
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-sigs/prow repository. I understand the commands that are listed here. |
|
Welcome @santoshguru-11! |
|
Hi @santoshguru-11. 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: santoshguru-11 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 |
Summary
When kustomize is used as a Go library (calling
krusty.MakeKustomizer(...).Run(...)), deprecation warnings for fields likebases,vars,patchesJson6902,patchesStrategicMerge,commonLabels, etc. are unconditionally written toos.Stderr. Library consumers that control their own output have no way to silence this noise.Changes
SuppressDeprecationWarnings booltokrusty.OptionsKustTargetvia a newSetSuppressDeprecationWarningssetterfmt.Fprintf(os.Stderr, ...)calls inKustTarget.Load()when the option istruefalse— no change in behavior for existing callersTest
Added
TestSuppressDeprecationWarningsinapi/krusty/kustomizer_test.gothat:basesfield and asserts a warning appears on stderr by defaultSuppressDeprecationWarnings: trueand asserts stderr is emptyFixes
Fixes #5452