From 06acde32d542baf9fffdbcb33764928280480c0a Mon Sep 17 00:00:00 2001 From: Terin Stock Date: Wed, 1 May 2024 11:59:33 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20correct=20kind=20source=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverse the nil check in the String function of the internal Kind source to print the type when known. Fixes: 2add01e7 ("Event, source, handler, predicates: Use generics") Signed-off-by: Terin Stock --- pkg/internal/source/internal_test.go | 9 +++++++++ pkg/internal/source/kind.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/internal/source/internal_test.go b/pkg/internal/source/internal_test.go index f71be58424..e25315ffcc 100644 --- a/pkg/internal/source/internal_test.go +++ b/pkg/internal/source/internal_test.go @@ -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{} diff --git a/pkg/internal/source/kind.go b/pkg/internal/source/kind.go index 03431d1d24..3a8db96e3c 100644 --- a/pkg/internal/source/kind.go +++ b/pkg/internal/source/kind.go @@ -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"