Skip to content

Commit

Permalink
πŸ› Check to see if custom source implements fmt.Stringer when logging (#…
Browse files Browse the repository at this point in the history
…3068)

* add String() to source interface

Signed-off-by: Troy Connor <[email protected]>

* remove the enforcement of fmt.Stringer

---------

Signed-off-by: Troy Connor <[email protected]>
  • Loading branch information
troy0820 authored Jan 19, 2025
1 parent 8f7e114 commit aafb269
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 aafb269

Please sign in to comment.