Skip to content

Commit

Permalink
remove the enforcement of fmt.Stringer
Browse files Browse the repository at this point in the history
  • Loading branch information
troy0820 committed Jan 19, 2025
1 parent 707562c commit 57a711c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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", watch.String())
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
4 changes: 0 additions & 4 deletions pkg/source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ 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

0 comments on commit 57a711c

Please sign in to comment.