Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ 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).WithValues("source", watch.String())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

didStartSyncingSource := &atomic.Bool{}
errGroup.Go(func() error {
// Use a timeout for starting and syncing the source to avoid silently
Expand Down
4 changes: 4 additions & 0 deletions pkg/source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ type TypedSource[request comparable] interface {
// Start is internal and should be called only by the Controller to start the source.
// Start must be non-blocking.
Start(context.Context, workqueue.TypedRateLimitingInterface[request]) error

// String enforces the custom source to adhere to the fmt.Stringer interface
// to print when being logged.
String() string
}

// SyncingSource is a source that needs syncing prior to being usable. The controller
Expand Down
Loading