Standardize watch usage in registry/storage objects. Fix up extremely confusing pod test object.

This commit is contained in:
Daniel Smith
2014-08-14 14:14:31 -07:00
parent d900134a60
commit 4b2867fd8a
9 changed files with 96 additions and 123 deletions

View File

@@ -78,16 +78,8 @@ func (r *Registry) ListPods(selector labels.Selector) ([]api.Pod, error) {
}
// WatchPods begins watching for new, changed, or deleted pods.
func (r *Registry) WatchPods(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
return r.WatchList("/registry/pods", resourceVersion, func(obj interface{}) bool {
pod := obj.(*api.Pod)
fields := labels.Set{
"ID": pod.ID,
"CurrentState.Status": string(pod.CurrentState.Status),
"CurrentState.Host": pod.CurrentState.Host,
}
return label.Matches(labels.Set(pod.Labels)) && field.Matches(fields)
})
func (r *Registry) WatchPods(resourceVersion uint64) (watch.Interface, error) {
return r.WatchList("/registry/pods", resourceVersion, tools.Everything)
}
// GetPod gets a specific pod specified by its ID.
@@ -222,13 +214,8 @@ func (r *Registry) ListControllers() ([]api.ReplicationController, error) {
}
// WatchControllers begins watching for new, changed, or deleted controllers.
func (r *Registry) WatchControllers(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
if !field.Empty() {
return nil, fmt.Errorf("no field selector implemented for controllers")
}
return r.WatchList("/registry/controllers", resourceVersion, func(obj interface{}) bool {
return label.Matches(labels.Set(obj.(*api.ReplicationController).Labels))
})
func (r *Registry) WatchControllers(resourceVersion uint64) (watch.Interface, error) {
return r.WatchList("/registry/controllers", resourceVersion, tools.Everything)
}
func makeControllerKey(id string) string {