apiserver/storage: use metav1.InitialEventsAnnotationKey const
This commit is contained in:
		@@ -579,7 +579,7 @@ func TestCacheWatcherDrainingNoBookmarkAfterResourceVersionSent(t *testing.T) {
 | 
			
		||||
		{Type: watch.Bookmark, Object: &v1.Pod{
 | 
			
		||||
			ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
				ResourceVersion: "10",
 | 
			
		||||
				Annotations:     map[string]string{"k8s.io/initial-events-end": "true"},
 | 
			
		||||
				Annotations:     map[string]string{metav1.InitialEventsAnnotationKey: "true"},
 | 
			
		||||
			},
 | 
			
		||||
		}},
 | 
			
		||||
		{Type: watch.Added, Object: makePod(15)},
 | 
			
		||||
 
 | 
			
		||||
@@ -1926,7 +1926,7 @@ func TestDoNotPopExpiredWatchersWhenNoEventsSeen(t *testing.T) {
 | 
			
		||||
		{Type: watch.Bookmark, Object: &example.Pod{
 | 
			
		||||
			ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
				ResourceVersion: "102",
 | 
			
		||||
				Annotations:     map[string]string{"k8s.io/initial-events-end": "true"},
 | 
			
		||||
				Annotations:     map[string]string{metav1.InitialEventsAnnotationKey: "true"},
 | 
			
		||||
			},
 | 
			
		||||
		}},
 | 
			
		||||
	}, true)
 | 
			
		||||
 
 | 
			
		||||
@@ -1250,7 +1250,7 @@ func RunWatchSemantics(ctx context.Context, t *testing.T, store storage.Interfac
 | 
			
		||||
			Object: &example.Pod{
 | 
			
		||||
				ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
					ResourceVersion: createdInitialPods[len(createdInitialPods)-1].ResourceVersion,
 | 
			
		||||
					Annotations:     map[string]string{"k8s.io/initial-events-end": "true"},
 | 
			
		||||
					Annotations:     map[string]string{metav1.InitialEventsAnnotationKey: "true"},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		}}
 | 
			
		||||
@@ -1513,7 +1513,7 @@ func RunWatchSemanticInitialEventsExtended(ctx context.Context, t *testing.T, st
 | 
			
		||||
		watchEvents = append(watchEvents, watch.Event{Type: watch.Bookmark, Object: &example.Pod{
 | 
			
		||||
			ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
				ResourceVersion: globalResourceVersion,
 | 
			
		||||
				Annotations:     map[string]string{"k8s.io/initial-events-end": "true"},
 | 
			
		||||
				Annotations:     map[string]string{metav1.InitialEventsAnnotationKey: "true"},
 | 
			
		||||
			},
 | 
			
		||||
		}})
 | 
			
		||||
		return watchEvents
 | 
			
		||||
 
 | 
			
		||||
@@ -24,18 +24,12 @@ import (
 | 
			
		||||
 | 
			
		||||
	"k8s.io/apimachinery/pkg/api/meta"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/api/validation/path"
 | 
			
		||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/fields"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/labels"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	// initialEventsAnnotationKey the name of the key
 | 
			
		||||
	// under which an annotation marking the end of list stream
 | 
			
		||||
	// is kept.
 | 
			
		||||
	initialEventsAnnotationKey = "k8s.io/initial-events-end"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type SimpleUpdateFunc func(runtime.Object) (runtime.Object, error)
 | 
			
		||||
 | 
			
		||||
// SimpleUpdateFunc converts SimpleUpdateFunc into UpdateFunc
 | 
			
		||||
@@ -144,7 +138,7 @@ func AnnotateInitialEventsEndBookmark(obj runtime.Object) error {
 | 
			
		||||
	if objAnnotations == nil {
 | 
			
		||||
		objAnnotations = map[string]string{}
 | 
			
		||||
	}
 | 
			
		||||
	objAnnotations[initialEventsAnnotationKey] = "true"
 | 
			
		||||
	objAnnotations[metav1.InitialEventsAnnotationKey] = "true"
 | 
			
		||||
	objMeta.SetAnnotations(objAnnotations)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
@@ -157,5 +151,5 @@ func HasInitialEventsEndBookmarkAnnotation(obj runtime.Object) (bool, error) {
 | 
			
		||||
		return false, err
 | 
			
		||||
	}
 | 
			
		||||
	objAnnotations := objMeta.GetAnnotations()
 | 
			
		||||
	return objAnnotations[initialEventsAnnotationKey] == "true", nil
 | 
			
		||||
	return objAnnotations[metav1.InitialEventsAnnotationKey] == "true", nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -154,7 +154,7 @@ func TestHasInitialEventsEndBookmarkAnnotation(t *testing.T) {
 | 
			
		||||
	createAnnotatedPod := func(name, value string) *example.Pod {
 | 
			
		||||
		p := createPod(name)
 | 
			
		||||
		p.Annotations = map[string]string{}
 | 
			
		||||
		p.Annotations["k8s.io/initial-events-end"] = value
 | 
			
		||||
		p.Annotations[metav1.InitialEventsAnnotationKey] = value
 | 
			
		||||
		return p
 | 
			
		||||
	}
 | 
			
		||||
	scenarios := []struct {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user