From 45e17fede08496913c4ce21def96bdff28987d76 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 Kubernetes-commit: a953539fb57b2ee18337f323ef15425a4d6207ed --- tools/cache/reflector.go | 2 +- tools/cache/reflector_watchlist_test.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/cache/reflector.go b/tools/cache/reflector.go index f733e244..14221cd2 100644 --- a/tools/cache/reflector.go +++ b/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/tools/cache/reflector_watchlist_test.go b/tools/cache/reflector_watchlist_test.go index 76eacb5a..a2eec919 100644 --- a/tools/cache/reflector_watchlist_test.go +++ b/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"}, }, }}, },