Skip to content

Commit 57a711c

Browse files
committed
remove the enforcement of fmt.Stringer
1 parent 707562c commit 57a711c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pkg/internal/controller/controller.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,16 @@ func (c *Controller[request]) Start(ctx context.Context) error {
175175
// caches.
176176
errGroup := &errgroup.Group{}
177177
for _, watch := range c.startWatches {
178-
log := c.LogConstructor(nil).WithValues("source", watch.String())
178+
log := c.LogConstructor(nil)
179+
_, ok := watch.(interface {
180+
String() string
181+
})
182+
183+
if !ok {
184+
log = log.WithValues("source", fmt.Sprintf("%T", watch))
185+
} else {
186+
log = log.WithValues("source", fmt.Sprintf("%s", watch))
187+
}
179188
didStartSyncingSource := &atomic.Bool{}
180189
errGroup.Go(func() error {
181190
// Use a timeout for starting and syncing the source to avoid silently

pkg/source/source.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ type TypedSource[request comparable] interface {
5656
// Start is internal and should be called only by the Controller to start the source.
5757
// Start must be non-blocking.
5858
Start(context.Context, workqueue.TypedRateLimitingInterface[request]) error
59-
60-
// String enforces the custom source to adhere to the fmt.Stringer interface
61-
// to print when being logged.
62-
String() string
6359
}
6460

6561
// SyncingSource is a source that needs syncing prior to being usable. The controller

0 commit comments

Comments
 (0)