🐛 Check to see if custom source implements fmt.Stringer when logging#3068
Conversation
Signed-off-by: Troy Connor <troy0820@users.noreply.github.com>
8ef597e to
707562c
Compare
|
/test pull-controller-runtime-test |
dongjiang1989
left a comment
There was a problem hiding this comment.
Great. Looks very elegant
|
@dongjiang1989: changing LGTM is restricted to collaborators DetailsIn 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-sigs/prow repository. |
| errGroup := &errgroup.Group{} | ||
| for _, watch := range c.startWatches { | ||
| log := c.LogConstructor(nil).WithValues("source", fmt.Sprintf("%s", watch)) | ||
| log := c.LogConstructor(nil).WithValues("source", watch.String()) |
There was a problem hiding this comment.
It is an interesting issue - How about rather then requiring the implementation of fmt.Stringer, we check if it is implemented and if yes use that, otherwise use the Type (i.E. fmt.Sprintf("%T", watch))? That way we avoid the breaking change
|
LGTM label has been added. DetailsGit tree hash: a414c38213cf8ff7a9d5fe0e187d2c9bfbc50d2d |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, dongjiang1989, troy0820 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/cherry-pick release-0.19 |
|
@troy0820: #3068 failed to apply on top of branch "release-0.19": DetailsIn 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-sigs/prow repository. |
|
/cherry-pick release-0.20 |
|
@troy0820: new pull request created: #3077 DetailsIn 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-sigs/prow repository. |
When using a custom source, the error when starting will fail because the
fmt.Stringerinterface is not implemented by the source. The builtin sources have already implanted this interface allow the below line to not fail:Resolves #3057