Skip to content

Commit

Permalink
[release-0.20] šŸ› Check to see if custom source implements fmt.Stringeā€¦
Browse files Browse the repository at this point in the history
ā€¦r when logging (#3077)

* add String() to source interface

Signed-off-by: Troy Connor <troy0820@users.noreply.github.com>

* remove the enforcement of fmt.Stringer

---------

Signed-off-by: Troy Connor <troy0820@users.noreply.github.com>
Co-authored-by: Troy Connor <troy0820@users.noreply.github.com>
  • Loading branch information
k8s-infra-cherrypick-robot and troy0820 authored Jan 20, 2025
1 parent 8f7e114 commit aa3f342
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aa3f342

Please sign in to comment.