mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 05:02:50 +00:00
Fix watch for events; add test for interface implementation so it won't break again.
This commit is contained in:
@@ -91,8 +91,12 @@ func (e *Etcd) Delete(ctx api.Context, id string) error {
|
||||
|
||||
// Watch starts a watch for the items that m matches.
|
||||
// TODO: Detect if m references a single object instead of a list.
|
||||
func (e *Etcd) Watch(ctx api.Context, m generic.Matcher, resourceVersion uint64) (watch.Interface, error) {
|
||||
return e.Helper.WatchList(e.KeyRoot, resourceVersion, func(obj runtime.Object) bool {
|
||||
func (e *Etcd) Watch(ctx api.Context, m generic.Matcher, resourceVersion string) (watch.Interface, error) {
|
||||
version, err := tools.ParseWatchResourceVersion(resourceVersion, e.EndpointName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return e.Helper.WatchList(e.KeyRoot, version, func(obj runtime.Object) bool {
|
||||
matches, err := m.Matches(obj)
|
||||
return err == nil && matches
|
||||
})
|
||||
|
@@ -417,7 +417,7 @@ func TestEtcdWatch(t *testing.T) {
|
||||
}
|
||||
|
||||
fakeClient, registry := NewTestGenericEtcdRegistry(t)
|
||||
wi, err := registry.Watch(api.NewContext(), EverythingMatcher{}, 1)
|
||||
wi, err := registry.Watch(api.NewContext(), EverythingMatcher{}, "1")
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
@@ -76,7 +76,7 @@ type Registry interface {
|
||||
Update(ctx api.Context, id string, obj runtime.Object) error
|
||||
Get(ctx api.Context, id string) (runtime.Object, error)
|
||||
Delete(ctx api.Context, id string) error
|
||||
Watch(ctx api.Context, m Matcher, resourceVersion uint64) (watch.Interface, error)
|
||||
Watch(ctx api.Context, m Matcher, resourceVersion string) (watch.Interface, error)
|
||||
}
|
||||
|
||||
// FilterList filters any list object that conforms to the api conventions,
|
||||
|
Reference in New Issue
Block a user