mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 14:11:14 +00:00
Standardize watch usage in registry/storage objects. Fix up extremely confusing pod test object.
This commit is contained in:
@@ -18,14 +18,13 @@ package controller
|
||||
|
||||
import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||
)
|
||||
|
||||
// Registry is an interface for things that know how to store ReplicationControllers.
|
||||
type Registry interface {
|
||||
ListControllers() ([]api.ReplicationController, error)
|
||||
WatchControllers(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
|
||||
WatchControllers(resourceVersion uint64) (watch.Interface, error)
|
||||
GetController(controllerID string) (*api.ReplicationController, error)
|
||||
CreateController(controller api.ReplicationController) error
|
||||
UpdateController(controller api.ReplicationController) error
|
||||
|
@@ -131,7 +131,17 @@ func (rs *RegistryStorage) Update(obj interface{}) (<-chan interface{}, error) {
|
||||
// Watch returns ReplicationController events via a watch.Interface.
|
||||
// It implements apiserver.ResourceWatcher.
|
||||
func (rs *RegistryStorage) Watch(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
|
||||
return rs.registry.WatchControllers(label, field, resourceVersion)
|
||||
if !field.Empty() {
|
||||
return nil, fmt.Errorf("no field selector implemented for controllers")
|
||||
}
|
||||
incoming, err := rs.registry.WatchControllers(resourceVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return watch.Filter(incoming, func(e watch.Event) (watch.Event, bool) {
|
||||
repController := e.Object.(*api.ReplicationController)
|
||||
return e, label.Matches(labels.Set(repController.Labels))
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (rs *RegistryStorage) waitForController(ctrl api.ReplicationController) (interface{}, error) {
|
||||
|
Reference in New Issue
Block a user