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 committed May 1, 2024
1 parent 24cc51f commit 4c19a76
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 4c19a76

Please sign in to comment.