From aa3f3426e4902c7808d76c1b38ec4e95f2959073 Mon Sep 17 00:00:00 2001 From: k8s-infra-cherrypick-robot <90416843+k8s-infra-cherrypick-robot@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:30:35 -0800 Subject: [PATCH] =?UTF-8?q?[release-0.20]=20=F0=9F=90=9B=20Check=20to=20se?= =?UTF-8?q?e=20if=20custom=20source=20implements=20fmt.Stringer=20when=20l?= =?UTF-8?q?ogging=20(#3077)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add String() to source interface Signed-off-by: Troy Connor * remove the enforcement of fmt.Stringer --------- Signed-off-by: Troy Connor Co-authored-by: Troy Connor --- pkg/internal/controller/controller.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/internal/controller/controller.go b/pkg/internal/controller/controller.go index fda25e0641..25575cca7c 100644 --- a/pkg/internal/controller/controller.go +++ b/pkg/internal/controller/controller.go @@ -175,7 +175,16 @@ func (c *Controller[request]) Start(ctx context.Context) error { // caches. errGroup := &errgroup.Group{} for _, watch := range c.startWatches { - log := c.LogConstructor(nil).WithValues("source", fmt.Sprintf("%s", watch)) + log := c.LogConstructor(nil) + _, ok := watch.(interface { + String() string + }) + + if !ok { + log = log.WithValues("source", fmt.Sprintf("%T", watch)) + } else { + log = log.WithValues("source", fmt.Sprintf("%s", watch)) + } didStartSyncingSource := &atomic.Bool{} errGroup.Go(func() error { // Use a timeout for starting and syncing the source to avoid silently