Skip to content

Commit

Permalink
馃悰 correct kind source type
Browse files Browse the repository at this point in the history
Reverse the nil check in the String function of the internal Kind source
to print the type when known.

Fixes: 2add01e ("Event, source, handler, predicates: Use generics")
Signed-off-by: Terin Stock <terinjokes@gmail.com>
  • Loading branch information
terinjokes authored and k8s-infra-cherrypick-robot committed May 1, 2024
1 parent d6feaae commit 06acde3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions pkg/internal/source/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ var _ = Describe("Internal", func() {
instance.OnDelete(Foo{})
})
})

Describe("Kind", func() {
It("should return kind source type", func() {
kind := internal.Kind[*corev1.Pod]{
Type: &corev1.Pod{},
}
Expect(kind.String()).Should(Equal("kind source: *v1.Pod"))
})
})
})

type Foo struct{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/internal/source/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (ks *Kind[T]) Start(ctx context.Context, queue workqueue.RateLimitingInterf
}

func (ks *Kind[T]) String() string {
if isNil(ks.Type) {
if !isNil(ks.Type) {
return fmt.Sprintf("kind source: %T", ks.Type)
}
return "kind source: unknown type"
Expand Down

0 comments on commit 06acde3

Please sign in to comment.