mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-17 07:03:31 +00:00
Standardize watch usage in registry/storage objects. Fix up extremely confusing pod test object.
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user