From a953539fb57b2ee18337f323ef15425a4d6207ed Mon Sep 17 00:00:00 2001 From: Lukasz Szaszkiewicz Date: Mon, 11 Mar 2024 12:56:40 +0100 Subject: [PATCH] client-go/cache/reflector: use metav1.InitialEventsAnnotationKey --- .../src/k8s.io/client-go/tools/cache/reflector.go | 2 +- .../tools/cache/reflector_watchlist_test.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/staging/src/k8s.io/client-go/tools/cache/reflector.go b/staging/src/k8s.io/client-go/tools/cache/reflector.go index f733e244ccc..14221cd2400 100644 --- a/staging/src/k8s.io/client-go/tools/cache/reflector.go +++ b/staging/src/k8s.io/client-go/tools/cache/reflector.go @@ -780,7 +780,7 @@ loop: } case watch.Bookmark: // A `Bookmark` means watch has synced here, just update the resourceVersion - if meta.GetAnnotations()["k8s.io/initial-events-end"] == "true" { + if meta.GetAnnotations()[metav1.InitialEventsAnnotationKey] == "true" { if exitOnInitialEventsEndBookmark != nil { *exitOnInitialEventsEndBookmark = true } diff --git a/staging/src/k8s.io/client-go/tools/cache/reflector_watchlist_test.go b/staging/src/k8s.io/client-go/tools/cache/reflector_watchlist_test.go index 76eacb5a515..a2eec9193f4 100644 --- a/staging/src/k8s.io/client-go/tools/cache/reflector_watchlist_test.go +++ b/staging/src/k8s.io/client-go/tools/cache/reflector_watchlist_test.go @@ -174,7 +174,7 @@ func TestWatchList(t *testing.T) { {Type: watch.Bookmark, Object: &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ ResourceVersion: "2", - Annotations: map[string]string{"k8s.io/initial-events-end": "true"}, + Annotations: map[string]string{metav1.InitialEventsAnnotationKey: "true"}, }, }}, }, @@ -203,7 +203,7 @@ func TestWatchList(t *testing.T) { {Type: watch.Bookmark, Object: &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ ResourceVersion: "5", - Annotations: map[string]string{"k8s.io/initial-events-end": "true"}, + Annotations: map[string]string{metav1.InitialEventsAnnotationKey: "true"}, }, }}, }, @@ -241,7 +241,7 @@ func TestWatchList(t *testing.T) { {Type: watch.Bookmark, Object: &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ ResourceVersion: "2", - Annotations: map[string]string{"k8s.io/initial-events-end": "true"}, + Annotations: map[string]string{metav1.InitialEventsAnnotationKey: "true"}, }, }}, }, @@ -279,7 +279,7 @@ func TestWatchList(t *testing.T) { {Type: watch.Bookmark, Object: &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ ResourceVersion: "1", - Annotations: map[string]string{"k8s.io/initial-events-end": "true"}, + Annotations: map[string]string{metav1.InitialEventsAnnotationKey: "true"}, }, }}, }, @@ -310,7 +310,7 @@ func TestWatchList(t *testing.T) { {Type: watch.Bookmark, Object: &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ ResourceVersion: "2", - Annotations: map[string]string{"k8s.io/initial-events-end": "true"}, + Annotations: map[string]string{metav1.InitialEventsAnnotationKey: "true"}, }, }}, {Type: watch.Added, Object: makePod("p3", "3")}, @@ -351,7 +351,7 @@ func TestWatchList(t *testing.T) { {Type: watch.Bookmark, Object: &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ ResourceVersion: "2", - Annotations: map[string]string{"k8s.io/initial-events-end": "true"}, + Annotations: map[string]string{metav1.InitialEventsAnnotationKey: "true"}, }, }}, {Type: watch.Added, Object: makePod("p3", "3")}, @@ -382,7 +382,7 @@ func TestWatchList(t *testing.T) { {Type: watch.Bookmark, Object: &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ ResourceVersion: "2", - Annotations: map[string]string{"k8s.io/initial-events-end": "false"}, + Annotations: map[string]string{metav1.InitialEventsAnnotationKey: "false"}, }, }}, },