コード例 #1
0
ファイル: healthy_registry.go プロジェクト: nhr/kubernetes
func (r *HealthyRegistry) WatchMinions(ctx api.Context, label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
	w, err := r.delegate.WatchMinions(ctx, label, field, resourceVersion)
	if err != nil {
		return nil, err
	}
	return watch.Filter(w, watch.FilterFunc(func(in watch.Event) (watch.Event, bool) {
		if node, ok := in.Object.(*api.Node); ok && node != nil {
			in.Object = r.checkMinion(node)
		}
		return in, true
	})), nil
}
コード例 #2
0
ファイル: storage.go プロジェクト: K-A-Z/kubernetes
// 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) {
	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
}
コード例 #3
0
ファイル: storage.go プロジェクト: kunallimaye/kubernetes
// Watch begins watching for new, changed, or deleted pods.
func (rs *RegistryStorage) Watch(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
	source, err := rs.registry.WatchPods(resourceVersion)
	if err != nil {
		return nil, err
	}
	return watch.Filter(source, func(e watch.Event) (watch.Event, bool) {
		pod := e.Object.(*api.Pod)
		fields := labels.Set{
			"ID": pod.ID,
			"DesiredState.Status": string(pod.CurrentState.Status),
			"DesiredState.Host":   pod.CurrentState.Host,
		}
		return e, label.Matches(labels.Set(pod.Labels)) && field.Matches(fields)
	}), nil
}
コード例 #4
0
ファイル: rest.go プロジェクト: ericcapricorn/kubernetes
// Watch returns ReplicationController events via a watch.Interface.
// It implements apiserver.ResourceWatcher.
func (rs *REST) Watch(ctx api.Context, label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
	if !field.Empty() {
		return nil, fmt.Errorf("no field selector implemented for controllers")
	}
	incoming, err := rs.registry.WatchControllers(ctx, resourceVersion)
	if err != nil {
		return nil, err
	}
	// TODO(lavalamp): remove watch.Filter, which is broken. Implement consistent way of filtering.
	// TODO(lavalamp): this watch method needs a test.
	return watch.Filter(incoming, func(e watch.Event) (watch.Event, bool) {
		repController, ok := e.Object.(*api.ReplicationController)
		if !ok {
			// must be an error event-- pass it on
			return e, true
		}
		match := label.Matches(labels.Set(repController.Labels))
		if match {
			rs.fillCurrentState(ctx, repController)
		}
		return e, match
	}), nil
}