mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	dependencies: pkg/client
This commit is contained in:
		
							
								
								
									
										30
									
								
								pkg/client/cache/controller_test.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										30
									
								
								pkg/client/cache/controller_test.go
									
									
									
									
										vendored
									
									
								
							@@ -23,7 +23,7 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	fcache "k8s.io/kubernetes/pkg/client/testing/cache"
 | 
						fcache "k8s.io/kubernetes/pkg/client/testing/cache"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/runtime"
 | 
						"k8s.io/kubernetes/pkg/runtime"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/sets"
 | 
						"k8s.io/kubernetes/pkg/util/sets"
 | 
				
			||||||
@@ -51,7 +51,7 @@ func Example() {
 | 
				
			|||||||
	cfg := &Config{
 | 
						cfg := &Config{
 | 
				
			||||||
		Queue:            fifo,
 | 
							Queue:            fifo,
 | 
				
			||||||
		ListerWatcher:    source,
 | 
							ListerWatcher:    source,
 | 
				
			||||||
		ObjectType:       &api.Pod{},
 | 
							ObjectType:       &v1.Pod{},
 | 
				
			||||||
		FullResyncPeriod: time.Millisecond * 100,
 | 
							FullResyncPeriod: time.Millisecond * 100,
 | 
				
			||||||
		RetryOnError:     false,
 | 
							RetryOnError:     false,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -101,7 +101,7 @@ func Example() {
 | 
				
			|||||||
	for _, name := range testIDs {
 | 
						for _, name := range testIDs {
 | 
				
			||||||
		// Note that these pods are not valid-- the fake source doesn't
 | 
							// Note that these pods are not valid-- the fake source doesn't
 | 
				
			||||||
		// call validation or anything.
 | 
							// call validation or anything.
 | 
				
			||||||
		source.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: name}})
 | 
							source.Add(&v1.Pod{ObjectMeta: v1.ObjectMeta{Name: name}})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Let's wait for the controller to process the things we just added.
 | 
						// Let's wait for the controller to process the things we just added.
 | 
				
			||||||
@@ -130,7 +130,7 @@ func ExampleNewInformer() {
 | 
				
			|||||||
	// logs anything deleted.
 | 
						// logs anything deleted.
 | 
				
			||||||
	_, controller := NewInformer(
 | 
						_, controller := NewInformer(
 | 
				
			||||||
		source,
 | 
							source,
 | 
				
			||||||
		&api.Pod{},
 | 
							&v1.Pod{},
 | 
				
			||||||
		time.Millisecond*100,
 | 
							time.Millisecond*100,
 | 
				
			||||||
		ResourceEventHandlerFuncs{
 | 
							ResourceEventHandlerFuncs{
 | 
				
			||||||
			AddFunc: func(obj interface{}) {
 | 
								AddFunc: func(obj interface{}) {
 | 
				
			||||||
@@ -158,7 +158,7 @@ func ExampleNewInformer() {
 | 
				
			|||||||
	for _, name := range testIDs {
 | 
						for _, name := range testIDs {
 | 
				
			||||||
		// Note that these pods are not valid-- the fake source doesn't
 | 
							// Note that these pods are not valid-- the fake source doesn't
 | 
				
			||||||
		// call validation or anything.
 | 
							// call validation or anything.
 | 
				
			||||||
		source.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: name}})
 | 
							source.Add(&v1.Pod{ObjectMeta: v1.ObjectMeta{Name: name}})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Let's wait for the controller to process the things we just added.
 | 
						// Let's wait for the controller to process the things we just added.
 | 
				
			||||||
@@ -206,7 +206,7 @@ func TestHammerController(t *testing.T) {
 | 
				
			|||||||
	// Make a controller which just logs all the changes it gets.
 | 
						// Make a controller which just logs all the changes it gets.
 | 
				
			||||||
	_, controller := NewInformer(
 | 
						_, controller := NewInformer(
 | 
				
			||||||
		source,
 | 
							source,
 | 
				
			||||||
		&api.Pod{},
 | 
							&v1.Pod{},
 | 
				
			||||||
		time.Millisecond*100,
 | 
							time.Millisecond*100,
 | 
				
			||||||
		ResourceEventHandlerFuncs{
 | 
							ResourceEventHandlerFuncs{
 | 
				
			||||||
			AddFunc:    func(obj interface{}) { recordFunc("add", obj) },
 | 
								AddFunc:    func(obj interface{}) { recordFunc("add", obj) },
 | 
				
			||||||
@@ -253,7 +253,7 @@ func TestHammerController(t *testing.T) {
 | 
				
			|||||||
					name = l[r.Intn(len(l))]
 | 
										name = l[r.Intn(len(l))]
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				pod := &api.Pod{}
 | 
									pod := &v1.Pod{}
 | 
				
			||||||
				f.Fuzz(pod)
 | 
									f.Fuzz(pod)
 | 
				
			||||||
				pod.ObjectMeta.Name = name
 | 
									pod.ObjectMeta.Name = name
 | 
				
			||||||
				pod.ObjectMeta.Namespace = "default"
 | 
									pod.ObjectMeta.Namespace = "default"
 | 
				
			||||||
@@ -315,9 +315,9 @@ func TestUpdate(t *testing.T) {
 | 
				
			|||||||
		pair{FROM, FROM}: true,
 | 
							pair{FROM, FROM}: true,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pod := func(name, check string, final bool) *api.Pod {
 | 
						pod := func(name, check string, final bool) *v1.Pod {
 | 
				
			||||||
		p := &api.Pod{
 | 
							p := &v1.Pod{
 | 
				
			||||||
			ObjectMeta: api.ObjectMeta{
 | 
								ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
				Name:   name,
 | 
									Name:   name,
 | 
				
			||||||
				Labels: map[string]string{"check": check},
 | 
									Labels: map[string]string{"check": check},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@@ -327,7 +327,7 @@ func TestUpdate(t *testing.T) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		return p
 | 
							return p
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	deletePod := func(p *api.Pod) bool {
 | 
						deletePod := func(p *v1.Pod) bool {
 | 
				
			||||||
		return p.Labels["final"] == "true"
 | 
							return p.Labels["final"] == "true"
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -350,20 +350,20 @@ func TestUpdate(t *testing.T) {
 | 
				
			|||||||
	watchCh := make(chan struct{})
 | 
						watchCh := make(chan struct{})
 | 
				
			||||||
	_, controller := NewInformer(
 | 
						_, controller := NewInformer(
 | 
				
			||||||
		&testLW{
 | 
							&testLW{
 | 
				
			||||||
			WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
 | 
								WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
				watch, err := source.Watch(options)
 | 
									watch, err := source.Watch(options)
 | 
				
			||||||
				close(watchCh)
 | 
									close(watchCh)
 | 
				
			||||||
				return watch, err
 | 
									return watch, err
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			ListFunc: func(options api.ListOptions) (runtime.Object, error) {
 | 
								ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
				return source.List(options)
 | 
									return source.List(options)
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		&api.Pod{},
 | 
							&v1.Pod{},
 | 
				
			||||||
		0,
 | 
							0,
 | 
				
			||||||
		ResourceEventHandlerFuncs{
 | 
							ResourceEventHandlerFuncs{
 | 
				
			||||||
			UpdateFunc: func(oldObj, newObj interface{}) {
 | 
								UpdateFunc: func(oldObj, newObj interface{}) {
 | 
				
			||||||
				o, n := oldObj.(*api.Pod), newObj.(*api.Pod)
 | 
									o, n := oldObj.(*v1.Pod), newObj.(*v1.Pod)
 | 
				
			||||||
				from, to := o.Labels["check"], n.Labels["check"]
 | 
									from, to := o.Labels["check"], n.Labels["check"]
 | 
				
			||||||
				if !allowedTransitions[pair{from, to}] {
 | 
									if !allowedTransitions[pair{from, to}] {
 | 
				
			||||||
					t.Errorf("observed transition %q -> %q for %v", from, to, n.Name)
 | 
										t.Errorf("observed transition %q -> %q for %v", from, to, n.Name)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								pkg/client/cache/index_test.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								pkg/client/cache/index_test.go
									
									
									
									
										vendored
									
									
								
							@@ -21,19 +21,20 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func testIndexFunc(obj interface{}) ([]string, error) {
 | 
					func testIndexFunc(obj interface{}) ([]string, error) {
 | 
				
			||||||
	pod := obj.(*api.Pod)
 | 
						pod := obj.(*v1.Pod)
 | 
				
			||||||
	return []string{pod.Labels["foo"]}, nil
 | 
						return []string{pod.Labels["foo"]}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestGetIndexFuncValues(t *testing.T) {
 | 
					func TestGetIndexFuncValues(t *testing.T) {
 | 
				
			||||||
	index := NewIndexer(MetaNamespaceKeyFunc, Indexers{"testmodes": testIndexFunc})
 | 
						index := NewIndexer(MetaNamespaceKeyFunc, Indexers{"testmodes": testIndexFunc})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pod1 := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "one", Labels: map[string]string{"foo": "bar"}}}
 | 
						pod1 := &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "one", Labels: map[string]string{"foo": "bar"}}}
 | 
				
			||||||
	pod2 := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "two", Labels: map[string]string{"foo": "bar"}}}
 | 
						pod2 := &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "two", Labels: map[string]string{"foo": "bar"}}}
 | 
				
			||||||
	pod3 := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "tre", Labels: map[string]string{"foo": "biz"}}}
 | 
						pod3 := &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "tre", Labels: map[string]string{"foo": "biz"}}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	index.Add(pod1)
 | 
						index.Add(pod1)
 | 
				
			||||||
	index.Add(pod2)
 | 
						index.Add(pod2)
 | 
				
			||||||
@@ -52,7 +53,7 @@ func TestGetIndexFuncValues(t *testing.T) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func testUsersIndexFunc(obj interface{}) ([]string, error) {
 | 
					func testUsersIndexFunc(obj interface{}) ([]string, error) {
 | 
				
			||||||
	pod := obj.(*api.Pod)
 | 
						pod := obj.(*v1.Pod)
 | 
				
			||||||
	usersString := pod.Annotations["users"]
 | 
						usersString := pod.Annotations["users"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return strings.Split(usersString, ","), nil
 | 
						return strings.Split(usersString, ","), nil
 | 
				
			||||||
@@ -61,9 +62,9 @@ func testUsersIndexFunc(obj interface{}) ([]string, error) {
 | 
				
			|||||||
func TestMultiIndexKeys(t *testing.T) {
 | 
					func TestMultiIndexKeys(t *testing.T) {
 | 
				
			||||||
	index := NewIndexer(MetaNamespaceKeyFunc, Indexers{"byUser": testUsersIndexFunc})
 | 
						index := NewIndexer(MetaNamespaceKeyFunc, Indexers{"byUser": testUsersIndexFunc})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pod1 := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "one", Annotations: map[string]string{"users": "ernie,bert"}}}
 | 
						pod1 := &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "one", Annotations: map[string]string{"users": "ernie,bert"}}}
 | 
				
			||||||
	pod2 := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "two", Annotations: map[string]string{"users": "bert,oscar"}}}
 | 
						pod2 := &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "two", Annotations: map[string]string{"users": "bert,oscar"}}}
 | 
				
			||||||
	pod3 := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "tre", Annotations: map[string]string{"users": "ernie,elmo"}}}
 | 
						pod3 := &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "tre", Annotations: map[string]string{"users": "ernie,elmo"}}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	index.Add(pod1)
 | 
						index.Add(pod1)
 | 
				
			||||||
	index.Add(pod2)
 | 
						index.Add(pod2)
 | 
				
			||||||
@@ -121,7 +122,7 @@ func TestMultiIndexKeys(t *testing.T) {
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Errorf("unexpected error: %v", err)
 | 
							t.Errorf("unexpected error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	copyOfPod2 := obj.(*api.Pod)
 | 
						copyOfPod2 := obj.(*v1.Pod)
 | 
				
			||||||
	copyOfPod2.Annotations["users"] = "oscar"
 | 
						copyOfPod2.Annotations["users"] = "oscar"
 | 
				
			||||||
	index.Update(copyOfPod2)
 | 
						index.Update(copyOfPod2)
 | 
				
			||||||
	bertPods, err = index.ByIndex("byUser", "bert")
 | 
						bertPods, err = index.ByIndex("byUser", "bert")
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										51
									
								
								pkg/client/cache/listers.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										51
									
								
								pkg/client/cache/listers.go
									
									
									
									
										vendored
									
									
								
							@@ -20,15 +20,16 @@ import (
 | 
				
			|||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/golang/glog"
 | 
						"github.com/golang/glog"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/errors"
 | 
						"k8s.io/kubernetes/pkg/api/errors"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/meta"
 | 
						"k8s.io/kubernetes/pkg/api/meta"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/apps"
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/certificates"
 | 
						apps "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/extensions"
 | 
						certificates "k8s.io/kubernetes/pkg/apis/certificates/v1alpha1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/policy"
 | 
						extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/storage"
 | 
						policy "k8s.io/kubernetes/pkg/apis/policy/v1beta1"
 | 
				
			||||||
 | 
						storageinternal "k8s.io/kubernetes/pkg/apis/storage"
 | 
				
			||||||
 | 
						storage "k8s.io/kubernetes/pkg/apis/storage/v1beta1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/labels"
 | 
						"k8s.io/kubernetes/pkg/labels"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/runtime"
 | 
						"k8s.io/kubernetes/pkg/runtime"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -50,7 +51,7 @@ func ListAll(store Store, selector labels.Selector, appendFn AppendFunc) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func ListAllByNamespace(indexer Indexer, namespace string, selector labels.Selector, appendFn AppendFunc) error {
 | 
					func ListAllByNamespace(indexer Indexer, namespace string, selector labels.Selector, appendFn AppendFunc) error {
 | 
				
			||||||
	if namespace == api.NamespaceAll {
 | 
						if namespace == v1.NamespaceAll {
 | 
				
			||||||
		for _, m := range indexer.List() {
 | 
							for _, m := range indexer.List() {
 | 
				
			||||||
			metadata, err := meta.Accessor(m)
 | 
								metadata, err := meta.Accessor(m)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
@@ -63,7 +64,7 @@ func ListAllByNamespace(indexer Indexer, namespace string, selector labels.Selec
 | 
				
			|||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	items, err := indexer.Index(NamespaceIndex, &api.ObjectMeta{Namespace: namespace})
 | 
						items, err := indexer.Index(NamespaceIndex, &v1.ObjectMeta{Namespace: namespace})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		// Ignore error; do slow search without index.
 | 
							// Ignore error; do slow search without index.
 | 
				
			||||||
		glog.Warningf("can not retrieve list of objects using index : %v", err)
 | 
							glog.Warningf("can not retrieve list of objects using index : %v", err)
 | 
				
			||||||
@@ -170,7 +171,7 @@ func (s *genericNamespaceLister) Get(name string) (runtime.Object, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// NodeConditionPredicate is a function that indicates whether the given node's conditions meet
 | 
					// NodeConditionPredicate is a function that indicates whether the given node's conditions meet
 | 
				
			||||||
// some set of criteria defined by the function.
 | 
					// some set of criteria defined by the function.
 | 
				
			||||||
type NodeConditionPredicate func(node *api.Node) bool
 | 
					type NodeConditionPredicate func(node *v1.Node) bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StoreToNodeLister makes a Store have the List method of the client.NodeInterface
 | 
					// StoreToNodeLister makes a Store have the List method of the client.NodeInterface
 | 
				
			||||||
// The Store must contain (only) Nodes.
 | 
					// The Store must contain (only) Nodes.
 | 
				
			||||||
@@ -178,9 +179,9 @@ type StoreToNodeLister struct {
 | 
				
			|||||||
	Store
 | 
						Store
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *StoreToNodeLister) List() (machines api.NodeList, err error) {
 | 
					func (s *StoreToNodeLister) List() (machines v1.NodeList, err error) {
 | 
				
			||||||
	for _, m := range s.Store.List() {
 | 
						for _, m := range s.Store.List() {
 | 
				
			||||||
		machines.Items = append(machines.Items, *(m.(*api.Node)))
 | 
							machines.Items = append(machines.Items, *(m.(*v1.Node)))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return machines, nil
 | 
						return machines, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -199,9 +200,9 @@ type storeToNodeConditionLister struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// List returns a list of nodes that match the conditions defined by the predicate functions in the storeToNodeConditionLister.
 | 
					// List returns a list of nodes that match the conditions defined by the predicate functions in the storeToNodeConditionLister.
 | 
				
			||||||
func (s storeToNodeConditionLister) List() (nodes []*api.Node, err error) {
 | 
					func (s storeToNodeConditionLister) List() (nodes []*v1.Node, err error) {
 | 
				
			||||||
	for _, m := range s.store.List() {
 | 
						for _, m := range s.store.List() {
 | 
				
			||||||
		node := m.(*api.Node)
 | 
							node := m.(*v1.Node)
 | 
				
			||||||
		if s.predicate(node) {
 | 
							if s.predicate(node) {
 | 
				
			||||||
			nodes = append(nodes, node)
 | 
								nodes = append(nodes, node)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
@@ -236,7 +237,7 @@ func (s *StoreToDaemonSetLister) List() (dss extensions.DaemonSetList, err error
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// GetPodDaemonSets returns a list of daemon sets managing a pod.
 | 
					// GetPodDaemonSets returns a list of daemon sets managing a pod.
 | 
				
			||||||
// Returns an error if and only if no matching daemon sets are found.
 | 
					// Returns an error if and only if no matching daemon sets are found.
 | 
				
			||||||
func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *api.Pod) (daemonSets []extensions.DaemonSet, err error) {
 | 
					func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *v1.Pod) (daemonSets []extensions.DaemonSet, err error) {
 | 
				
			||||||
	var selector labels.Selector
 | 
						var selector labels.Selector
 | 
				
			||||||
	var daemonSet extensions.DaemonSet
 | 
						var daemonSet extensions.DaemonSet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -274,17 +275,17 @@ type StoreToEndpointsLister struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// List lists all endpoints in the store.
 | 
					// List lists all endpoints in the store.
 | 
				
			||||||
func (s *StoreToEndpointsLister) List() (services api.EndpointsList, err error) {
 | 
					func (s *StoreToEndpointsLister) List() (services v1.EndpointsList, err error) {
 | 
				
			||||||
	for _, m := range s.Store.List() {
 | 
						for _, m := range s.Store.List() {
 | 
				
			||||||
		services.Items = append(services.Items, *(m.(*api.Endpoints)))
 | 
							services.Items = append(services.Items, *(m.(*v1.Endpoints)))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return services, nil
 | 
						return services, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetServiceEndpoints returns the endpoints of a service, matched on service name.
 | 
					// GetServiceEndpoints returns the endpoints of a service, matched on service name.
 | 
				
			||||||
func (s *StoreToEndpointsLister) GetServiceEndpoints(svc *api.Service) (ep api.Endpoints, err error) {
 | 
					func (s *StoreToEndpointsLister) GetServiceEndpoints(svc *v1.Service) (ep v1.Endpoints, err error) {
 | 
				
			||||||
	for _, m := range s.Store.List() {
 | 
						for _, m := range s.Store.List() {
 | 
				
			||||||
		ep = *m.(*api.Endpoints)
 | 
							ep = *m.(*v1.Endpoints)
 | 
				
			||||||
		if svc.Name == ep.Name && svc.Namespace == ep.Namespace {
 | 
							if svc.Name == ep.Name && svc.Namespace == ep.Namespace {
 | 
				
			||||||
			return ep, nil
 | 
								return ep, nil
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -299,8 +300,8 @@ type StoreToPVFetcher struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetPersistentVolumeInfo returns cached data for the PersistentVolume 'id'.
 | 
					// GetPersistentVolumeInfo returns cached data for the PersistentVolume 'id'.
 | 
				
			||||||
func (s *StoreToPVFetcher) GetPersistentVolumeInfo(id string) (*api.PersistentVolume, error) {
 | 
					func (s *StoreToPVFetcher) GetPersistentVolumeInfo(id string) (*v1.PersistentVolume, error) {
 | 
				
			||||||
	o, exists, err := s.Get(&api.PersistentVolume{ObjectMeta: api.ObjectMeta{Name: id}})
 | 
						o, exists, err := s.Get(&v1.PersistentVolume{ObjectMeta: v1.ObjectMeta{Name: id}})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, fmt.Errorf("error retrieving PersistentVolume '%v' from cache: %v", id, err)
 | 
							return nil, fmt.Errorf("error retrieving PersistentVolume '%v' from cache: %v", id, err)
 | 
				
			||||||
@@ -310,7 +311,7 @@ func (s *StoreToPVFetcher) GetPersistentVolumeInfo(id string) (*api.PersistentVo
 | 
				
			|||||||
		return nil, fmt.Errorf("PersistentVolume '%v' not found", id)
 | 
							return nil, fmt.Errorf("PersistentVolume '%v' not found", id)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return o.(*api.PersistentVolume), nil
 | 
						return o.(*v1.PersistentVolume), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StoreToStatefulSetLister gives a store List and Exists methods. The store must contain only StatefulSets.
 | 
					// StoreToStatefulSetLister gives a store List and Exists methods. The store must contain only StatefulSets.
 | 
				
			||||||
@@ -345,7 +346,7 @@ func (s *StoreToStatefulSetLister) StatefulSets(namespace string) storeStatefulS
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetPodStatefulSets returns a list of StatefulSets managing a pod. Returns an error only if no matching StatefulSets are found.
 | 
					// GetPodStatefulSets returns a list of StatefulSets managing a pod. Returns an error only if no matching StatefulSets are found.
 | 
				
			||||||
func (s *StoreToStatefulSetLister) GetPodStatefulSets(pod *api.Pod) (psList []apps.StatefulSet, err error) {
 | 
					func (s *StoreToStatefulSetLister) GetPodStatefulSets(pod *v1.Pod) (psList []apps.StatefulSet, err error) {
 | 
				
			||||||
	var selector labels.Selector
 | 
						var selector labels.Selector
 | 
				
			||||||
	var ps apps.StatefulSet
 | 
						var ps apps.StatefulSet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -404,7 +405,7 @@ type StoreToPodDisruptionBudgetLister struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetPodPodDisruptionBudgets returns a list of PodDisruptionBudgets matching a pod.  Returns an error only if no matching PodDisruptionBudgets are found.
 | 
					// GetPodPodDisruptionBudgets returns a list of PodDisruptionBudgets matching a pod.  Returns an error only if no matching PodDisruptionBudgets are found.
 | 
				
			||||||
func (s *StoreToPodDisruptionBudgetLister) GetPodPodDisruptionBudgets(pod *api.Pod) (pdbList []policy.PodDisruptionBudget, err error) {
 | 
					func (s *StoreToPodDisruptionBudgetLister) GetPodPodDisruptionBudgets(pod *v1.Pod) (pdbList []policy.PodDisruptionBudget, err error) {
 | 
				
			||||||
	var selector labels.Selector
 | 
						var selector labels.Selector
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(pod.Labels) == 0 {
 | 
						if len(pod.Labels) == 0 {
 | 
				
			||||||
@@ -466,13 +467,13 @@ func (s *storageClassLister) List(selector labels.Selector) (ret []*storage.Stor
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// List returns a list of storage classes
 | 
					// List returns a list of storage classes
 | 
				
			||||||
func (s *storageClassLister) Get(name string) (*storage.StorageClass, error) {
 | 
					func (s *storageClassLister) Get(name string) (*storage.StorageClass, error) {
 | 
				
			||||||
	key := &storage.StorageClass{ObjectMeta: api.ObjectMeta{Name: name}}
 | 
						key := &storage.StorageClass{ObjectMeta: v1.ObjectMeta{Name: name}}
 | 
				
			||||||
	obj, exists, err := s.indexer.Get(key)
 | 
						obj, exists, err := s.indexer.Get(key)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if !exists {
 | 
						if !exists {
 | 
				
			||||||
		return nil, errors.NewNotFound(storage.Resource("storageclass"), name)
 | 
							return nil, errors.NewNotFound(storageinternal.Resource("storageclass"), name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return obj.(*storage.StorageClass), nil
 | 
						return obj.(*storage.StorageClass), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										89
									
								
								pkg/client/cache/listers_core.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										89
									
								
								pkg/client/cache/listers_core.go
									
									
									
									
										vendored
									
									
								
							@@ -21,6 +21,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/errors"
 | 
						"k8s.io/kubernetes/pkg/api/errors"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/labels"
 | 
						"k8s.io/kubernetes/pkg/labels"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -40,9 +41,9 @@ type StoreToPodLister struct {
 | 
				
			|||||||
	Indexer Indexer
 | 
						Indexer Indexer
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *StoreToPodLister) List(selector labels.Selector) (ret []*api.Pod, err error) {
 | 
					func (s *StoreToPodLister) List(selector labels.Selector) (ret []*v1.Pod, err error) {
 | 
				
			||||||
	err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
						err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.Pod))
 | 
							ret = append(ret, m.(*v1.Pod))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -56,14 +57,14 @@ type storePodsNamespacer struct {
 | 
				
			|||||||
	namespace string
 | 
						namespace string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storePodsNamespacer) List(selector labels.Selector) (ret []*api.Pod, err error) {
 | 
					func (s storePodsNamespacer) List(selector labels.Selector) (ret []*v1.Pod, err error) {
 | 
				
			||||||
	err = ListAllByNamespace(s.Indexer, s.namespace, selector, func(m interface{}) {
 | 
						err = ListAllByNamespace(s.Indexer, s.namespace, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.Pod))
 | 
							ret = append(ret, m.(*v1.Pod))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storePodsNamespacer) Get(name string) (*api.Pod, error) {
 | 
					func (s storePodsNamespacer) Get(name string) (*v1.Pod, error) {
 | 
				
			||||||
	obj, exists, err := s.Indexer.GetByKey(s.namespace + "/" + name)
 | 
						obj, exists, err := s.Indexer.GetByKey(s.namespace + "/" + name)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
@@ -71,7 +72,7 @@ func (s storePodsNamespacer) Get(name string) (*api.Pod, error) {
 | 
				
			|||||||
	if !exists {
 | 
						if !exists {
 | 
				
			||||||
		return nil, errors.NewNotFound(api.Resource("pod"), name)
 | 
							return nil, errors.NewNotFound(api.Resource("pod"), name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return obj.(*api.Pod), nil
 | 
						return obj.(*v1.Pod), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StoreToServiceLister helps list services
 | 
					// StoreToServiceLister helps list services
 | 
				
			||||||
@@ -79,9 +80,9 @@ type StoreToServiceLister struct {
 | 
				
			|||||||
	Indexer Indexer
 | 
						Indexer Indexer
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *StoreToServiceLister) List(selector labels.Selector) (ret []*api.Service, err error) {
 | 
					func (s *StoreToServiceLister) List(selector labels.Selector) (ret []*v1.Service, err error) {
 | 
				
			||||||
	err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
						err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.Service))
 | 
							ret = append(ret, m.(*v1.Service))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -95,14 +96,14 @@ type storeServicesNamespacer struct {
 | 
				
			|||||||
	namespace string
 | 
						namespace string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storeServicesNamespacer) List(selector labels.Selector) (ret []*api.Service, err error) {
 | 
					func (s storeServicesNamespacer) List(selector labels.Selector) (ret []*v1.Service, err error) {
 | 
				
			||||||
	err = ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
 | 
						err = ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.Service))
 | 
							ret = append(ret, m.(*v1.Service))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storeServicesNamespacer) Get(name string) (*api.Service, error) {
 | 
					func (s storeServicesNamespacer) Get(name string) (*v1.Service, error) {
 | 
				
			||||||
	obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
 | 
						obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
@@ -110,12 +111,12 @@ func (s storeServicesNamespacer) Get(name string) (*api.Service, error) {
 | 
				
			|||||||
	if !exists {
 | 
						if !exists {
 | 
				
			||||||
		return nil, errors.NewNotFound(api.Resource("service"), name)
 | 
							return nil, errors.NewNotFound(api.Resource("service"), name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return obj.(*api.Service), nil
 | 
						return obj.(*v1.Service), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: Move this back to scheduler as a helper function that takes a Store,
 | 
					// TODO: Move this back to scheduler as a helper function that takes a Store,
 | 
				
			||||||
// rather than a method of StoreToServiceLister.
 | 
					// rather than a method of StoreToServiceLister.
 | 
				
			||||||
func (s *StoreToServiceLister) GetPodServices(pod *api.Pod) (services []*api.Service, err error) {
 | 
					func (s *StoreToServiceLister) GetPodServices(pod *v1.Pod) (services []*v1.Service, err error) {
 | 
				
			||||||
	allServices, err := s.Services(pod.Namespace).List(labels.Everything())
 | 
						allServices, err := s.Services(pod.Namespace).List(labels.Everything())
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
@@ -141,9 +142,9 @@ type StoreToReplicationControllerLister struct {
 | 
				
			|||||||
	Indexer Indexer
 | 
						Indexer Indexer
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *StoreToReplicationControllerLister) List(selector labels.Selector) (ret []*api.ReplicationController, err error) {
 | 
					func (s *StoreToReplicationControllerLister) List(selector labels.Selector) (ret []*v1.ReplicationController, err error) {
 | 
				
			||||||
	err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
						err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.ReplicationController))
 | 
							ret = append(ret, m.(*v1.ReplicationController))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -157,14 +158,14 @@ type storeReplicationControllersNamespacer struct {
 | 
				
			|||||||
	namespace string
 | 
						namespace string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storeReplicationControllersNamespacer) List(selector labels.Selector) (ret []*api.ReplicationController, err error) {
 | 
					func (s storeReplicationControllersNamespacer) List(selector labels.Selector) (ret []*v1.ReplicationController, err error) {
 | 
				
			||||||
	err = ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
 | 
						err = ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.ReplicationController))
 | 
							ret = append(ret, m.(*v1.ReplicationController))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storeReplicationControllersNamespacer) Get(name string) (*api.ReplicationController, error) {
 | 
					func (s storeReplicationControllersNamespacer) Get(name string) (*v1.ReplicationController, error) {
 | 
				
			||||||
	obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
 | 
						obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
@@ -172,24 +173,24 @@ func (s storeReplicationControllersNamespacer) Get(name string) (*api.Replicatio
 | 
				
			|||||||
	if !exists {
 | 
						if !exists {
 | 
				
			||||||
		return nil, errors.NewNotFound(api.Resource("replicationcontroller"), name)
 | 
							return nil, errors.NewNotFound(api.Resource("replicationcontroller"), name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return obj.(*api.ReplicationController), nil
 | 
						return obj.(*v1.ReplicationController), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetPodControllers returns a list of replication controllers managing a pod. Returns an error only if no matching controllers are found.
 | 
					// GetPodControllers returns a list of replication controllers managing a pod. Returns an error only if no matching controllers are found.
 | 
				
			||||||
func (s *StoreToReplicationControllerLister) GetPodControllers(pod *api.Pod) (controllers []*api.ReplicationController, err error) {
 | 
					func (s *StoreToReplicationControllerLister) GetPodControllers(pod *v1.Pod) (controllers []*v1.ReplicationController, err error) {
 | 
				
			||||||
	if len(pod.Labels) == 0 {
 | 
						if len(pod.Labels) == 0 {
 | 
				
			||||||
		err = fmt.Errorf("no controllers found for pod %v because it has no labels", pod.Name)
 | 
							err = fmt.Errorf("no controllers found for pod %v because it has no labels", pod.Name)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	key := &api.ReplicationController{ObjectMeta: api.ObjectMeta{Namespace: pod.Namespace}}
 | 
						key := &v1.ReplicationController{ObjectMeta: v1.ObjectMeta{Namespace: pod.Namespace}}
 | 
				
			||||||
	items, err := s.Indexer.Index(NamespaceIndex, key)
 | 
						items, err := s.Indexer.Index(NamespaceIndex, key)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, m := range items {
 | 
						for _, m := range items {
 | 
				
			||||||
		rc := m.(*api.ReplicationController)
 | 
							rc := m.(*v1.ReplicationController)
 | 
				
			||||||
		selector := labels.Set(rc.Spec.Selector).AsSelectorPreValidated()
 | 
							selector := labels.Set(rc.Spec.Selector).AsSelectorPreValidated()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// If an rc with a nil or empty selector creeps in, it should match nothing, not everything.
 | 
							// If an rc with a nil or empty selector creeps in, it should match nothing, not everything.
 | 
				
			||||||
@@ -209,9 +210,9 @@ type StoreToServiceAccountLister struct {
 | 
				
			|||||||
	Indexer Indexer
 | 
						Indexer Indexer
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *StoreToServiceAccountLister) List(selector labels.Selector) (ret []*api.ServiceAccount, err error) {
 | 
					func (s *StoreToServiceAccountLister) List(selector labels.Selector) (ret []*v1.ServiceAccount, err error) {
 | 
				
			||||||
	err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
						err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.ServiceAccount))
 | 
							ret = append(ret, m.(*v1.ServiceAccount))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -225,14 +226,14 @@ type storeServiceAccountsNamespacer struct {
 | 
				
			|||||||
	namespace string
 | 
						namespace string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storeServiceAccountsNamespacer) List(selector labels.Selector) (ret []*api.ServiceAccount, err error) {
 | 
					func (s storeServiceAccountsNamespacer) List(selector labels.Selector) (ret []*v1.ServiceAccount, err error) {
 | 
				
			||||||
	err = ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
 | 
						err = ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.ServiceAccount))
 | 
							ret = append(ret, m.(*v1.ServiceAccount))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storeServiceAccountsNamespacer) Get(name string) (*api.ServiceAccount, error) {
 | 
					func (s storeServiceAccountsNamespacer) Get(name string) (*v1.ServiceAccount, error) {
 | 
				
			||||||
	obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
 | 
						obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
@@ -240,7 +241,7 @@ func (s storeServiceAccountsNamespacer) Get(name string) (*api.ServiceAccount, e
 | 
				
			|||||||
	if !exists {
 | 
						if !exists {
 | 
				
			||||||
		return nil, errors.NewNotFound(api.Resource("serviceaccount"), name)
 | 
							return nil, errors.NewNotFound(api.Resource("serviceaccount"), name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return obj.(*api.ServiceAccount), nil
 | 
						return obj.(*v1.ServiceAccount), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StoreToLimitRangeLister helps list limit ranges
 | 
					// StoreToLimitRangeLister helps list limit ranges
 | 
				
			||||||
@@ -248,9 +249,9 @@ type StoreToLimitRangeLister struct {
 | 
				
			|||||||
	Indexer Indexer
 | 
						Indexer Indexer
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *StoreToLimitRangeLister) List(selector labels.Selector) (ret []*api.LimitRange, err error) {
 | 
					func (s *StoreToLimitRangeLister) List(selector labels.Selector) (ret []*v1.LimitRange, err error) {
 | 
				
			||||||
	err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
						err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.LimitRange))
 | 
							ret = append(ret, m.(*v1.LimitRange))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -261,9 +262,9 @@ type StoreToPersistentVolumeClaimLister struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// List returns all persistentvolumeclaims that match the specified selector
 | 
					// List returns all persistentvolumeclaims that match the specified selector
 | 
				
			||||||
func (s *StoreToPersistentVolumeClaimLister) List(selector labels.Selector) (ret []*api.PersistentVolumeClaim, err error) {
 | 
					func (s *StoreToPersistentVolumeClaimLister) List(selector labels.Selector) (ret []*v1.PersistentVolumeClaim, err error) {
 | 
				
			||||||
	err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
						err = ListAll(s.Indexer, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.PersistentVolumeClaim))
 | 
							ret = append(ret, m.(*v1.PersistentVolumeClaim))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -277,14 +278,14 @@ type storeLimitRangesNamespacer struct {
 | 
				
			|||||||
	namespace string
 | 
						namespace string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storeLimitRangesNamespacer) List(selector labels.Selector) (ret []*api.LimitRange, err error) {
 | 
					func (s storeLimitRangesNamespacer) List(selector labels.Selector) (ret []*v1.LimitRange, err error) {
 | 
				
			||||||
	err = ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
 | 
						err = ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.LimitRange))
 | 
							ret = append(ret, m.(*v1.LimitRange))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storeLimitRangesNamespacer) Get(name string) (*api.LimitRange, error) {
 | 
					func (s storeLimitRangesNamespacer) Get(name string) (*v1.LimitRange, error) {
 | 
				
			||||||
	obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
 | 
						obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
@@ -292,7 +293,7 @@ func (s storeLimitRangesNamespacer) Get(name string) (*api.LimitRange, error) {
 | 
				
			|||||||
	if !exists {
 | 
						if !exists {
 | 
				
			||||||
		return nil, errors.NewNotFound(api.Resource("limitrange"), name)
 | 
							return nil, errors.NewNotFound(api.Resource("limitrange"), name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return obj.(*api.LimitRange), nil
 | 
						return obj.(*v1.LimitRange), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// PersistentVolumeClaims returns all claims in a specified namespace.
 | 
					// PersistentVolumeClaims returns all claims in a specified namespace.
 | 
				
			||||||
@@ -305,14 +306,14 @@ type storePersistentVolumeClaimsNamespacer struct {
 | 
				
			|||||||
	namespace string
 | 
						namespace string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storePersistentVolumeClaimsNamespacer) List(selector labels.Selector) (ret []*api.PersistentVolumeClaim, err error) {
 | 
					func (s storePersistentVolumeClaimsNamespacer) List(selector labels.Selector) (ret []*v1.PersistentVolumeClaim, err error) {
 | 
				
			||||||
	err = ListAllByNamespace(s.Indexer, s.namespace, selector, func(m interface{}) {
 | 
						err = ListAllByNamespace(s.Indexer, s.namespace, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.PersistentVolumeClaim))
 | 
							ret = append(ret, m.(*v1.PersistentVolumeClaim))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s storePersistentVolumeClaimsNamespacer) Get(name string) (*api.PersistentVolumeClaim, error) {
 | 
					func (s storePersistentVolumeClaimsNamespacer) Get(name string) (*v1.PersistentVolumeClaim, error) {
 | 
				
			||||||
	obj, exists, err := s.Indexer.GetByKey(s.namespace + "/" + name)
 | 
						obj, exists, err := s.Indexer.GetByKey(s.namespace + "/" + name)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
@@ -320,7 +321,7 @@ func (s storePersistentVolumeClaimsNamespacer) Get(name string) (*api.Persistent
 | 
				
			|||||||
	if !exists {
 | 
						if !exists {
 | 
				
			||||||
		return nil, errors.NewNotFound(api.Resource("persistentvolumeclaims"), name)
 | 
							return nil, errors.NewNotFound(api.Resource("persistentvolumeclaims"), name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return obj.(*api.PersistentVolumeClaim), nil
 | 
						return obj.(*v1.PersistentVolumeClaim), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// IndexerToNamespaceLister gives an Indexer List method
 | 
					// IndexerToNamespaceLister gives an Indexer List method
 | 
				
			||||||
@@ -329,14 +330,14 @@ type IndexerToNamespaceLister struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// List returns a list of namespaces
 | 
					// List returns a list of namespaces
 | 
				
			||||||
func (i *IndexerToNamespaceLister) List(selector labels.Selector) (ret []*api.Namespace, err error) {
 | 
					func (i *IndexerToNamespaceLister) List(selector labels.Selector) (ret []*v1.Namespace, err error) {
 | 
				
			||||||
	err = ListAll(i.Indexer, selector, func(m interface{}) {
 | 
						err = ListAll(i.Indexer, selector, func(m interface{}) {
 | 
				
			||||||
		ret = append(ret, m.(*api.Namespace))
 | 
							ret = append(ret, m.(*v1.Namespace))
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	return ret, err
 | 
						return ret, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (i *IndexerToNamespaceLister) Get(name string) (*api.Namespace, error) {
 | 
					func (i *IndexerToNamespaceLister) Get(name string) (*v1.Namespace, error) {
 | 
				
			||||||
	obj, exists, err := i.Indexer.GetByKey(name)
 | 
						obj, exists, err := i.Indexer.GetByKey(name)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
@@ -344,5 +345,5 @@ func (i *IndexerToNamespaceLister) Get(name string) (*api.Namespace, error) {
 | 
				
			|||||||
	if !exists {
 | 
						if !exists {
 | 
				
			||||||
		return nil, errors.NewNotFound(api.Resource("namespace"), name)
 | 
							return nil, errors.NewNotFound(api.Resource("namespace"), name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return obj.(*api.Namespace), nil
 | 
						return obj.(*v1.Namespace), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								pkg/client/cache/listers_extensions.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								pkg/client/cache/listers_extensions.go
									
									
									
									
										vendored
									
									
								
							@@ -19,10 +19,11 @@ package cache
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/errors"
 | 
						"k8s.io/kubernetes/pkg/api/errors"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/extensions"
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
 | 
						extensionsinternal "k8s.io/kubernetes/pkg/apis/extensions"
 | 
				
			||||||
 | 
						extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/labels"
 | 
						"k8s.io/kubernetes/pkg/labels"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -71,7 +72,7 @@ func (s storeDeploymentsNamespacer) Get(name string) (*extensions.Deployment, er
 | 
				
			|||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if !exists {
 | 
						if !exists {
 | 
				
			||||||
		return nil, errors.NewNotFound(extensions.Resource("deployment"), name)
 | 
							return nil, errors.NewNotFound(extensionsinternal.Resource("deployment"), name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return obj.(*extensions.Deployment), nil
 | 
						return obj.(*extensions.Deployment), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -107,7 +108,7 @@ func (s *StoreToDeploymentLister) GetDeploymentsForReplicaSet(rs *extensions.Rep
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// GetDeploymentsForDeployments returns a list of deployments managing a pod. Returns an error only if no matching deployments are found.
 | 
					// GetDeploymentsForDeployments returns a list of deployments managing a pod. Returns an error only if no matching deployments are found.
 | 
				
			||||||
// TODO eliminate shallow copies
 | 
					// TODO eliminate shallow copies
 | 
				
			||||||
func (s *StoreToDeploymentLister) GetDeploymentsForPod(pod *api.Pod) (deployments []*extensions.Deployment, err error) {
 | 
					func (s *StoreToDeploymentLister) GetDeploymentsForPod(pod *v1.Pod) (deployments []*extensions.Deployment, err error) {
 | 
				
			||||||
	if len(pod.Labels) == 0 {
 | 
						if len(pod.Labels) == 0 {
 | 
				
			||||||
		err = fmt.Errorf("no deployments found for Pod %v because it has no labels", pod.Name)
 | 
							err = fmt.Errorf("no deployments found for Pod %v because it has no labels", pod.Name)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
@@ -172,13 +173,13 @@ func (s storeReplicaSetsNamespacer) Get(name string) (*extensions.ReplicaSet, er
 | 
				
			|||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if !exists {
 | 
						if !exists {
 | 
				
			||||||
		return nil, errors.NewNotFound(extensions.Resource("replicaset"), name)
 | 
							return nil, errors.NewNotFound(extensionsinternal.Resource("replicaset"), name)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return obj.(*extensions.ReplicaSet), nil
 | 
						return obj.(*extensions.ReplicaSet), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// GetPodReplicaSets returns a list of ReplicaSets managing a pod. Returns an error only if no matching ReplicaSets are found.
 | 
					// GetPodReplicaSets returns a list of ReplicaSets managing a pod. Returns an error only if no matching ReplicaSets are found.
 | 
				
			||||||
func (s *StoreToReplicaSetLister) GetPodReplicaSets(pod *api.Pod) (rss []*extensions.ReplicaSet, err error) {
 | 
					func (s *StoreToReplicaSetLister) GetPodReplicaSets(pod *v1.Pod) (rss []*extensions.ReplicaSet, err error) {
 | 
				
			||||||
	if len(pod.Labels) == 0 {
 | 
						if len(pod.Labels) == 0 {
 | 
				
			||||||
		err = fmt.Errorf("no ReplicaSets found for pod %v because it has no labels", pod.Name)
 | 
							err = fmt.Errorf("no ReplicaSets found for pod %v because it has no labels", pod.Name)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								pkg/client/cache/listers_rbac.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								pkg/client/cache/listers_rbac.go
									
									
									
									
										vendored
									
									
								
							@@ -18,7 +18,7 @@ package cache
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/errors"
 | 
						"k8s.io/kubernetes/pkg/api/errors"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/rbac"
 | 
						rbac "k8s.io/kubernetes/pkg/apis/rbac"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/labels"
 | 
						"k8s.io/kubernetes/pkg/labels"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										190
									
								
								pkg/client/cache/listers_test.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										190
									
								
								pkg/client/cache/listers_test.go
									
									
									
									
										vendored
									
									
								
							@@ -19,10 +19,10 @@ package cache
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
					 | 
				
			||||||
	apierrors "k8s.io/kubernetes/pkg/api/errors"
 | 
						apierrors "k8s.io/kubernetes/pkg/api/errors"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/extensions"
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
 | 
						extensions "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/labels"
 | 
						"k8s.io/kubernetes/pkg/labels"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/sets"
 | 
						"k8s.io/kubernetes/pkg/util/sets"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -31,7 +31,7 @@ func TestStoreToNodeLister(t *testing.T) {
 | 
				
			|||||||
	store := NewStore(MetaNamespaceKeyFunc)
 | 
						store := NewStore(MetaNamespaceKeyFunc)
 | 
				
			||||||
	ids := sets.NewString("foo", "bar", "baz")
 | 
						ids := sets.NewString("foo", "bar", "baz")
 | 
				
			||||||
	for id := range ids {
 | 
						for id := range ids {
 | 
				
			||||||
		store.Add(&api.Node{ObjectMeta: api.ObjectMeta{Name: id}})
 | 
							store.Add(&v1.Node{ObjectMeta: v1.ObjectMeta{Name: id}})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	sml := StoreToNodeLister{store}
 | 
						sml := StoreToNodeLister{store}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -50,44 +50,44 @@ func TestStoreToNodeLister(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestStoreToNodeConditionLister(t *testing.T) {
 | 
					func TestStoreToNodeConditionLister(t *testing.T) {
 | 
				
			||||||
	store := NewStore(MetaNamespaceKeyFunc)
 | 
						store := NewStore(MetaNamespaceKeyFunc)
 | 
				
			||||||
	nodes := []*api.Node{
 | 
						nodes := []*v1.Node{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			ObjectMeta: api.ObjectMeta{Name: "foo"},
 | 
								ObjectMeta: v1.ObjectMeta{Name: "foo"},
 | 
				
			||||||
			Status: api.NodeStatus{
 | 
								Status: v1.NodeStatus{
 | 
				
			||||||
				Conditions: []api.NodeCondition{
 | 
									Conditions: []v1.NodeCondition{
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						Type:   api.NodeReady,
 | 
											Type:   v1.NodeReady,
 | 
				
			||||||
						Status: api.ConditionTrue,
 | 
											Status: v1.ConditionTrue,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						Type:   api.NodeOutOfDisk,
 | 
											Type:   v1.NodeOutOfDisk,
 | 
				
			||||||
						Status: api.ConditionFalse,
 | 
											Status: v1.ConditionFalse,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			ObjectMeta: api.ObjectMeta{Name: "bar"},
 | 
								ObjectMeta: v1.ObjectMeta{Name: "bar"},
 | 
				
			||||||
			Status: api.NodeStatus{
 | 
								Status: v1.NodeStatus{
 | 
				
			||||||
				Conditions: []api.NodeCondition{
 | 
									Conditions: []v1.NodeCondition{
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						Type:   api.NodeOutOfDisk,
 | 
											Type:   v1.NodeOutOfDisk,
 | 
				
			||||||
						Status: api.ConditionTrue,
 | 
											Status: v1.ConditionTrue,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			ObjectMeta: api.ObjectMeta{Name: "baz"},
 | 
								ObjectMeta: v1.ObjectMeta{Name: "baz"},
 | 
				
			||||||
			Status: api.NodeStatus{
 | 
								Status: v1.NodeStatus{
 | 
				
			||||||
				Conditions: []api.NodeCondition{
 | 
									Conditions: []v1.NodeCondition{
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						Type:   api.NodeReady,
 | 
											Type:   v1.NodeReady,
 | 
				
			||||||
						Status: api.ConditionFalse,
 | 
											Status: v1.ConditionFalse,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						Type:   api.NodeOutOfDisk,
 | 
											Type:   v1.NodeOutOfDisk,
 | 
				
			||||||
						Status: api.ConditionUnknown,
 | 
											Status: v1.ConditionUnknown,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@@ -97,9 +97,9 @@ func TestStoreToNodeConditionLister(t *testing.T) {
 | 
				
			|||||||
		store.Add(n)
 | 
							store.Add(n)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	predicate := func(node *api.Node) bool {
 | 
						predicate := func(node *v1.Node) bool {
 | 
				
			||||||
		for _, cond := range node.Status.Conditions {
 | 
							for _, cond := range node.Status.Conditions {
 | 
				
			||||||
			if cond.Type == api.NodeOutOfDisk && cond.Status == api.ConditionTrue {
 | 
								if cond.Type == v1.NodeOutOfDisk && cond.Status == v1.ConditionTrue {
 | 
				
			||||||
				return false
 | 
									return false
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -126,65 +126,65 @@ func TestStoreToNodeConditionLister(t *testing.T) {
 | 
				
			|||||||
func TestStoreToReplicationControllerLister(t *testing.T) {
 | 
					func TestStoreToReplicationControllerLister(t *testing.T) {
 | 
				
			||||||
	testCases := []struct {
 | 
						testCases := []struct {
 | 
				
			||||||
		description              string
 | 
							description              string
 | 
				
			||||||
		inRCs                    []*api.ReplicationController
 | 
							inRCs                    []*v1.ReplicationController
 | 
				
			||||||
		list                     func(StoreToReplicationControllerLister) ([]*api.ReplicationController, error)
 | 
							list                     func(StoreToReplicationControllerLister) ([]*v1.ReplicationController, error)
 | 
				
			||||||
		outRCNames               sets.String
 | 
							outRCNames               sets.String
 | 
				
			||||||
		expectErr                bool
 | 
							expectErr                bool
 | 
				
			||||||
		onlyIfIndexedByNamespace bool
 | 
							onlyIfIndexedByNamespace bool
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			description: "Verify we can search all namespaces",
 | 
								description: "Verify we can search all namespaces",
 | 
				
			||||||
			inRCs: []*api.ReplicationController{
 | 
								inRCs: []*v1.ReplicationController{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "bar"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "foo", Namespace: "bar"},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "hmm", Namespace: "hmm"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "hmm", Namespace: "hmm"},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func(lister StoreToReplicationControllerLister) ([]*api.ReplicationController, error) {
 | 
								list: func(lister StoreToReplicationControllerLister) ([]*v1.ReplicationController, error) {
 | 
				
			||||||
				return lister.ReplicationControllers(api.NamespaceAll).List(labels.Set{}.AsSelectorPreValidated())
 | 
									return lister.ReplicationControllers(v1.NamespaceAll).List(labels.Set{}.AsSelectorPreValidated())
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			outRCNames: sets.NewString("hmm", "foo"),
 | 
								outRCNames: sets.NewString("hmm", "foo"),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			description: "Verify we can search a specific namespace",
 | 
								description: "Verify we can search a specific namespace",
 | 
				
			||||||
			inRCs: []*api.ReplicationController{
 | 
								inRCs: []*v1.ReplicationController{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "bar"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "foo", Namespace: "bar"},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "hmm", Namespace: "hmm"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "hmm", Namespace: "hmm"},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func(lister StoreToReplicationControllerLister) ([]*api.ReplicationController, error) {
 | 
								list: func(lister StoreToReplicationControllerLister) ([]*v1.ReplicationController, error) {
 | 
				
			||||||
				return lister.ReplicationControllers("hmm").List(labels.Set{}.AsSelectorPreValidated())
 | 
									return lister.ReplicationControllers("hmm").List(labels.Set{}.AsSelectorPreValidated())
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			outRCNames: sets.NewString("hmm"),
 | 
								outRCNames: sets.NewString("hmm"),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			description: "Basic listing with all labels and no selectors",
 | 
								description: "Basic listing with all labels and no selectors",
 | 
				
			||||||
			inRCs: []*api.ReplicationController{
 | 
								inRCs: []*v1.ReplicationController{
 | 
				
			||||||
				{ObjectMeta: api.ObjectMeta{Name: "basic"}},
 | 
									{ObjectMeta: v1.ObjectMeta{Name: "basic"}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func(lister StoreToReplicationControllerLister) ([]*api.ReplicationController, error) {
 | 
								list: func(lister StoreToReplicationControllerLister) ([]*v1.ReplicationController, error) {
 | 
				
			||||||
				return lister.List(labels.Everything())
 | 
									return lister.List(labels.Everything())
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			outRCNames: sets.NewString("basic"),
 | 
								outRCNames: sets.NewString("basic"),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			description: "No pod labels",
 | 
								description: "No pod labels",
 | 
				
			||||||
			inRCs: []*api.ReplicationController{
 | 
								inRCs: []*v1.ReplicationController{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
				
			||||||
					Spec: api.ReplicationControllerSpec{
 | 
										Spec: v1.ReplicationControllerSpec{
 | 
				
			||||||
						Selector: map[string]string{"foo": "baz"},
 | 
											Selector: map[string]string{"foo": "baz"},
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func(lister StoreToReplicationControllerLister) ([]*api.ReplicationController, error) {
 | 
								list: func(lister StoreToReplicationControllerLister) ([]*v1.ReplicationController, error) {
 | 
				
			||||||
				pod := &api.Pod{
 | 
									pod := &v1.Pod{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "pod1", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "pod1", Namespace: "ns"},
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return lister.GetPodControllers(pod)
 | 
									return lister.GetPodControllers(pod)
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@@ -193,14 +193,14 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			description: "No RC selectors",
 | 
								description: "No RC selectors",
 | 
				
			||||||
			inRCs: []*api.ReplicationController{
 | 
								inRCs: []*v1.ReplicationController{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func(lister StoreToReplicationControllerLister) ([]*api.ReplicationController, error) {
 | 
								list: func(lister StoreToReplicationControllerLister) ([]*v1.ReplicationController, error) {
 | 
				
			||||||
				pod := &api.Pod{
 | 
									pod := &v1.Pod{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{
 | 
										ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
						Name:      "pod1",
 | 
											Name:      "pod1",
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Labels:    map[string]string{"foo": "bar"},
 | 
											Labels:    map[string]string{"foo": "bar"},
 | 
				
			||||||
@@ -213,23 +213,23 @@ func TestStoreToReplicationControllerLister(t *testing.T) {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			description: "Matching labels to selectors and namespace",
 | 
								description: "Matching labels to selectors and namespace",
 | 
				
			||||||
			inRCs: []*api.ReplicationController{
 | 
								inRCs: []*v1.ReplicationController{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "foo"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "foo"},
 | 
				
			||||||
					Spec: api.ReplicationControllerSpec{
 | 
										Spec: v1.ReplicationControllerSpec{
 | 
				
			||||||
						Selector: map[string]string{"foo": "bar"},
 | 
											Selector: map[string]string{"foo": "bar"},
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "bar", Namespace: "ns"},
 | 
				
			||||||
					Spec: api.ReplicationControllerSpec{
 | 
										Spec: v1.ReplicationControllerSpec{
 | 
				
			||||||
						Selector: map[string]string{"foo": "bar"},
 | 
											Selector: map[string]string{"foo": "bar"},
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func(lister StoreToReplicationControllerLister) ([]*api.ReplicationController, error) {
 | 
								list: func(lister StoreToReplicationControllerLister) ([]*v1.ReplicationController, error) {
 | 
				
			||||||
				pod := &api.Pod{
 | 
									pod := &v1.Pod{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{
 | 
										ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
						Name:      "pod1",
 | 
											Name:      "pod1",
 | 
				
			||||||
						Labels:    map[string]string{"foo": "bar"},
 | 
											Labels:    map[string]string{"foo": "bar"},
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
@@ -290,7 +290,7 @@ func TestStoreToReplicaSetLister(t *testing.T) {
 | 
				
			|||||||
		// Basic listing with all labels and no selectors
 | 
							// Basic listing with all labels and no selectors
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			inRSs: []*extensions.ReplicaSet{
 | 
								inRSs: []*extensions.ReplicaSet{
 | 
				
			||||||
				{ObjectMeta: api.ObjectMeta{Name: "basic"}},
 | 
									{ObjectMeta: v1.ObjectMeta{Name: "basic"}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func() ([]*extensions.ReplicaSet, error) {
 | 
								list: func() ([]*extensions.ReplicaSet, error) {
 | 
				
			||||||
				return lister.List(labels.Everything())
 | 
									return lister.List(labels.Everything())
 | 
				
			||||||
@@ -301,15 +301,15 @@ func TestStoreToReplicaSetLister(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			inRSs: []*extensions.ReplicaSet{
 | 
								inRSs: []*extensions.ReplicaSet{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
				
			||||||
					Spec: extensions.ReplicaSetSpec{
 | 
										Spec: extensions.ReplicaSetSpec{
 | 
				
			||||||
						Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "baz"}},
 | 
											Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "baz"}},
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func() ([]*extensions.ReplicaSet, error) {
 | 
								list: func() ([]*extensions.ReplicaSet, error) {
 | 
				
			||||||
				pod := &api.Pod{
 | 
									pod := &v1.Pod{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "pod1", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "pod1", Namespace: "ns"},
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return lister.GetPodReplicaSets(pod)
 | 
									return lister.GetPodReplicaSets(pod)
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@@ -320,12 +320,12 @@ func TestStoreToReplicaSetLister(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			inRSs: []*extensions.ReplicaSet{
 | 
								inRSs: []*extensions.ReplicaSet{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func() ([]*extensions.ReplicaSet, error) {
 | 
								list: func() ([]*extensions.ReplicaSet, error) {
 | 
				
			||||||
				pod := &api.Pod{
 | 
									pod := &v1.Pod{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{
 | 
										ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
						Name:      "pod1",
 | 
											Name:      "pod1",
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Labels:    map[string]string{"foo": "bar"},
 | 
											Labels:    map[string]string{"foo": "bar"},
 | 
				
			||||||
@@ -340,21 +340,21 @@ func TestStoreToReplicaSetLister(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			inRSs: []*extensions.ReplicaSet{
 | 
								inRSs: []*extensions.ReplicaSet{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "foo"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "foo"},
 | 
				
			||||||
					Spec: extensions.ReplicaSetSpec{
 | 
										Spec: extensions.ReplicaSetSpec{
 | 
				
			||||||
						Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
 | 
											Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "bar", Namespace: "ns"},
 | 
				
			||||||
					Spec: extensions.ReplicaSetSpec{
 | 
										Spec: extensions.ReplicaSetSpec{
 | 
				
			||||||
						Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
 | 
											Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func() ([]*extensions.ReplicaSet, error) {
 | 
								list: func() ([]*extensions.ReplicaSet, error) {
 | 
				
			||||||
				pod := &api.Pod{
 | 
									pod := &v1.Pod{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{
 | 
										ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
						Name:      "pod1",
 | 
											Name:      "pod1",
 | 
				
			||||||
						Labels:    map[string]string{"foo": "bar"},
 | 
											Labels:    map[string]string{"foo": "bar"},
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
@@ -402,7 +402,7 @@ func TestStoreToDaemonSetLister(t *testing.T) {
 | 
				
			|||||||
		// Basic listing
 | 
							// Basic listing
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			inDSs: []*extensions.DaemonSet{
 | 
								inDSs: []*extensions.DaemonSet{
 | 
				
			||||||
				{ObjectMeta: api.ObjectMeta{Name: "basic"}},
 | 
									{ObjectMeta: v1.ObjectMeta{Name: "basic"}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func() ([]extensions.DaemonSet, error) {
 | 
								list: func() ([]extensions.DaemonSet, error) {
 | 
				
			||||||
				list, err := lister.List()
 | 
									list, err := lister.List()
 | 
				
			||||||
@@ -413,9 +413,9 @@ func TestStoreToDaemonSetLister(t *testing.T) {
 | 
				
			|||||||
		// Listing multiple daemon sets
 | 
							// Listing multiple daemon sets
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			inDSs: []*extensions.DaemonSet{
 | 
								inDSs: []*extensions.DaemonSet{
 | 
				
			||||||
				{ObjectMeta: api.ObjectMeta{Name: "basic"}},
 | 
									{ObjectMeta: v1.ObjectMeta{Name: "basic"}},
 | 
				
			||||||
				{ObjectMeta: api.ObjectMeta{Name: "complex"}},
 | 
									{ObjectMeta: v1.ObjectMeta{Name: "complex"}},
 | 
				
			||||||
				{ObjectMeta: api.ObjectMeta{Name: "complex2"}},
 | 
									{ObjectMeta: v1.ObjectMeta{Name: "complex2"}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func() ([]extensions.DaemonSet, error) {
 | 
								list: func() ([]extensions.DaemonSet, error) {
 | 
				
			||||||
				list, err := lister.List()
 | 
									list, err := lister.List()
 | 
				
			||||||
@@ -427,15 +427,15 @@ func TestStoreToDaemonSetLister(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			inDSs: []*extensions.DaemonSet{
 | 
								inDSs: []*extensions.DaemonSet{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
				
			||||||
					Spec: extensions.DaemonSetSpec{
 | 
										Spec: extensions.DaemonSetSpec{
 | 
				
			||||||
						Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "baz"}},
 | 
											Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "baz"}},
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func() ([]extensions.DaemonSet, error) {
 | 
								list: func() ([]extensions.DaemonSet, error) {
 | 
				
			||||||
				pod := &api.Pod{
 | 
									pod := &v1.Pod{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "pod1", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "pod1", Namespace: "ns"},
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return lister.GetPodDaemonSets(pod)
 | 
									return lister.GetPodDaemonSets(pod)
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@@ -446,12 +446,12 @@ func TestStoreToDaemonSetLister(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			inDSs: []*extensions.DaemonSet{
 | 
								inDSs: []*extensions.DaemonSet{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "basic", Namespace: "ns"},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func() ([]extensions.DaemonSet, error) {
 | 
								list: func() ([]extensions.DaemonSet, error) {
 | 
				
			||||||
				pod := &api.Pod{
 | 
									pod := &v1.Pod{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{
 | 
										ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
						Name:      "pod1",
 | 
											Name:      "pod1",
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Labels:    map[string]string{"foo": "bar"},
 | 
											Labels:    map[string]string{"foo": "bar"},
 | 
				
			||||||
@@ -466,21 +466,21 @@ func TestStoreToDaemonSetLister(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			inDSs: []*extensions.DaemonSet{
 | 
								inDSs: []*extensions.DaemonSet{
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "foo"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "foo"},
 | 
				
			||||||
					Spec: extensions.DaemonSetSpec{
 | 
										Spec: extensions.DaemonSetSpec{
 | 
				
			||||||
						Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
 | 
											Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{Name: "bar", Namespace: "ns"},
 | 
										ObjectMeta: v1.ObjectMeta{Name: "bar", Namespace: "ns"},
 | 
				
			||||||
					Spec: extensions.DaemonSetSpec{
 | 
										Spec: extensions.DaemonSetSpec{
 | 
				
			||||||
						Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
 | 
											Selector: &unversioned.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			list: func() ([]extensions.DaemonSet, error) {
 | 
								list: func() ([]extensions.DaemonSet, error) {
 | 
				
			||||||
				pod := &api.Pod{
 | 
									pod := &v1.Pod{
 | 
				
			||||||
					ObjectMeta: api.ObjectMeta{
 | 
										ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
						Name:      "pod1",
 | 
											Name:      "pod1",
 | 
				
			||||||
						Labels:    map[string]string{"foo": "bar"},
 | 
											Labels:    map[string]string{"foo": "bar"},
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
@@ -527,25 +527,25 @@ func TestStoreToPodLister(t *testing.T) {
 | 
				
			|||||||
	for _, store := range stores {
 | 
						for _, store := range stores {
 | 
				
			||||||
		ids := []string{"foo", "bar", "baz"}
 | 
							ids := []string{"foo", "bar", "baz"}
 | 
				
			||||||
		for _, id := range ids {
 | 
							for _, id := range ids {
 | 
				
			||||||
			store.Add(&api.Pod{
 | 
								store.Add(&v1.Pod{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Namespace: "other",
 | 
										Namespace: "other",
 | 
				
			||||||
					Name:      id,
 | 
										Name:      id,
 | 
				
			||||||
					Labels:    map[string]string{"name": id},
 | 
										Labels:    map[string]string{"name": id},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		store.Add(&api.Pod{
 | 
							store.Add(&v1.Pod{
 | 
				
			||||||
			ObjectMeta: api.ObjectMeta{
 | 
								ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
				Name:      "quux",
 | 
									Name:      "quux",
 | 
				
			||||||
				Namespace: api.NamespaceDefault,
 | 
									Namespace: v1.NamespaceDefault,
 | 
				
			||||||
				Labels:    map[string]string{"name": "quux"},
 | 
									Labels:    map[string]string{"name": "quux"},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
		spl := StoreToPodLister{store}
 | 
							spl := StoreToPodLister{store}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Verify that we can always look up by Namespace.
 | 
							// Verify that we can always look up by Namespace.
 | 
				
			||||||
		defaultPods, err := spl.Pods(api.NamespaceDefault).List(labels.Set{}.AsSelectorPreValidated())
 | 
							defaultPods, err := spl.Pods(v1.NamespaceDefault).List(labels.Set{}.AsSelectorPreValidated())
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			t.Errorf("Unexpected error: %v", err)
 | 
								t.Errorf("Unexpected error: %v", err)
 | 
				
			||||||
		} else if e, a := 1, len(defaultPods); e != a {
 | 
							} else if e, a := 1, len(defaultPods); e != a {
 | 
				
			||||||
@@ -583,17 +583,17 @@ func TestStoreToPodLister(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestStoreToServiceLister(t *testing.T) {
 | 
					func TestStoreToServiceLister(t *testing.T) {
 | 
				
			||||||
	store := NewIndexer(MetaNamespaceKeyFunc, Indexers{NamespaceIndex: MetaNamespaceIndexFunc})
 | 
						store := NewIndexer(MetaNamespaceKeyFunc, Indexers{NamespaceIndex: MetaNamespaceIndexFunc})
 | 
				
			||||||
	store.Add(&api.Service{
 | 
						store.Add(&v1.Service{
 | 
				
			||||||
		ObjectMeta: api.ObjectMeta{Name: "foo"},
 | 
							ObjectMeta: v1.ObjectMeta{Name: "foo"},
 | 
				
			||||||
		Spec: api.ServiceSpec{
 | 
							Spec: v1.ServiceSpec{
 | 
				
			||||||
			Selector: map[string]string{},
 | 
								Selector: map[string]string{},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	store.Add(&api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}})
 | 
						store.Add(&v1.Service{ObjectMeta: v1.ObjectMeta{Name: "bar"}})
 | 
				
			||||||
	ssl := StoreToServiceLister{store}
 | 
						ssl := StoreToServiceLister{store}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pod := &api.Pod{
 | 
						pod := &v1.Pod{
 | 
				
			||||||
		ObjectMeta: api.ObjectMeta{
 | 
							ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
			Name:   "foopod",
 | 
								Name:   "foopod",
 | 
				
			||||||
			Labels: map[string]string{"role": "foo"},
 | 
								Labels: map[string]string{"role": "foo"},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										23
									
								
								pkg/client/cache/listwatch.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								pkg/client/cache/listwatch.go
									
									
									
									
										vendored
									
									
								
							@@ -21,6 +21,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/meta"
 | 
						"k8s.io/kubernetes/pkg/api/meta"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/client/restclient"
 | 
						"k8s.io/kubernetes/pkg/client/restclient"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/fields"
 | 
						"k8s.io/kubernetes/pkg/fields"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/runtime"
 | 
						"k8s.io/kubernetes/pkg/runtime"
 | 
				
			||||||
@@ -31,16 +32,16 @@ import (
 | 
				
			|||||||
type ListerWatcher interface {
 | 
					type ListerWatcher interface {
 | 
				
			||||||
	// List should return a list type object; the Items field will be extracted, and the
 | 
						// List should return a list type object; the Items field will be extracted, and the
 | 
				
			||||||
	// ResourceVersion field will be used to start the watch in the right place.
 | 
						// ResourceVersion field will be used to start the watch in the right place.
 | 
				
			||||||
	List(options api.ListOptions) (runtime.Object, error)
 | 
						List(options v1.ListOptions) (runtime.Object, error)
 | 
				
			||||||
	// Watch should begin a watch at the specified version.
 | 
						// Watch should begin a watch at the specified version.
 | 
				
			||||||
	Watch(options api.ListOptions) (watch.Interface, error)
 | 
						Watch(options v1.ListOptions) (watch.Interface, error)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListFunc knows how to list resources
 | 
					// ListFunc knows how to list resources
 | 
				
			||||||
type ListFunc func(options api.ListOptions) (runtime.Object, error)
 | 
					type ListFunc func(options v1.ListOptions) (runtime.Object, error)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// WatchFunc knows how to watch resources
 | 
					// WatchFunc knows how to watch resources
 | 
				
			||||||
type WatchFunc func(options api.ListOptions) (watch.Interface, error)
 | 
					type WatchFunc func(options v1.ListOptions) (watch.Interface, error)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ListWatch knows how to list and watch a set of apiserver resources.  It satisfies the ListerWatcher interface.
 | 
					// ListWatch knows how to list and watch a set of apiserver resources.  It satisfies the ListerWatcher interface.
 | 
				
			||||||
// It is a convenience function for users of NewReflector, etc.
 | 
					// It is a convenience function for users of NewReflector, etc.
 | 
				
			||||||
@@ -57,7 +58,7 @@ type Getter interface {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.
 | 
					// NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.
 | 
				
			||||||
func NewListWatchFromClient(c Getter, resource string, namespace string, fieldSelector fields.Selector) *ListWatch {
 | 
					func NewListWatchFromClient(c Getter, resource string, namespace string, fieldSelector fields.Selector) *ListWatch {
 | 
				
			||||||
	listFunc := func(options api.ListOptions) (runtime.Object, error) {
 | 
						listFunc := func(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
		return c.Get().
 | 
							return c.Get().
 | 
				
			||||||
			Namespace(namespace).
 | 
								Namespace(namespace).
 | 
				
			||||||
			Resource(resource).
 | 
								Resource(resource).
 | 
				
			||||||
@@ -66,7 +67,7 @@ func NewListWatchFromClient(c Getter, resource string, namespace string, fieldSe
 | 
				
			|||||||
			Do().
 | 
								Do().
 | 
				
			||||||
			Get()
 | 
								Get()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	watchFunc := func(options api.ListOptions) (watch.Interface, error) {
 | 
						watchFunc := func(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
		return c.Get().
 | 
							return c.Get().
 | 
				
			||||||
			Prefix("watch").
 | 
								Prefix("watch").
 | 
				
			||||||
			Namespace(namespace).
 | 
								Namespace(namespace).
 | 
				
			||||||
@@ -78,7 +79,7 @@ func NewListWatchFromClient(c Getter, resource string, namespace string, fieldSe
 | 
				
			|||||||
	return &ListWatch{ListFunc: listFunc, WatchFunc: watchFunc}
 | 
						return &ListWatch{ListFunc: listFunc, WatchFunc: watchFunc}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func timeoutFromListOptions(options api.ListOptions) time.Duration {
 | 
					func timeoutFromListOptions(options v1.ListOptions) time.Duration {
 | 
				
			||||||
	if options.TimeoutSeconds != nil {
 | 
						if options.TimeoutSeconds != nil {
 | 
				
			||||||
		return time.Duration(*options.TimeoutSeconds) * time.Second
 | 
							return time.Duration(*options.TimeoutSeconds) * time.Second
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -86,12 +87,12 @@ func timeoutFromListOptions(options api.ListOptions) time.Duration {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// List a set of apiserver resources
 | 
					// List a set of apiserver resources
 | 
				
			||||||
func (lw *ListWatch) List(options api.ListOptions) (runtime.Object, error) {
 | 
					func (lw *ListWatch) List(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
	return lw.ListFunc(options)
 | 
						return lw.ListFunc(options)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Watch a set of apiserver resources
 | 
					// Watch a set of apiserver resources
 | 
				
			||||||
func (lw *ListWatch) Watch(options api.ListOptions) (watch.Interface, error) {
 | 
					func (lw *ListWatch) Watch(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
	return lw.WatchFunc(options)
 | 
						return lw.WatchFunc(options)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -101,7 +102,7 @@ func ListWatchUntil(timeout time.Duration, lw ListerWatcher, conditions ...watch
 | 
				
			|||||||
		return nil, nil
 | 
							return nil, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	list, err := lw.List(api.ListOptions{})
 | 
						list, err := lw.List(v1.ListOptions{})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -153,7 +154,7 @@ func ListWatchUntil(timeout time.Duration, lw ListerWatcher, conditions ...watch
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	currResourceVersion := metaObj.GetResourceVersion()
 | 
						currResourceVersion := metaObj.GetResourceVersion()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	watchInterface, err := lw.Watch(api.ListOptions{ResourceVersion: currResourceVersion})
 | 
						watchInterface, err := lw.Watch(v1.ListOptions{ResourceVersion: currResourceVersion})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										44
									
								
								pkg/client/cache/listwatch_test.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										44
									
								
								pkg/client/cache/listwatch_test.go
									
									
									
									
										vendored
									
									
								
							@@ -22,9 +22,9 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/testapi"
 | 
						"k8s.io/kubernetes/pkg/api/testapi"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apimachinery/registered"
 | 
						"k8s.io/kubernetes/pkg/apimachinery/registered"
 | 
				
			||||||
	clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
 | 
						clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/client/restclient"
 | 
						"k8s.io/kubernetes/pkg/client/restclient"
 | 
				
			||||||
@@ -60,7 +60,7 @@ func buildLocation(resourcePath string, query url.Values) string {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestListWatchesCanList(t *testing.T) {
 | 
					func TestListWatchesCanList(t *testing.T) {
 | 
				
			||||||
	fieldSelectorQueryParamName := unversioned.FieldSelectorQueryParam(registered.GroupOrDie(api.GroupName).GroupVersion.String())
 | 
						fieldSelectorQueryParamName := unversioned.FieldSelectorQueryParam(registered.GroupOrDie(v1.GroupName).GroupVersion.String())
 | 
				
			||||||
	table := []struct {
 | 
						table := []struct {
 | 
				
			||||||
		location      string
 | 
							location      string
 | 
				
			||||||
		resource      string
 | 
							resource      string
 | 
				
			||||||
@@ -69,18 +69,18 @@ func TestListWatchesCanList(t *testing.T) {
 | 
				
			|||||||
	}{
 | 
						}{
 | 
				
			||||||
		// Node
 | 
							// Node
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			location:      testapi.Default.ResourcePath("nodes", api.NamespaceAll, ""),
 | 
								location:      testapi.Default.ResourcePath("nodes", v1.NamespaceAll, ""),
 | 
				
			||||||
			resource:      "nodes",
 | 
								resource:      "nodes",
 | 
				
			||||||
			namespace:     api.NamespaceAll,
 | 
								namespace:     v1.NamespaceAll,
 | 
				
			||||||
			fieldSelector: parseSelectorOrDie(""),
 | 
								fieldSelector: parseSelectorOrDie(""),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		// pod with "assigned" field selector.
 | 
							// pod with "assigned" field selector.
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			location: buildLocation(
 | 
								location: buildLocation(
 | 
				
			||||||
				testapi.Default.ResourcePath("pods", api.NamespaceAll, ""),
 | 
									testapi.Default.ResourcePath("pods", v1.NamespaceAll, ""),
 | 
				
			||||||
				buildQueryValues(url.Values{fieldSelectorQueryParamName: []string{"spec.host="}})),
 | 
									buildQueryValues(url.Values{fieldSelectorQueryParamName: []string{"spec.host="}})),
 | 
				
			||||||
			resource:      "pods",
 | 
								resource:      "pods",
 | 
				
			||||||
			namespace:     api.NamespaceAll,
 | 
								namespace:     v1.NamespaceAll,
 | 
				
			||||||
			fieldSelector: fields.Set{"spec.host": ""}.AsSelector(),
 | 
								fieldSelector: fields.Set{"spec.host": ""}.AsSelector(),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		// pod in namespace "foo"
 | 
							// pod in namespace "foo"
 | 
				
			||||||
@@ -101,16 +101,16 @@ func TestListWatchesCanList(t *testing.T) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		server := httptest.NewServer(&handler)
 | 
							server := httptest.NewServer(&handler)
 | 
				
			||||||
		defer server.Close()
 | 
							defer server.Close()
 | 
				
			||||||
		client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: ®istered.GroupOrDie(api.GroupName).GroupVersion}})
 | 
							client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: ®istered.GroupOrDie(v1.GroupName).GroupVersion}})
 | 
				
			||||||
		lw := NewListWatchFromClient(client.Core().RESTClient(), item.resource, item.namespace, item.fieldSelector)
 | 
							lw := NewListWatchFromClient(client.Core().RESTClient(), item.resource, item.namespace, item.fieldSelector)
 | 
				
			||||||
		// This test merely tests that the correct request is made.
 | 
							// This test merely tests that the correct request is made.
 | 
				
			||||||
		lw.List(api.ListOptions{})
 | 
							lw.List(v1.ListOptions{})
 | 
				
			||||||
		handler.ValidateRequest(t, item.location, "GET", nil)
 | 
							handler.ValidateRequest(t, item.location, "GET", nil)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestListWatchesCanWatch(t *testing.T) {
 | 
					func TestListWatchesCanWatch(t *testing.T) {
 | 
				
			||||||
	fieldSelectorQueryParamName := unversioned.FieldSelectorQueryParam(registered.GroupOrDie(api.GroupName).GroupVersion.String())
 | 
						fieldSelectorQueryParamName := unversioned.FieldSelectorQueryParam(registered.GroupOrDie(v1.GroupName).GroupVersion.String())
 | 
				
			||||||
	table := []struct {
 | 
						table := []struct {
 | 
				
			||||||
		rv            string
 | 
							rv            string
 | 
				
			||||||
		location      string
 | 
							location      string
 | 
				
			||||||
@@ -121,30 +121,30 @@ func TestListWatchesCanWatch(t *testing.T) {
 | 
				
			|||||||
		// Node
 | 
							// Node
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			location: buildLocation(
 | 
								location: buildLocation(
 | 
				
			||||||
				testapi.Default.ResourcePathWithPrefix("watch", "nodes", api.NamespaceAll, ""),
 | 
									testapi.Default.ResourcePathWithPrefix("watch", "nodes", v1.NamespaceAll, ""),
 | 
				
			||||||
				buildQueryValues(url.Values{})),
 | 
									buildQueryValues(url.Values{})),
 | 
				
			||||||
			rv:            "",
 | 
								rv:            "",
 | 
				
			||||||
			resource:      "nodes",
 | 
								resource:      "nodes",
 | 
				
			||||||
			namespace:     api.NamespaceAll,
 | 
								namespace:     v1.NamespaceAll,
 | 
				
			||||||
			fieldSelector: parseSelectorOrDie(""),
 | 
								fieldSelector: parseSelectorOrDie(""),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			location: buildLocation(
 | 
								location: buildLocation(
 | 
				
			||||||
				testapi.Default.ResourcePathWithPrefix("watch", "nodes", api.NamespaceAll, ""),
 | 
									testapi.Default.ResourcePathWithPrefix("watch", "nodes", v1.NamespaceAll, ""),
 | 
				
			||||||
				buildQueryValues(url.Values{"resourceVersion": []string{"42"}})),
 | 
									buildQueryValues(url.Values{"resourceVersion": []string{"42"}})),
 | 
				
			||||||
			rv:            "42",
 | 
								rv:            "42",
 | 
				
			||||||
			resource:      "nodes",
 | 
								resource:      "nodes",
 | 
				
			||||||
			namespace:     api.NamespaceAll,
 | 
								namespace:     v1.NamespaceAll,
 | 
				
			||||||
			fieldSelector: parseSelectorOrDie(""),
 | 
								fieldSelector: parseSelectorOrDie(""),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		// pod with "assigned" field selector.
 | 
							// pod with "assigned" field selector.
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			location: buildLocation(
 | 
								location: buildLocation(
 | 
				
			||||||
				testapi.Default.ResourcePathWithPrefix("watch", "pods", api.NamespaceAll, ""),
 | 
									testapi.Default.ResourcePathWithPrefix("watch", "pods", v1.NamespaceAll, ""),
 | 
				
			||||||
				buildQueryValues(url.Values{fieldSelectorQueryParamName: []string{"spec.host="}, "resourceVersion": []string{"0"}})),
 | 
									buildQueryValues(url.Values{fieldSelectorQueryParamName: []string{"spec.host="}, "resourceVersion": []string{"0"}})),
 | 
				
			||||||
			rv:            "0",
 | 
								rv:            "0",
 | 
				
			||||||
			resource:      "pods",
 | 
								resource:      "pods",
 | 
				
			||||||
			namespace:     api.NamespaceAll,
 | 
								namespace:     v1.NamespaceAll,
 | 
				
			||||||
			fieldSelector: fields.Set{"spec.host": ""}.AsSelector(),
 | 
								fieldSelector: fields.Set{"spec.host": ""}.AsSelector(),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		// pod with namespace foo and assigned field selector
 | 
							// pod with namespace foo and assigned field selector
 | 
				
			||||||
@@ -167,10 +167,10 @@ func TestListWatchesCanWatch(t *testing.T) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		server := httptest.NewServer(&handler)
 | 
							server := httptest.NewServer(&handler)
 | 
				
			||||||
		defer server.Close()
 | 
							defer server.Close()
 | 
				
			||||||
		client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: ®istered.GroupOrDie(api.GroupName).GroupVersion}})
 | 
							client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: ®istered.GroupOrDie(v1.GroupName).GroupVersion}})
 | 
				
			||||||
		lw := NewListWatchFromClient(client.Core().RESTClient(), item.resource, item.namespace, item.fieldSelector)
 | 
							lw := NewListWatchFromClient(client.Core().RESTClient(), item.resource, item.namespace, item.fieldSelector)
 | 
				
			||||||
		// This test merely tests that the correct request is made.
 | 
							// This test merely tests that the correct request is made.
 | 
				
			||||||
		lw.Watch(api.ListOptions{ResourceVersion: item.rv})
 | 
							lw.Watch(v1.ListOptions{ResourceVersion: item.rv})
 | 
				
			||||||
		handler.ValidateRequest(t, item.location, "GET", nil)
 | 
							handler.ValidateRequest(t, item.location, "GET", nil)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -180,22 +180,22 @@ type lw struct {
 | 
				
			|||||||
	watch watch.Interface
 | 
						watch watch.Interface
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (w lw) List(options api.ListOptions) (runtime.Object, error) {
 | 
					func (w lw) List(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
	return w.list, nil
 | 
						return w.list, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (w lw) Watch(options api.ListOptions) (watch.Interface, error) {
 | 
					func (w lw) Watch(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
	return w.watch, nil
 | 
						return w.watch, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestListWatchUntil(t *testing.T) {
 | 
					func TestListWatchUntil(t *testing.T) {
 | 
				
			||||||
	fw := watch.NewFake()
 | 
						fw := watch.NewFake()
 | 
				
			||||||
	go func() {
 | 
						go func() {
 | 
				
			||||||
		var obj *api.Pod
 | 
							var obj *v1.Pod
 | 
				
			||||||
		fw.Modify(obj)
 | 
							fw.Modify(obj)
 | 
				
			||||||
	}()
 | 
						}()
 | 
				
			||||||
	listwatch := lw{
 | 
						listwatch := lw{
 | 
				
			||||||
		list:  &api.PodList{Items: []api.Pod{{}}},
 | 
							list:  &v1.PodList{Items: []v1.Pod{{}}},
 | 
				
			||||||
		watch: fw,
 | 
							watch: fw,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -221,7 +221,7 @@ func TestListWatchUntil(t *testing.T) {
 | 
				
			|||||||
	if lastEvent.Type != watch.Modified {
 | 
						if lastEvent.Type != watch.Modified {
 | 
				
			||||||
		t.Fatalf("expected MODIFIED event type, got %v", lastEvent.Type)
 | 
							t.Fatalf("expected MODIFIED event type, got %v", lastEvent.Type)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if got, isPod := lastEvent.Object.(*api.Pod); !isPod {
 | 
						if got, isPod := lastEvent.Object.(*v1.Pod); !isPod {
 | 
				
			||||||
		t.Fatalf("expected a pod event, got %#v", got)
 | 
							t.Fatalf("expected a pod event, got %#v", got)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								pkg/client/cache/mutation_detector_test.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								pkg/client/cache/mutation_detector_test.go
									
									
									
									
										vendored
									
									
								
							@@ -22,7 +22,7 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/runtime"
 | 
						"k8s.io/kubernetes/pkg/runtime"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/watch"
 | 
						"k8s.io/kubernetes/pkg/watch"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -30,15 +30,15 @@ import (
 | 
				
			|||||||
func TestMutationDetector(t *testing.T) {
 | 
					func TestMutationDetector(t *testing.T) {
 | 
				
			||||||
	fakeWatch := watch.NewFake()
 | 
						fakeWatch := watch.NewFake()
 | 
				
			||||||
	lw := &testLW{
 | 
						lw := &testLW{
 | 
				
			||||||
		WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
 | 
							WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
			return fakeWatch, nil
 | 
								return fakeWatch, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		ListFunc: func(options api.ListOptions) (runtime.Object, error) {
 | 
							ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
			return &api.PodList{}, nil
 | 
								return &v1.PodList{}, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pod := &api.Pod{
 | 
						pod := &v1.Pod{
 | 
				
			||||||
		ObjectMeta: api.ObjectMeta{
 | 
							ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
			Name:   "anything",
 | 
								Name:   "anything",
 | 
				
			||||||
			Labels: map[string]string{"check": "foo"},
 | 
								Labels: map[string]string{"check": "foo"},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -48,7 +48,7 @@ func TestMutationDetector(t *testing.T) {
 | 
				
			|||||||
	addReceived := make(chan bool)
 | 
						addReceived := make(chan bool)
 | 
				
			||||||
	mutationFound := make(chan bool)
 | 
						mutationFound := make(chan bool)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	informer := NewSharedInformer(lw, &api.Pod{}, 1*time.Second).(*sharedIndexInformer)
 | 
						informer := NewSharedInformer(lw, &v1.Pod{}, 1*time.Second).(*sharedIndexInformer)
 | 
				
			||||||
	informer.cacheMutationDetector = &defaultCacheMutationDetector{
 | 
						informer.cacheMutationDetector = &defaultCacheMutationDetector{
 | 
				
			||||||
		name:   "name",
 | 
							name:   "name",
 | 
				
			||||||
		period: 1 * time.Second,
 | 
							period: 1 * time.Second,
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								pkg/client/cache/reflector.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								pkg/client/cache/reflector.go
									
									
									
									
										vendored
									
									
								
							@@ -34,9 +34,9 @@ import (
 | 
				
			|||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/golang/glog"
 | 
						"github.com/golang/glog"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
					 | 
				
			||||||
	apierrs "k8s.io/kubernetes/pkg/api/errors"
 | 
						apierrs "k8s.io/kubernetes/pkg/api/errors"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/meta"
 | 
						"k8s.io/kubernetes/pkg/api/meta"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/runtime"
 | 
						"k8s.io/kubernetes/pkg/runtime"
 | 
				
			||||||
	utilruntime "k8s.io/kubernetes/pkg/util/runtime"
 | 
						utilruntime "k8s.io/kubernetes/pkg/util/runtime"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/wait"
 | 
						"k8s.io/kubernetes/pkg/util/wait"
 | 
				
			||||||
@@ -239,7 +239,7 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error {
 | 
				
			|||||||
	// Explicitly set "0" as resource version - it's fine for the List()
 | 
						// Explicitly set "0" as resource version - it's fine for the List()
 | 
				
			||||||
	// to be served from cache and potentially be delayed relative to
 | 
						// to be served from cache and potentially be delayed relative to
 | 
				
			||||||
	// etcd contents. Reflector framework will catch up via Watch() eventually.
 | 
						// etcd contents. Reflector framework will catch up via Watch() eventually.
 | 
				
			||||||
	options := api.ListOptions{ResourceVersion: "0"}
 | 
						options := v1.ListOptions{ResourceVersion: "0"}
 | 
				
			||||||
	list, err := r.listerWatcher.List(options)
 | 
						list, err := r.listerWatcher.List(options)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return fmt.Errorf("%s: Failed to list %v: %v", r.name, r.expectedType, err)
 | 
							return fmt.Errorf("%s: Failed to list %v: %v", r.name, r.expectedType, err)
 | 
				
			||||||
@@ -278,7 +278,7 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for {
 | 
						for {
 | 
				
			||||||
		timemoutseconds := int64(minWatchTimeout.Seconds() * (rand.Float64() + 1.0))
 | 
							timemoutseconds := int64(minWatchTimeout.Seconds() * (rand.Float64() + 1.0))
 | 
				
			||||||
		options = api.ListOptions{
 | 
							options = v1.ListOptions{
 | 
				
			||||||
			ResourceVersion: resourceVersion,
 | 
								ResourceVersion: resourceVersion,
 | 
				
			||||||
			// We want to avoid situations of hanging watchers. Stop any wachers that do not
 | 
								// We want to avoid situations of hanging watchers. Stop any wachers that do not
 | 
				
			||||||
			// receive any events within the timeout window.
 | 
								// receive any events within the timeout window.
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										98
									
								
								pkg/client/cache/reflector_test.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										98
									
								
								pkg/client/cache/reflector_test.go
									
									
									
									
										vendored
									
									
								
							@@ -24,8 +24,8 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/runtime"
 | 
						"k8s.io/kubernetes/pkg/runtime"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/wait"
 | 
						"k8s.io/kubernetes/pkg/util/wait"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/watch"
 | 
						"k8s.io/kubernetes/pkg/watch"
 | 
				
			||||||
@@ -34,27 +34,27 @@ import (
 | 
				
			|||||||
var nevererrc chan error
 | 
					var nevererrc chan error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type testLW struct {
 | 
					type testLW struct {
 | 
				
			||||||
	ListFunc  func(options api.ListOptions) (runtime.Object, error)
 | 
						ListFunc  func(options v1.ListOptions) (runtime.Object, error)
 | 
				
			||||||
	WatchFunc func(options api.ListOptions) (watch.Interface, error)
 | 
						WatchFunc func(options v1.ListOptions) (watch.Interface, error)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (t *testLW) List(options api.ListOptions) (runtime.Object, error) {
 | 
					func (t *testLW) List(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
	return t.ListFunc(options)
 | 
						return t.ListFunc(options)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
func (t *testLW) Watch(options api.ListOptions) (watch.Interface, error) {
 | 
					func (t *testLW) Watch(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
	return t.WatchFunc(options)
 | 
						return t.WatchFunc(options)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestCloseWatchChannelOnError(t *testing.T) {
 | 
					func TestCloseWatchChannelOnError(t *testing.T) {
 | 
				
			||||||
	r := NewReflector(&testLW{}, &api.Pod{}, NewStore(MetaNamespaceKeyFunc), 0)
 | 
						r := NewReflector(&testLW{}, &v1.Pod{}, NewStore(MetaNamespaceKeyFunc), 0)
 | 
				
			||||||
	pod := &api.Pod{ObjectMeta: api.ObjectMeta{Name: "bar"}}
 | 
						pod := &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "bar"}}
 | 
				
			||||||
	fw := watch.NewFake()
 | 
						fw := watch.NewFake()
 | 
				
			||||||
	r.listerWatcher = &testLW{
 | 
						r.listerWatcher = &testLW{
 | 
				
			||||||
		WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
 | 
							WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
			return fw, nil
 | 
								return fw, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		ListFunc: func(options api.ListOptions) (runtime.Object, error) {
 | 
							ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
			return &api.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "1"}}, nil
 | 
								return &v1.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "1"}}, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	go r.ListAndWatch(wait.NeverStop)
 | 
						go r.ListAndWatch(wait.NeverStop)
 | 
				
			||||||
@@ -73,20 +73,20 @@ func TestCloseWatchChannelOnError(t *testing.T) {
 | 
				
			|||||||
func TestRunUntil(t *testing.T) {
 | 
					func TestRunUntil(t *testing.T) {
 | 
				
			||||||
	stopCh := make(chan struct{})
 | 
						stopCh := make(chan struct{})
 | 
				
			||||||
	store := NewStore(MetaNamespaceKeyFunc)
 | 
						store := NewStore(MetaNamespaceKeyFunc)
 | 
				
			||||||
	r := NewReflector(&testLW{}, &api.Pod{}, store, 0)
 | 
						r := NewReflector(&testLW{}, &v1.Pod{}, store, 0)
 | 
				
			||||||
	fw := watch.NewFake()
 | 
						fw := watch.NewFake()
 | 
				
			||||||
	r.listerWatcher = &testLW{
 | 
						r.listerWatcher = &testLW{
 | 
				
			||||||
		WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
 | 
							WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
			return fw, nil
 | 
								return fw, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		ListFunc: func(options api.ListOptions) (runtime.Object, error) {
 | 
							ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
			return &api.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "1"}}, nil
 | 
								return &v1.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "1"}}, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	r.RunUntil(stopCh)
 | 
						r.RunUntil(stopCh)
 | 
				
			||||||
	// Synchronously add a dummy pod into the watch channel so we
 | 
						// Synchronously add a dummy pod into the watch channel so we
 | 
				
			||||||
	// know the RunUntil go routine is in the watch handler.
 | 
						// know the RunUntil go routine is in the watch handler.
 | 
				
			||||||
	fw.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "bar"}})
 | 
						fw.Add(&v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "bar"}})
 | 
				
			||||||
	close(stopCh)
 | 
						close(stopCh)
 | 
				
			||||||
	select {
 | 
						select {
 | 
				
			||||||
	case _, ok := <-fw.ResultChan():
 | 
						case _, ok := <-fw.ResultChan():
 | 
				
			||||||
@@ -101,7 +101,7 @@ func TestRunUntil(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestReflectorResyncChan(t *testing.T) {
 | 
					func TestReflectorResyncChan(t *testing.T) {
 | 
				
			||||||
	s := NewStore(MetaNamespaceKeyFunc)
 | 
						s := NewStore(MetaNamespaceKeyFunc)
 | 
				
			||||||
	g := NewReflector(&testLW{}, &api.Pod{}, s, time.Millisecond)
 | 
						g := NewReflector(&testLW{}, &v1.Pod{}, s, time.Millisecond)
 | 
				
			||||||
	a, _ := g.resyncChan()
 | 
						a, _ := g.resyncChan()
 | 
				
			||||||
	b := time.After(wait.ForeverTestTimeout)
 | 
						b := time.After(wait.ForeverTestTimeout)
 | 
				
			||||||
	select {
 | 
						select {
 | 
				
			||||||
@@ -114,7 +114,7 @@ func TestReflectorResyncChan(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func BenchmarkReflectorResyncChanMany(b *testing.B) {
 | 
					func BenchmarkReflectorResyncChanMany(b *testing.B) {
 | 
				
			||||||
	s := NewStore(MetaNamespaceKeyFunc)
 | 
						s := NewStore(MetaNamespaceKeyFunc)
 | 
				
			||||||
	g := NewReflector(&testLW{}, &api.Pod{}, s, 25*time.Millisecond)
 | 
						g := NewReflector(&testLW{}, &v1.Pod{}, s, 25*time.Millisecond)
 | 
				
			||||||
	// The improvement to this (calling the timer's Stop() method) makes
 | 
						// The improvement to this (calling the timer's Stop() method) makes
 | 
				
			||||||
	// this benchmark about 40% faster.
 | 
						// this benchmark about 40% faster.
 | 
				
			||||||
	for i := 0; i < b.N; i++ {
 | 
						for i := 0; i < b.N; i++ {
 | 
				
			||||||
@@ -126,7 +126,7 @@ func BenchmarkReflectorResyncChanMany(b *testing.B) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestReflectorWatchHandlerError(t *testing.T) {
 | 
					func TestReflectorWatchHandlerError(t *testing.T) {
 | 
				
			||||||
	s := NewStore(MetaNamespaceKeyFunc)
 | 
						s := NewStore(MetaNamespaceKeyFunc)
 | 
				
			||||||
	g := NewReflector(&testLW{}, &api.Pod{}, s, 0)
 | 
						g := NewReflector(&testLW{}, &v1.Pod{}, s, 0)
 | 
				
			||||||
	fw := watch.NewFake()
 | 
						fw := watch.NewFake()
 | 
				
			||||||
	go func() {
 | 
						go func() {
 | 
				
			||||||
		fw.Stop()
 | 
							fw.Stop()
 | 
				
			||||||
@@ -140,15 +140,15 @@ func TestReflectorWatchHandlerError(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestReflectorWatchHandler(t *testing.T) {
 | 
					func TestReflectorWatchHandler(t *testing.T) {
 | 
				
			||||||
	s := NewStore(MetaNamespaceKeyFunc)
 | 
						s := NewStore(MetaNamespaceKeyFunc)
 | 
				
			||||||
	g := NewReflector(&testLW{}, &api.Pod{}, s, 0)
 | 
						g := NewReflector(&testLW{}, &v1.Pod{}, s, 0)
 | 
				
			||||||
	fw := watch.NewFake()
 | 
						fw := watch.NewFake()
 | 
				
			||||||
	s.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}})
 | 
						s.Add(&v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "foo"}})
 | 
				
			||||||
	s.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "bar"}})
 | 
						s.Add(&v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "bar"}})
 | 
				
			||||||
	go func() {
 | 
						go func() {
 | 
				
			||||||
		fw.Add(&api.Service{ObjectMeta: api.ObjectMeta{Name: "rejected"}})
 | 
							fw.Add(&v1.Service{ObjectMeta: v1.ObjectMeta{Name: "rejected"}})
 | 
				
			||||||
		fw.Delete(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "foo"}})
 | 
							fw.Delete(&v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "foo"}})
 | 
				
			||||||
		fw.Modify(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "55"}})
 | 
							fw.Modify(&v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "bar", ResourceVersion: "55"}})
 | 
				
			||||||
		fw.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "baz", ResourceVersion: "32"}})
 | 
							fw.Add(&v1.Pod{ObjectMeta: v1.ObjectMeta{Name: "baz", ResourceVersion: "32"}})
 | 
				
			||||||
		fw.Stop()
 | 
							fw.Stop()
 | 
				
			||||||
	}()
 | 
						}()
 | 
				
			||||||
	var resumeRV string
 | 
						var resumeRV string
 | 
				
			||||||
@@ -157,12 +157,12 @@ func TestReflectorWatchHandler(t *testing.T) {
 | 
				
			|||||||
		t.Errorf("unexpected error %v", err)
 | 
							t.Errorf("unexpected error %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mkPod := func(id string, rv string) *api.Pod {
 | 
						mkPod := func(id string, rv string) *v1.Pod {
 | 
				
			||||||
		return &api.Pod{ObjectMeta: api.ObjectMeta{Name: id, ResourceVersion: rv}}
 | 
							return &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: id, ResourceVersion: rv}}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	table := []struct {
 | 
						table := []struct {
 | 
				
			||||||
		Pod    *api.Pod
 | 
							Pod    *v1.Pod
 | 
				
			||||||
		exists bool
 | 
							exists bool
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{mkPod("foo", ""), false},
 | 
							{mkPod("foo", ""), false},
 | 
				
			||||||
@@ -178,7 +178,7 @@ func TestReflectorWatchHandler(t *testing.T) {
 | 
				
			|||||||
		if !exists {
 | 
							if !exists {
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if e, a := item.Pod.ResourceVersion, obj.(*api.Pod).ResourceVersion; e != a {
 | 
							if e, a := item.Pod.ResourceVersion, obj.(*v1.Pod).ResourceVersion; e != a {
 | 
				
			||||||
			t.Errorf("%v: expected %v, got %v", item.Pod, e, a)
 | 
								t.Errorf("%v: expected %v, got %v", item.Pod, e, a)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -196,7 +196,7 @@ func TestReflectorWatchHandler(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestReflectorStopWatch(t *testing.T) {
 | 
					func TestReflectorStopWatch(t *testing.T) {
 | 
				
			||||||
	s := NewStore(MetaNamespaceKeyFunc)
 | 
						s := NewStore(MetaNamespaceKeyFunc)
 | 
				
			||||||
	g := NewReflector(&testLW{}, &api.Pod{}, s, 0)
 | 
						g := NewReflector(&testLW{}, &v1.Pod{}, s, 0)
 | 
				
			||||||
	fw := watch.NewFake()
 | 
						fw := watch.NewFake()
 | 
				
			||||||
	var resumeRV string
 | 
						var resumeRV string
 | 
				
			||||||
	stopWatch := make(chan struct{}, 1)
 | 
						stopWatch := make(chan struct{}, 1)
 | 
				
			||||||
@@ -215,7 +215,7 @@ func TestReflectorListAndWatch(t *testing.T) {
 | 
				
			|||||||
	// inject an error.
 | 
						// inject an error.
 | 
				
			||||||
	expectedRVs := []string{"1", "3"}
 | 
						expectedRVs := []string{"1", "3"}
 | 
				
			||||||
	lw := &testLW{
 | 
						lw := &testLW{
 | 
				
			||||||
		WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
 | 
							WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
			rv := options.ResourceVersion
 | 
								rv := options.ResourceVersion
 | 
				
			||||||
			fw := watch.NewFake()
 | 
								fw := watch.NewFake()
 | 
				
			||||||
			if e, a := expectedRVs[0], rv; e != a {
 | 
								if e, a := expectedRVs[0], rv; e != a {
 | 
				
			||||||
@@ -227,12 +227,12 @@ func TestReflectorListAndWatch(t *testing.T) {
 | 
				
			|||||||
			go func() { createdFakes <- fw }()
 | 
								go func() { createdFakes <- fw }()
 | 
				
			||||||
			return fw, nil
 | 
								return fw, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		ListFunc: func(options api.ListOptions) (runtime.Object, error) {
 | 
							ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
			return &api.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "1"}}, nil
 | 
								return &v1.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "1"}}, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	s := NewFIFO(MetaNamespaceKeyFunc)
 | 
						s := NewFIFO(MetaNamespaceKeyFunc)
 | 
				
			||||||
	r := NewReflector(lw, &api.Pod{}, s, 0)
 | 
						r := NewReflector(lw, &v1.Pod{}, s, 0)
 | 
				
			||||||
	go r.ListAndWatch(wait.NeverStop)
 | 
						go r.ListAndWatch(wait.NeverStop)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ids := []string{"foo", "bar", "baz", "qux", "zoo"}
 | 
						ids := []string{"foo", "bar", "baz", "qux", "zoo"}
 | 
				
			||||||
@@ -242,7 +242,7 @@ func TestReflectorListAndWatch(t *testing.T) {
 | 
				
			|||||||
			fw = <-createdFakes
 | 
								fw = <-createdFakes
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		sendingRV := strconv.FormatUint(uint64(i+2), 10)
 | 
							sendingRV := strconv.FormatUint(uint64(i+2), 10)
 | 
				
			||||||
		fw.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: id, ResourceVersion: sendingRV}})
 | 
							fw.Add(&v1.Pod{ObjectMeta: v1.ObjectMeta{Name: id, ResourceVersion: sendingRV}})
 | 
				
			||||||
		if sendingRV == "3" {
 | 
							if sendingRV == "3" {
 | 
				
			||||||
			// Inject a failure.
 | 
								// Inject a failure.
 | 
				
			||||||
			fw.Stop()
 | 
								fw.Stop()
 | 
				
			||||||
@@ -252,7 +252,7 @@ func TestReflectorListAndWatch(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Verify we received the right ids with the right resource versions.
 | 
						// Verify we received the right ids with the right resource versions.
 | 
				
			||||||
	for i, id := range ids {
 | 
						for i, id := range ids {
 | 
				
			||||||
		pod := Pop(s).(*api.Pod)
 | 
							pod := Pop(s).(*v1.Pod)
 | 
				
			||||||
		if e, a := id, pod.Name; e != a {
 | 
							if e, a := id, pod.Name; e != a {
 | 
				
			||||||
			t.Errorf("%v: Expected %v, got %v", i, e, a)
 | 
								t.Errorf("%v: Expected %v, got %v", i, e, a)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -267,18 +267,18 @@ func TestReflectorListAndWatch(t *testing.T) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestReflectorListAndWatchWithErrors(t *testing.T) {
 | 
					func TestReflectorListAndWatchWithErrors(t *testing.T) {
 | 
				
			||||||
	mkPod := func(id string, rv string) *api.Pod {
 | 
						mkPod := func(id string, rv string) *v1.Pod {
 | 
				
			||||||
		return &api.Pod{ObjectMeta: api.ObjectMeta{Name: id, ResourceVersion: rv}}
 | 
							return &v1.Pod{ObjectMeta: v1.ObjectMeta{Name: id, ResourceVersion: rv}}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	mkList := func(rv string, pods ...*api.Pod) *api.PodList {
 | 
						mkList := func(rv string, pods ...*v1.Pod) *v1.PodList {
 | 
				
			||||||
		list := &api.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: rv}}
 | 
							list := &v1.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: rv}}
 | 
				
			||||||
		for _, pod := range pods {
 | 
							for _, pod := range pods {
 | 
				
			||||||
			list.Items = append(list.Items, *pod)
 | 
								list.Items = append(list.Items, *pod)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return list
 | 
							return list
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	table := []struct {
 | 
						table := []struct {
 | 
				
			||||||
		list     *api.PodList
 | 
							list     *v1.PodList
 | 
				
			||||||
		listErr  error
 | 
							listErr  error
 | 
				
			||||||
		events   []watch.Event
 | 
							events   []watch.Event
 | 
				
			||||||
		watchErr error
 | 
							watchErr error
 | 
				
			||||||
@@ -317,7 +317,7 @@ func TestReflectorListAndWatchWithErrors(t *testing.T) {
 | 
				
			|||||||
			current := s.List()
 | 
								current := s.List()
 | 
				
			||||||
			checkMap := map[string]string{}
 | 
								checkMap := map[string]string{}
 | 
				
			||||||
			for _, item := range current {
 | 
								for _, item := range current {
 | 
				
			||||||
				pod := item.(*api.Pod)
 | 
									pod := item.(*v1.Pod)
 | 
				
			||||||
				checkMap[pod.Name] = pod.ResourceVersion
 | 
									checkMap[pod.Name] = pod.ResourceVersion
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			for _, pod := range item.list.Items {
 | 
								for _, pod := range item.list.Items {
 | 
				
			||||||
@@ -331,7 +331,7 @@ func TestReflectorListAndWatchWithErrors(t *testing.T) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		watchRet, watchErr := item.events, item.watchErr
 | 
							watchRet, watchErr := item.events, item.watchErr
 | 
				
			||||||
		lw := &testLW{
 | 
							lw := &testLW{
 | 
				
			||||||
			WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
 | 
								WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
				if watchErr != nil {
 | 
									if watchErr != nil {
 | 
				
			||||||
					return nil, watchErr
 | 
										return nil, watchErr
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
@@ -345,11 +345,11 @@ func TestReflectorListAndWatchWithErrors(t *testing.T) {
 | 
				
			|||||||
				}()
 | 
									}()
 | 
				
			||||||
				return fw, nil
 | 
									return fw, nil
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			ListFunc: func(options api.ListOptions) (runtime.Object, error) {
 | 
								ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
				return item.list, item.listErr
 | 
									return item.list, item.listErr
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		r := NewReflector(lw, &api.Pod{}, s, 0)
 | 
							r := NewReflector(lw, &v1.Pod{}, s, 0)
 | 
				
			||||||
		r.ListAndWatch(wait.NeverStop)
 | 
							r.ListAndWatch(wait.NeverStop)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -369,16 +369,16 @@ func TestReflectorResync(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lw := &testLW{
 | 
						lw := &testLW{
 | 
				
			||||||
		WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
 | 
							WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
			fw := watch.NewFake()
 | 
								fw := watch.NewFake()
 | 
				
			||||||
			return fw, nil
 | 
								return fw, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		ListFunc: func(options api.ListOptions) (runtime.Object, error) {
 | 
							ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
			return &api.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "0"}}, nil
 | 
								return &v1.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "0"}}, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	resyncPeriod := 1 * time.Millisecond
 | 
						resyncPeriod := 1 * time.Millisecond
 | 
				
			||||||
	r := NewReflector(lw, &api.Pod{}, s, resyncPeriod)
 | 
						r := NewReflector(lw, &v1.Pod{}, s, resyncPeriod)
 | 
				
			||||||
	if err := r.ListAndWatch(stopCh); err != nil {
 | 
						if err := r.ListAndWatch(stopCh); err != nil {
 | 
				
			||||||
		// error from Resync is not propaged up to here.
 | 
							// error from Resync is not propaged up to here.
 | 
				
			||||||
		t.Errorf("expected error %v", err)
 | 
							t.Errorf("expected error %v", err)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,6 +20,7 @@ import (
 | 
				
			|||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/fields"
 | 
						"k8s.io/kubernetes/pkg/fields"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/runtime"
 | 
						"k8s.io/kubernetes/pkg/runtime"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -148,14 +149,47 @@ type EventSinkImpl struct {
 | 
				
			|||||||
	Interface EventInterface
 | 
						Interface EventInterface
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e *EventSinkImpl) Create(event *api.Event) (*api.Event, error) {
 | 
					func (e *EventSinkImpl) Create(event *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
	return e.Interface.CreateWithEventNamespace(event)
 | 
						internalEvent := &api.Event{}
 | 
				
			||||||
 | 
						err := v1.Convert_v1_Event_To_api_Event(event, internalEvent, nil)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_, err = e.Interface.CreateWithEventNamespace(internalEvent)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return event, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e *EventSinkImpl) Update(event *api.Event) (*api.Event, error) {
 | 
					func (e *EventSinkImpl) Update(event *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
	return e.Interface.UpdateWithEventNamespace(event)
 | 
						internalEvent := &api.Event{}
 | 
				
			||||||
 | 
						err := v1.Convert_v1_Event_To_api_Event(event, internalEvent, nil)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						_, err = e.Interface.UpdateWithEventNamespace(internalEvent)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return event, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e *EventSinkImpl) Patch(event *api.Event, data []byte) (*api.Event, error) {
 | 
					func (e *EventSinkImpl) Patch(event *v1.Event, data []byte) (*v1.Event, error) {
 | 
				
			||||||
	return e.Interface.PatchWithEventNamespace(event, data)
 | 
						internalEvent := &api.Event{}
 | 
				
			||||||
 | 
						err := v1.Convert_v1_Event_To_api_Event(event, internalEvent, nil)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						internalEvent, err = e.Interface.PatchWithEventNamespace(internalEvent, data)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						externalEvent := &v1.Event{}
 | 
				
			||||||
 | 
						err = v1.Convert_api_Event_To_v1_Event(internalEvent, externalEvent, nil)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							// Patch succeeded, no need to report the failed conversion
 | 
				
			||||||
 | 
							return event, nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return externalEvent, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										164
									
								
								pkg/client/conditions/conditions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										164
									
								
								pkg/client/conditions/conditions.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,164 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					Copyright 2014 The Kubernetes Authors.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
 | 
					You may obtain a copy of the License at
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    http://www.apache.org/licenses/LICENSE-2.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Unless required by applicable law or agreed to in writing, software
 | 
				
			||||||
 | 
					distributed under the License is distributed on an "AS IS" BASIS,
 | 
				
			||||||
 | 
					WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
				
			||||||
 | 
					See the License for the specific language governing permissions and
 | 
				
			||||||
 | 
					limitations under the License.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package conditions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/errors"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/watch"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ErrPodCompleted is returned by PodRunning or PodContainerRunning to indicate that
 | 
				
			||||||
 | 
					// the pod has already reached completed state.
 | 
				
			||||||
 | 
					var ErrPodCompleted = fmt.Errorf("pod ran to completion")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ErrContainerTerminated is returned by PodContainerRunning in the intermediate
 | 
				
			||||||
 | 
					// state where the pod indicates it's still running, but its container is already terminated
 | 
				
			||||||
 | 
					var ErrContainerTerminated = fmt.Errorf("container terminated")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// PodRunning returns true if the pod is running, false if the pod has not yet reached running state,
 | 
				
			||||||
 | 
					// returns ErrPodCompleted if the pod has run to completion, or an error in any other case.
 | 
				
			||||||
 | 
					func PodRunning(event watch.Event) (bool, error) {
 | 
				
			||||||
 | 
						switch event.Type {
 | 
				
			||||||
 | 
						case watch.Deleted:
 | 
				
			||||||
 | 
							return false, errors.NewNotFound(unversioned.GroupResource{Resource: "pods"}, "")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						switch t := event.Object.(type) {
 | 
				
			||||||
 | 
						case *v1.Pod:
 | 
				
			||||||
 | 
							switch t.Status.Phase {
 | 
				
			||||||
 | 
							case v1.PodRunning:
 | 
				
			||||||
 | 
								return true, nil
 | 
				
			||||||
 | 
							case v1.PodFailed, v1.PodSucceeded:
 | 
				
			||||||
 | 
								return false, ErrPodCompleted
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return false, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// PodCompleted returns true if the pod has run to completion, false if the pod has not yet
 | 
				
			||||||
 | 
					// reached running state, or an error in any other case.
 | 
				
			||||||
 | 
					func PodCompleted(event watch.Event) (bool, error) {
 | 
				
			||||||
 | 
						switch event.Type {
 | 
				
			||||||
 | 
						case watch.Deleted:
 | 
				
			||||||
 | 
							return false, errors.NewNotFound(unversioned.GroupResource{Resource: "pods"}, "")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						switch t := event.Object.(type) {
 | 
				
			||||||
 | 
						case *v1.Pod:
 | 
				
			||||||
 | 
							switch t.Status.Phase {
 | 
				
			||||||
 | 
							case v1.PodFailed, v1.PodSucceeded:
 | 
				
			||||||
 | 
								return true, nil
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return false, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// PodRunningAndReady returns true if the pod is running and ready, false if the pod has not
 | 
				
			||||||
 | 
					// yet reached those states, returns ErrPodCompleted if the pod has run to completion, or
 | 
				
			||||||
 | 
					// an error in any other case.
 | 
				
			||||||
 | 
					func PodRunningAndReady(event watch.Event) (bool, error) {
 | 
				
			||||||
 | 
						switch event.Type {
 | 
				
			||||||
 | 
						case watch.Deleted:
 | 
				
			||||||
 | 
							return false, errors.NewNotFound(unversioned.GroupResource{Resource: "pods"}, "")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						switch t := event.Object.(type) {
 | 
				
			||||||
 | 
						case *v1.Pod:
 | 
				
			||||||
 | 
							switch t.Status.Phase {
 | 
				
			||||||
 | 
							case v1.PodFailed, v1.PodSucceeded:
 | 
				
			||||||
 | 
								return false, ErrPodCompleted
 | 
				
			||||||
 | 
							case v1.PodRunning:
 | 
				
			||||||
 | 
								return v1.IsPodReady(t), nil
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return false, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// PodNotPending returns true if the pod has left the pending state, false if it has not,
 | 
				
			||||||
 | 
					// or an error in any other case (such as if the pod was deleted).
 | 
				
			||||||
 | 
					func PodNotPending(event watch.Event) (bool, error) {
 | 
				
			||||||
 | 
						switch event.Type {
 | 
				
			||||||
 | 
						case watch.Deleted:
 | 
				
			||||||
 | 
							return false, errors.NewNotFound(unversioned.GroupResource{Resource: "pods"}, "")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						switch t := event.Object.(type) {
 | 
				
			||||||
 | 
						case *v1.Pod:
 | 
				
			||||||
 | 
							switch t.Status.Phase {
 | 
				
			||||||
 | 
							case v1.PodPending:
 | 
				
			||||||
 | 
								return false, nil
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
								return true, nil
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return false, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// PodContainerRunning returns false until the named container has ContainerStatus running (at least once),
 | 
				
			||||||
 | 
					// and will return an error if the pod is deleted, runs to completion, or the container pod is not available.
 | 
				
			||||||
 | 
					func PodContainerRunning(containerName string) watch.ConditionFunc {
 | 
				
			||||||
 | 
						return func(event watch.Event) (bool, error) {
 | 
				
			||||||
 | 
							switch event.Type {
 | 
				
			||||||
 | 
							case watch.Deleted:
 | 
				
			||||||
 | 
								return false, errors.NewNotFound(unversioned.GroupResource{Resource: "pods"}, "")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							switch t := event.Object.(type) {
 | 
				
			||||||
 | 
							case *v1.Pod:
 | 
				
			||||||
 | 
								switch t.Status.Phase {
 | 
				
			||||||
 | 
								case v1.PodRunning, v1.PodPending:
 | 
				
			||||||
 | 
								case v1.PodFailed, v1.PodSucceeded:
 | 
				
			||||||
 | 
									return false, ErrPodCompleted
 | 
				
			||||||
 | 
								default:
 | 
				
			||||||
 | 
									return false, nil
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								for _, s := range t.Status.ContainerStatuses {
 | 
				
			||||||
 | 
									if s.Name != containerName {
 | 
				
			||||||
 | 
										continue
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									if s.State.Terminated != nil {
 | 
				
			||||||
 | 
										return false, ErrContainerTerminated
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									return s.State.Running != nil, nil
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								for _, s := range t.Status.InitContainerStatuses {
 | 
				
			||||||
 | 
									if s.Name != containerName {
 | 
				
			||||||
 | 
										continue
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									if s.State.Terminated != nil {
 | 
				
			||||||
 | 
										return false, ErrContainerTerminated
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									return s.State.Running != nil, nil
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								return false, nil
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false, nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ServiceAccountHasSecrets returns true if the service account has at least one secret,
 | 
				
			||||||
 | 
					// false if it does not, or an error.
 | 
				
			||||||
 | 
					func ServiceAccountHasSecrets(event watch.Event) (bool, error) {
 | 
				
			||||||
 | 
						switch event.Type {
 | 
				
			||||||
 | 
						case watch.Deleted:
 | 
				
			||||||
 | 
							return false, errors.NewNotFound(unversioned.GroupResource{Resource: "serviceaccounts"}, "")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						switch t := event.Object.(type) {
 | 
				
			||||||
 | 
						case *v1.ServiceAccount:
 | 
				
			||||||
 | 
							return len(t.Secrets) > 0, nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return false, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -26,10 +26,10 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/errors"
 | 
						"k8s.io/kubernetes/pkg/api/errors"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
	fakeclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
 | 
						fakeclientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5/fake"
 | 
				
			||||||
	rl "k8s.io/kubernetes/pkg/client/leaderelection/resourcelock"
 | 
						rl "k8s.io/kubernetes/pkg/client/leaderelection/resourcelock"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/client/record"
 | 
						"k8s.io/kubernetes/pkg/client/record"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/client/testing/core"
 | 
						"k8s.io/kubernetes/pkg/client/testing/core"
 | 
				
			||||||
@@ -67,7 +67,7 @@ func TestTryAcquireOrRenew(t *testing.T) {
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					verb: "create",
 | 
										verb: "create",
 | 
				
			||||||
					reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
										reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
				
			||||||
						return true, action.(core.CreateAction).GetObject().(*api.Endpoints), nil
 | 
											return true, action.(core.CreateAction).GetObject().(*v1.Endpoints), nil
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@@ -83,8 +83,8 @@ func TestTryAcquireOrRenew(t *testing.T) {
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					verb: "get",
 | 
										verb: "get",
 | 
				
			||||||
					reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
										reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
				
			||||||
						return true, &api.Endpoints{
 | 
											return true, &v1.Endpoints{
 | 
				
			||||||
							ObjectMeta: api.ObjectMeta{
 | 
												ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
								Namespace: action.GetNamespace(),
 | 
													Namespace: action.GetNamespace(),
 | 
				
			||||||
								Name:      action.(core.GetAction).GetName(),
 | 
													Name:      action.(core.GetAction).GetName(),
 | 
				
			||||||
							},
 | 
												},
 | 
				
			||||||
@@ -94,7 +94,7 @@ func TestTryAcquireOrRenew(t *testing.T) {
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					verb: "update",
 | 
										verb: "update",
 | 
				
			||||||
					reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
										reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
				
			||||||
						return true, action.(core.CreateAction).GetObject().(*api.Endpoints), nil
 | 
											return true, action.(core.CreateAction).GetObject().(*v1.Endpoints), nil
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@@ -112,8 +112,8 @@ func TestTryAcquireOrRenew(t *testing.T) {
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					verb: "get",
 | 
										verb: "get",
 | 
				
			||||||
					reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
										reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
				
			||||||
						return true, &api.Endpoints{
 | 
											return true, &v1.Endpoints{
 | 
				
			||||||
							ObjectMeta: api.ObjectMeta{
 | 
												ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
								Namespace: action.GetNamespace(),
 | 
													Namespace: action.GetNamespace(),
 | 
				
			||||||
								Name:      action.(core.GetAction).GetName(),
 | 
													Name:      action.(core.GetAction).GetName(),
 | 
				
			||||||
								Annotations: map[string]string{
 | 
													Annotations: map[string]string{
 | 
				
			||||||
@@ -126,7 +126,7 @@ func TestTryAcquireOrRenew(t *testing.T) {
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					verb: "update",
 | 
										verb: "update",
 | 
				
			||||||
					reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
										reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
				
			||||||
						return true, action.(core.CreateAction).GetObject().(*api.Endpoints), nil
 | 
											return true, action.(core.CreateAction).GetObject().(*v1.Endpoints), nil
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@@ -146,8 +146,8 @@ func TestTryAcquireOrRenew(t *testing.T) {
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					verb: "get",
 | 
										verb: "get",
 | 
				
			||||||
					reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
										reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
				
			||||||
						return true, &api.Endpoints{
 | 
											return true, &v1.Endpoints{
 | 
				
			||||||
							ObjectMeta: api.ObjectMeta{
 | 
												ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
								Namespace: action.GetNamespace(),
 | 
													Namespace: action.GetNamespace(),
 | 
				
			||||||
								Name:      action.(core.GetAction).GetName(),
 | 
													Name:      action.(core.GetAction).GetName(),
 | 
				
			||||||
								Annotations: map[string]string{
 | 
													Annotations: map[string]string{
 | 
				
			||||||
@@ -172,8 +172,8 @@ func TestTryAcquireOrRenew(t *testing.T) {
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					verb: "get",
 | 
										verb: "get",
 | 
				
			||||||
					reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
										reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
				
			||||||
						return true, &api.Endpoints{
 | 
											return true, &v1.Endpoints{
 | 
				
			||||||
							ObjectMeta: api.ObjectMeta{
 | 
												ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
								Namespace: action.GetNamespace(),
 | 
													Namespace: action.GetNamespace(),
 | 
				
			||||||
								Name:      action.(core.GetAction).GetName(),
 | 
													Name:      action.(core.GetAction).GetName(),
 | 
				
			||||||
								Annotations: map[string]string{
 | 
													Annotations: map[string]string{
 | 
				
			||||||
@@ -186,7 +186,7 @@ func TestTryAcquireOrRenew(t *testing.T) {
 | 
				
			|||||||
				{
 | 
									{
 | 
				
			||||||
					verb: "update",
 | 
										verb: "update",
 | 
				
			||||||
					reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
										reaction: func(action core.Action) (handled bool, ret runtime.Object, err error) {
 | 
				
			||||||
						return true, action.(core.CreateAction).GetObject().(*api.Endpoints), nil
 | 
											return true, action.(core.CreateAction).GetObject().(*v1.Endpoints), nil
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@@ -205,7 +205,7 @@ func TestTryAcquireOrRenew(t *testing.T) {
 | 
				
			|||||||
		var reportedLeader string
 | 
							var reportedLeader string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		lock := rl.EndpointsLock{
 | 
							lock := rl.EndpointsLock{
 | 
				
			||||||
			EndpointsMeta: api.ObjectMeta{Namespace: "foo", Name: "bar"},
 | 
								EndpointsMeta: v1.ObjectMeta{Namespace: "foo", Name: "bar"},
 | 
				
			||||||
			LockConfig: rl.ResourceLockConfig{
 | 
								LockConfig: rl.ResourceLockConfig{
 | 
				
			||||||
				Identity:      "baz",
 | 
									Identity:      "baz",
 | 
				
			||||||
				EventRecorder: &record.FakeRecorder{},
 | 
									EventRecorder: &record.FakeRecorder{},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,17 +21,17 @@ import (
 | 
				
			|||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
 | 
						clientset "k8s.io/kubernetes/pkg/client/clientset_generated/release_1_5"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type EndpointsLock struct {
 | 
					type EndpointsLock struct {
 | 
				
			||||||
	// EndpointsMeta should contain a Name and a Namespace of an
 | 
						// EndpointsMeta should contain a Name and a Namespace of an
 | 
				
			||||||
	// Endpoints object that the LeaderElector will attempt to lead.
 | 
						// Endpoints object that the LeaderElector will attempt to lead.
 | 
				
			||||||
	EndpointsMeta api.ObjectMeta
 | 
						EndpointsMeta v1.ObjectMeta
 | 
				
			||||||
	Client        clientset.Interface
 | 
						Client        clientset.Interface
 | 
				
			||||||
	LockConfig    ResourceLockConfig
 | 
						LockConfig    ResourceLockConfig
 | 
				
			||||||
	e             *api.Endpoints
 | 
						e             *v1.Endpoints
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (el *EndpointsLock) Get() (*LeaderElectionRecord, error) {
 | 
					func (el *EndpointsLock) Get() (*LeaderElectionRecord, error) {
 | 
				
			||||||
@@ -58,8 +58,8 @@ func (el *EndpointsLock) Create(ler LeaderElectionRecord) error {
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	el.e, err = el.Client.Core().Endpoints(el.EndpointsMeta.Namespace).Create(&api.Endpoints{
 | 
						el.e, err = el.Client.Core().Endpoints(el.EndpointsMeta.Namespace).Create(&v1.Endpoints{
 | 
				
			||||||
		ObjectMeta: api.ObjectMeta{
 | 
							ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
			Name:      el.EndpointsMeta.Name,
 | 
								Name:      el.EndpointsMeta.Name,
 | 
				
			||||||
			Namespace: el.EndpointsMeta.Namespace,
 | 
								Namespace: el.EndpointsMeta.Namespace,
 | 
				
			||||||
			Annotations: map[string]string{
 | 
								Annotations: map[string]string{
 | 
				
			||||||
@@ -87,7 +87,7 @@ func (el *EndpointsLock) Update(ler LeaderElectionRecord) error {
 | 
				
			|||||||
// RecordEvent in leader election while adding meta-data
 | 
					// RecordEvent in leader election while adding meta-data
 | 
				
			||||||
func (el *EndpointsLock) RecordEvent(s string) {
 | 
					func (el *EndpointsLock) RecordEvent(s string) {
 | 
				
			||||||
	events := fmt.Sprintf("%v %v", el.LockConfig.Identity, s)
 | 
						events := fmt.Sprintf("%v %v", el.LockConfig.Identity, s)
 | 
				
			||||||
	el.LockConfig.EventRecorder.Eventf(&api.Endpoints{ObjectMeta: el.e.ObjectMeta}, api.EventTypeNormal, "LeaderElection", events)
 | 
						el.LockConfig.EventRecorder.Eventf(&v1.Endpoints{ObjectMeta: el.e.ObjectMeta}, v1.EventTypeNormal, "LeaderElection", events)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Describe is used to convert details on current resource lock
 | 
					// Describe is used to convert details on current resource lock
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,11 +17,3 @@ limitations under the License.
 | 
				
			|||||||
// This file was automatically generated by lister-gen with arguments: --input-dirs=[k8s.io/kubernetes/pkg/api,k8s.io/kubernetes/pkg/api/v1,k8s.io/kubernetes/pkg/apis/abac,k8s.io/kubernetes/pkg/apis/abac/v0,k8s.io/kubernetes/pkg/apis/abac/v1beta1,k8s.io/kubernetes/pkg/apis/apps,k8s.io/kubernetes/pkg/apis/apps/v1beta1,k8s.io/kubernetes/pkg/apis/authentication,k8s.io/kubernetes/pkg/apis/authentication/v1beta1,k8s.io/kubernetes/pkg/apis/authorization,k8s.io/kubernetes/pkg/apis/authorization/v1beta1,k8s.io/kubernetes/pkg/apis/autoscaling,k8s.io/kubernetes/pkg/apis/autoscaling/v1,k8s.io/kubernetes/pkg/apis/batch,k8s.io/kubernetes/pkg/apis/batch/v1,k8s.io/kubernetes/pkg/apis/batch/v2alpha1,k8s.io/kubernetes/pkg/apis/certificates,k8s.io/kubernetes/pkg/apis/certificates/v1alpha1,k8s.io/kubernetes/pkg/apis/componentconfig,k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1,k8s.io/kubernetes/pkg/apis/extensions,k8s.io/kubernetes/pkg/apis/extensions/v1beta1,k8s.io/kubernetes/pkg/apis/imagepolicy,k8s.io/kubernetes/pkg/apis/imagepolicy/v1alpha1,k8s.io/kubernetes/pkg/apis/policy,k8s.io/kubernetes/pkg/apis/policy/v1alpha1,k8s.io/kubernetes/pkg/apis/policy/v1beta1,k8s.io/kubernetes/pkg/apis/rbac,k8s.io/kubernetes/pkg/apis/rbac/v1alpha1,k8s.io/kubernetes/pkg/apis/storage,k8s.io/kubernetes/pkg/apis/storage/v1beta1]
 | 
					// This file was automatically generated by lister-gen with arguments: --input-dirs=[k8s.io/kubernetes/pkg/api,k8s.io/kubernetes/pkg/api/v1,k8s.io/kubernetes/pkg/apis/abac,k8s.io/kubernetes/pkg/apis/abac/v0,k8s.io/kubernetes/pkg/apis/abac/v1beta1,k8s.io/kubernetes/pkg/apis/apps,k8s.io/kubernetes/pkg/apis/apps/v1beta1,k8s.io/kubernetes/pkg/apis/authentication,k8s.io/kubernetes/pkg/apis/authentication/v1beta1,k8s.io/kubernetes/pkg/apis/authorization,k8s.io/kubernetes/pkg/apis/authorization/v1beta1,k8s.io/kubernetes/pkg/apis/autoscaling,k8s.io/kubernetes/pkg/apis/autoscaling/v1,k8s.io/kubernetes/pkg/apis/batch,k8s.io/kubernetes/pkg/apis/batch/v1,k8s.io/kubernetes/pkg/apis/batch/v2alpha1,k8s.io/kubernetes/pkg/apis/certificates,k8s.io/kubernetes/pkg/apis/certificates/v1alpha1,k8s.io/kubernetes/pkg/apis/componentconfig,k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1,k8s.io/kubernetes/pkg/apis/extensions,k8s.io/kubernetes/pkg/apis/extensions/v1beta1,k8s.io/kubernetes/pkg/apis/imagepolicy,k8s.io/kubernetes/pkg/apis/imagepolicy/v1alpha1,k8s.io/kubernetes/pkg/apis/policy,k8s.io/kubernetes/pkg/apis/policy/v1alpha1,k8s.io/kubernetes/pkg/apis/policy/v1beta1,k8s.io/kubernetes/pkg/apis/rbac,k8s.io/kubernetes/pkg/apis/rbac/v1alpha1,k8s.io/kubernetes/pkg/apis/storage,k8s.io/kubernetes/pkg/apis/storage/v1beta1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package v1
 | 
					package v1
 | 
				
			||||||
 | 
					 | 
				
			||||||
// JobListerExpansion allows custom methods to be added to
 | 
					 | 
				
			||||||
// JobLister.
 | 
					 | 
				
			||||||
type JobListerExpansion interface{}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// JobNamespaceListerExpansion allows custom methods to be added to
 | 
					 | 
				
			||||||
// JobNamespaeLister.
 | 
					 | 
				
			||||||
type JobNamespaceListerExpansion interface{}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										64
									
								
								pkg/client/listers/batch/v1/job_expansion.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								pkg/client/listers/batch/v1/job_expansion.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,64 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					Copyright 2016 The Kubernetes Authors.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
 | 
					you may not use this file except in compliance with the License.
 | 
				
			||||||
 | 
					You may obtain a copy of the License at
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    http://www.apache.org/licenses/LICENSE-2.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Unless required by applicable law or agreed to in writing, software
 | 
				
			||||||
 | 
					distributed under the License is distributed on an "AS IS" BASIS,
 | 
				
			||||||
 | 
					WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
				
			||||||
 | 
					See the License for the specific language governing permissions and
 | 
				
			||||||
 | 
					limitations under the License.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package v1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
 | 
						batch "k8s.io/kubernetes/pkg/apis/batch/v1"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/labels"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// JobListerExpansion allows custom methods to be added to
 | 
				
			||||||
 | 
					// JobLister.
 | 
				
			||||||
 | 
					type JobListerExpansion interface {
 | 
				
			||||||
 | 
						// GetPodJobs returns a list of jobs managing a pod. An error is returned only
 | 
				
			||||||
 | 
						// if no matching jobs are found.
 | 
				
			||||||
 | 
						GetPodJobs(pod *v1.Pod) (jobs []batch.Job, err error)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetPodJobs returns a list of jobs managing a pod. An error is returned only
 | 
				
			||||||
 | 
					// if no matching jobs are found.
 | 
				
			||||||
 | 
					func (l *jobLister) GetPodJobs(pod *v1.Pod) (jobs []batch.Job, err error) {
 | 
				
			||||||
 | 
						if len(pod.Labels) == 0 {
 | 
				
			||||||
 | 
							err = fmt.Errorf("no jobs found for pod %v because it has no labels", pod.Name)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var list []*batch.Job
 | 
				
			||||||
 | 
						list, err = l.Jobs(pod.Namespace).List(labels.Everything())
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						for _, job := range list {
 | 
				
			||||||
 | 
							selector, _ := unversioned.LabelSelectorAsSelector(job.Spec.Selector)
 | 
				
			||||||
 | 
							if !selector.Matches(labels.Set(pod.Labels)) {
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							jobs = append(jobs, *job)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if len(jobs) == 0 {
 | 
				
			||||||
 | 
							err = fmt.Errorf("could not find jobs for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// JobNamespaceListerExpansion allows custom methods to be added to
 | 
				
			||||||
 | 
					// JobNamespaceLister.
 | 
				
			||||||
 | 
					type JobNamespaceListerExpansion interface{}
 | 
				
			||||||
@@ -21,7 +21,7 @@ import (
 | 
				
			|||||||
	"math/rand"
 | 
						"math/rand"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/errors"
 | 
						"k8s.io/kubernetes/pkg/api/errors"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/client/restclient"
 | 
						"k8s.io/kubernetes/pkg/client/restclient"
 | 
				
			||||||
@@ -46,9 +46,9 @@ const maxQueuedEvents = 1000
 | 
				
			|||||||
// It is assumed that EventSink will return the same sorts of errors as
 | 
					// It is assumed that EventSink will return the same sorts of errors as
 | 
				
			||||||
// pkg/client's REST client.
 | 
					// pkg/client's REST client.
 | 
				
			||||||
type EventSink interface {
 | 
					type EventSink interface {
 | 
				
			||||||
	Create(event *api.Event) (*api.Event, error)
 | 
						Create(event *v1.Event) (*v1.Event, error)
 | 
				
			||||||
	Update(event *api.Event) (*api.Event, error)
 | 
						Update(event *v1.Event) (*v1.Event, error)
 | 
				
			||||||
	Patch(oldEvent *api.Event, data []byte) (*api.Event, error)
 | 
						Patch(oldEvent *v1.Event, data []byte) (*v1.Event, error)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// EventRecorder knows how to record events on behalf of an EventSource.
 | 
					// EventRecorder knows how to record events on behalf of an EventSource.
 | 
				
			||||||
@@ -78,7 +78,7 @@ type EventBroadcaster interface {
 | 
				
			|||||||
	// StartEventWatcher starts sending events received from this EventBroadcaster to the given
 | 
						// StartEventWatcher starts sending events received from this EventBroadcaster to the given
 | 
				
			||||||
	// event handler function. The return value can be ignored or used to stop recording, if
 | 
						// event handler function. The return value can be ignored or used to stop recording, if
 | 
				
			||||||
	// desired.
 | 
						// desired.
 | 
				
			||||||
	StartEventWatcher(eventHandler func(*api.Event)) watch.Interface
 | 
						StartEventWatcher(eventHandler func(*v1.Event)) watch.Interface
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// StartRecordingToSink starts sending events received from this EventBroadcaster to the given
 | 
						// StartRecordingToSink starts sending events received from this EventBroadcaster to the given
 | 
				
			||||||
	// sink. The return value can be ignored or used to stop recording, if desired.
 | 
						// sink. The return value can be ignored or used to stop recording, if desired.
 | 
				
			||||||
@@ -90,7 +90,7 @@ type EventBroadcaster interface {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// NewRecorder returns an EventRecorder that can be used to send events to this EventBroadcaster
 | 
						// NewRecorder returns an EventRecorder that can be used to send events to this EventBroadcaster
 | 
				
			||||||
	// with the event source set to the given event source.
 | 
						// with the event source set to the given event source.
 | 
				
			||||||
	NewRecorder(source api.EventSource) EventRecorder
 | 
						NewRecorder(source v1.EventSource) EventRecorder
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Creates a new event broadcaster.
 | 
					// Creates a new event broadcaster.
 | 
				
			||||||
@@ -116,12 +116,12 @@ func (eventBroadcaster *eventBroadcasterImpl) StartRecordingToSink(sink EventSin
 | 
				
			|||||||
	randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
 | 
						randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
 | 
				
			||||||
	eventCorrelator := NewEventCorrelator(clock.RealClock{})
 | 
						eventCorrelator := NewEventCorrelator(clock.RealClock{})
 | 
				
			||||||
	return eventBroadcaster.StartEventWatcher(
 | 
						return eventBroadcaster.StartEventWatcher(
 | 
				
			||||||
		func(event *api.Event) {
 | 
							func(event *v1.Event) {
 | 
				
			||||||
			recordToSink(sink, event, eventCorrelator, randGen, eventBroadcaster.sleepDuration)
 | 
								recordToSink(sink, event, eventCorrelator, randGen, eventBroadcaster.sleepDuration)
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func recordToSink(sink EventSink, event *api.Event, eventCorrelator *EventCorrelator, randGen *rand.Rand, sleepDuration time.Duration) {
 | 
					func recordToSink(sink EventSink, event *v1.Event, eventCorrelator *EventCorrelator, randGen *rand.Rand, sleepDuration time.Duration) {
 | 
				
			||||||
	// Make a copy before modification, because there could be multiple listeners.
 | 
						// Make a copy before modification, because there could be multiple listeners.
 | 
				
			||||||
	// Events are safe to copy like this.
 | 
						// Events are safe to copy like this.
 | 
				
			||||||
	eventCopy := *event
 | 
						eventCopy := *event
 | 
				
			||||||
@@ -167,8 +167,8 @@ func isKeyNotFoundError(err error) bool {
 | 
				
			|||||||
// was successfully recorded or discarded, false if it should be retried.
 | 
					// was successfully recorded or discarded, false if it should be retried.
 | 
				
			||||||
// If updateExistingEvent is false, it creates a new event, otherwise it updates
 | 
					// If updateExistingEvent is false, it creates a new event, otherwise it updates
 | 
				
			||||||
// existing event.
 | 
					// existing event.
 | 
				
			||||||
func recordEvent(sink EventSink, event *api.Event, patch []byte, updateExistingEvent bool, eventCorrelator *EventCorrelator) bool {
 | 
					func recordEvent(sink EventSink, event *v1.Event, patch []byte, updateExistingEvent bool, eventCorrelator *EventCorrelator) bool {
 | 
				
			||||||
	var newEvent *api.Event
 | 
						var newEvent *v1.Event
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
	if updateExistingEvent {
 | 
						if updateExistingEvent {
 | 
				
			||||||
		newEvent, err = sink.Patch(event, patch)
 | 
							newEvent, err = sink.Patch(event, patch)
 | 
				
			||||||
@@ -213,14 +213,14 @@ func recordEvent(sink EventSink, event *api.Event, patch []byte, updateExistingE
 | 
				
			|||||||
// The return value can be ignored or used to stop recording, if desired.
 | 
					// The return value can be ignored or used to stop recording, if desired.
 | 
				
			||||||
func (eventBroadcaster *eventBroadcasterImpl) StartLogging(logf func(format string, args ...interface{})) watch.Interface {
 | 
					func (eventBroadcaster *eventBroadcasterImpl) StartLogging(logf func(format string, args ...interface{})) watch.Interface {
 | 
				
			||||||
	return eventBroadcaster.StartEventWatcher(
 | 
						return eventBroadcaster.StartEventWatcher(
 | 
				
			||||||
		func(e *api.Event) {
 | 
							func(e *v1.Event) {
 | 
				
			||||||
			logf("Event(%#v): type: '%v' reason: '%v' %v", e.InvolvedObject, e.Type, e.Reason, e.Message)
 | 
								logf("Event(%#v): type: '%v' reason: '%v' %v", e.InvolvedObject, e.Type, e.Reason, e.Message)
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StartEventWatcher starts sending events received from this EventBroadcaster to the given event handler function.
 | 
					// StartEventWatcher starts sending events received from this EventBroadcaster to the given event handler function.
 | 
				
			||||||
// The return value can be ignored or used to stop recording, if desired.
 | 
					// The return value can be ignored or used to stop recording, if desired.
 | 
				
			||||||
func (eventBroadcaster *eventBroadcasterImpl) StartEventWatcher(eventHandler func(*api.Event)) watch.Interface {
 | 
					func (eventBroadcaster *eventBroadcasterImpl) StartEventWatcher(eventHandler func(*v1.Event)) watch.Interface {
 | 
				
			||||||
	watcher := eventBroadcaster.Watch()
 | 
						watcher := eventBroadcaster.Watch()
 | 
				
			||||||
	go func() {
 | 
						go func() {
 | 
				
			||||||
		defer utilruntime.HandleCrash()
 | 
							defer utilruntime.HandleCrash()
 | 
				
			||||||
@@ -229,7 +229,7 @@ func (eventBroadcaster *eventBroadcasterImpl) StartEventWatcher(eventHandler fun
 | 
				
			|||||||
			if !open {
 | 
								if !open {
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			event, ok := watchEvent.Object.(*api.Event)
 | 
								event, ok := watchEvent.Object.(*v1.Event)
 | 
				
			||||||
			if !ok {
 | 
								if !ok {
 | 
				
			||||||
				// This is all local, so there's no reason this should
 | 
									// This is all local, so there's no reason this should
 | 
				
			||||||
				// ever happen.
 | 
									// ever happen.
 | 
				
			||||||
@@ -242,18 +242,18 @@ func (eventBroadcaster *eventBroadcasterImpl) StartEventWatcher(eventHandler fun
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewRecorder returns an EventRecorder that records events with the given event source.
 | 
					// NewRecorder returns an EventRecorder that records events with the given event source.
 | 
				
			||||||
func (eventBroadcaster *eventBroadcasterImpl) NewRecorder(source api.EventSource) EventRecorder {
 | 
					func (eventBroadcaster *eventBroadcasterImpl) NewRecorder(source v1.EventSource) EventRecorder {
 | 
				
			||||||
	return &recorderImpl{source, eventBroadcaster.Broadcaster, clock.RealClock{}}
 | 
						return &recorderImpl{source, eventBroadcaster.Broadcaster, clock.RealClock{}}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type recorderImpl struct {
 | 
					type recorderImpl struct {
 | 
				
			||||||
	source api.EventSource
 | 
						source v1.EventSource
 | 
				
			||||||
	*watch.Broadcaster
 | 
						*watch.Broadcaster
 | 
				
			||||||
	clock clock.Clock
 | 
						clock clock.Clock
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (recorder *recorderImpl) generateEvent(object runtime.Object, timestamp unversioned.Time, eventtype, reason, message string) {
 | 
					func (recorder *recorderImpl) generateEvent(object runtime.Object, timestamp unversioned.Time, eventtype, reason, message string) {
 | 
				
			||||||
	ref, err := api.GetReference(object)
 | 
						ref, err := v1.GetReference(object)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		glog.Errorf("Could not construct reference to: '%#v' due to: '%v'. Will not report event: '%v' '%v' '%v'", object, err, eventtype, reason, message)
 | 
							glog.Errorf("Could not construct reference to: '%#v' due to: '%v'. Will not report event: '%v' '%v' '%v'", object, err, eventtype, reason, message)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
@@ -276,7 +276,7 @@ func (recorder *recorderImpl) generateEvent(object runtime.Object, timestamp unv
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func validateEventType(eventtype string) bool {
 | 
					func validateEventType(eventtype string) bool {
 | 
				
			||||||
	switch eventtype {
 | 
						switch eventtype {
 | 
				
			||||||
	case api.EventTypeNormal, api.EventTypeWarning:
 | 
						case v1.EventTypeNormal, v1.EventTypeWarning:
 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return false
 | 
						return false
 | 
				
			||||||
@@ -294,14 +294,14 @@ func (recorder *recorderImpl) PastEventf(object runtime.Object, timestamp unvers
 | 
				
			|||||||
	recorder.generateEvent(object, timestamp, eventtype, reason, fmt.Sprintf(messageFmt, args...))
 | 
						recorder.generateEvent(object, timestamp, eventtype, reason, fmt.Sprintf(messageFmt, args...))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (recorder *recorderImpl) makeEvent(ref *api.ObjectReference, eventtype, reason, message string) *api.Event {
 | 
					func (recorder *recorderImpl) makeEvent(ref *v1.ObjectReference, eventtype, reason, message string) *v1.Event {
 | 
				
			||||||
	t := unversioned.Time{Time: recorder.clock.Now()}
 | 
						t := unversioned.Time{Time: recorder.clock.Now()}
 | 
				
			||||||
	namespace := ref.Namespace
 | 
						namespace := ref.Namespace
 | 
				
			||||||
	if namespace == "" {
 | 
						if namespace == "" {
 | 
				
			||||||
		namespace = api.NamespaceDefault
 | 
							namespace = v1.NamespaceDefault
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return &api.Event{
 | 
						return &v1.Event{
 | 
				
			||||||
		ObjectMeta: api.ObjectMeta{
 | 
							ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
			Name:      fmt.Sprintf("%v.%x", ref.Name, t.UnixNano()),
 | 
								Name:      fmt.Sprintf("%v.%x", ref.Name, t.UnixNano()),
 | 
				
			||||||
			Namespace: namespace,
 | 
								Namespace: namespace,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,7 +25,7 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/errors"
 | 
						"k8s.io/kubernetes/pkg/api/errors"
 | 
				
			||||||
	_ "k8s.io/kubernetes/pkg/api/install" // To register api.Pod used in tests below
 | 
						_ "k8s.io/kubernetes/pkg/api/install" // To register api.Pod used in tests below
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
@@ -36,13 +36,13 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type testEventSink struct {
 | 
					type testEventSink struct {
 | 
				
			||||||
	OnCreate func(e *api.Event) (*api.Event, error)
 | 
						OnCreate func(e *v1.Event) (*v1.Event, error)
 | 
				
			||||||
	OnUpdate func(e *api.Event) (*api.Event, error)
 | 
						OnUpdate func(e *v1.Event) (*v1.Event, error)
 | 
				
			||||||
	OnPatch  func(e *api.Event, p []byte) (*api.Event, error)
 | 
						OnPatch  func(e *v1.Event, p []byte) (*v1.Event, error)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CreateEvent records the event for testing.
 | 
					// CreateEvent records the event for testing.
 | 
				
			||||||
func (t *testEventSink) Create(e *api.Event) (*api.Event, error) {
 | 
					func (t *testEventSink) Create(e *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
	if t.OnCreate != nil {
 | 
						if t.OnCreate != nil {
 | 
				
			||||||
		return t.OnCreate(e)
 | 
							return t.OnCreate(e)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -50,7 +50,7 @@ func (t *testEventSink) Create(e *api.Event) (*api.Event, error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateEvent records the event for testing.
 | 
					// UpdateEvent records the event for testing.
 | 
				
			||||||
func (t *testEventSink) Update(e *api.Event) (*api.Event, error) {
 | 
					func (t *testEventSink) Update(e *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
	if t.OnUpdate != nil {
 | 
						if t.OnUpdate != nil {
 | 
				
			||||||
		return t.OnUpdate(e)
 | 
							return t.OnUpdate(e)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -58,27 +58,27 @@ func (t *testEventSink) Update(e *api.Event) (*api.Event, error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// PatchEvent records the event for testing.
 | 
					// PatchEvent records the event for testing.
 | 
				
			||||||
func (t *testEventSink) Patch(e *api.Event, p []byte) (*api.Event, error) {
 | 
					func (t *testEventSink) Patch(e *v1.Event, p []byte) (*v1.Event, error) {
 | 
				
			||||||
	if t.OnPatch != nil {
 | 
						if t.OnPatch != nil {
 | 
				
			||||||
		return t.OnPatch(e, p)
 | 
							return t.OnPatch(e, p)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return e, nil
 | 
						return e, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type OnCreateFunc func(*api.Event) (*api.Event, error)
 | 
					type OnCreateFunc func(*v1.Event) (*v1.Event, error)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func OnCreateFactory(testCache map[string]*api.Event, createEvent chan<- *api.Event) OnCreateFunc {
 | 
					func OnCreateFactory(testCache map[string]*v1.Event, createEvent chan<- *v1.Event) OnCreateFunc {
 | 
				
			||||||
	return func(event *api.Event) (*api.Event, error) {
 | 
						return func(event *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
		testCache[getEventKey(event)] = event
 | 
							testCache[getEventKey(event)] = event
 | 
				
			||||||
		createEvent <- event
 | 
							createEvent <- event
 | 
				
			||||||
		return event, nil
 | 
							return event, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type OnPatchFunc func(*api.Event, []byte) (*api.Event, error)
 | 
					type OnPatchFunc func(*v1.Event, []byte) (*v1.Event, error)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func OnPatchFactory(testCache map[string]*api.Event, patchEvent chan<- *api.Event) OnPatchFunc {
 | 
					func OnPatchFactory(testCache map[string]*v1.Event, patchEvent chan<- *v1.Event) OnPatchFunc {
 | 
				
			||||||
	return func(event *api.Event, patch []byte) (*api.Event, error) {
 | 
						return func(event *v1.Event, patch []byte) (*v1.Event, error) {
 | 
				
			||||||
		cachedEvent, found := testCache[getEventKey(event)]
 | 
							cachedEvent, found := testCache[getEventKey(event)]
 | 
				
			||||||
		if !found {
 | 
							if !found {
 | 
				
			||||||
			return nil, fmt.Errorf("unexpected error: couldn't find Event in testCache.")
 | 
								return nil, fmt.Errorf("unexpected error: couldn't find Event in testCache.")
 | 
				
			||||||
@@ -91,7 +91,7 @@ func OnPatchFactory(testCache map[string]*api.Event, patchEvent chan<- *api.Even
 | 
				
			|||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, fmt.Errorf("unexpected error: %v", err)
 | 
								return nil, fmt.Errorf("unexpected error: %v", err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		patchedObj := &api.Event{}
 | 
							patchedObj := &v1.Event{}
 | 
				
			||||||
		err = json.Unmarshal(patched, patchedObj)
 | 
							err = json.Unmarshal(patched, patchedObj)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, fmt.Errorf("unexpected error: %v", err)
 | 
								return nil, fmt.Errorf("unexpected error: %v", err)
 | 
				
			||||||
@@ -102,24 +102,24 @@ func OnPatchFactory(testCache map[string]*api.Event, patchEvent chan<- *api.Even
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestEventf(t *testing.T) {
 | 
					func TestEventf(t *testing.T) {
 | 
				
			||||||
	testPod := &api.Pod{
 | 
						testPod := &v1.Pod{
 | 
				
			||||||
		ObjectMeta: api.ObjectMeta{
 | 
							ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
			SelfLink:  "/api/version/pods/foo",
 | 
								SelfLink:  "/api/version/pods/foo",
 | 
				
			||||||
			Name:      "foo",
 | 
								Name:      "foo",
 | 
				
			||||||
			Namespace: "baz",
 | 
								Namespace: "baz",
 | 
				
			||||||
			UID:       "bar",
 | 
								UID:       "bar",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	testPod2 := &api.Pod{
 | 
						testPod2 := &v1.Pod{
 | 
				
			||||||
		ObjectMeta: api.ObjectMeta{
 | 
							ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
			SelfLink:  "/api/version/pods/foo",
 | 
								SelfLink:  "/api/version/pods/foo",
 | 
				
			||||||
			Name:      "foo",
 | 
								Name:      "foo",
 | 
				
			||||||
			Namespace: "baz",
 | 
								Namespace: "baz",
 | 
				
			||||||
			UID:       "differentUid",
 | 
								UID:       "differentUid",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	testRef, err := api.GetPartialReference(testPod, "spec.containers[2]")
 | 
						testRef, err := v1.GetPartialReference(testPod, "spec.containers[2]")
 | 
				
			||||||
	testRef2, err := api.GetPartialReference(testPod2, "spec.containers[3]")
 | 
						testRef2, err := v1.GetPartialReference(testPod2, "spec.containers[3]")
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Fatal(err)
 | 
							t.Fatal(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -129,22 +129,22 @@ func TestEventf(t *testing.T) {
 | 
				
			|||||||
		reason       string
 | 
							reason       string
 | 
				
			||||||
		messageFmt   string
 | 
							messageFmt   string
 | 
				
			||||||
		elements     []interface{}
 | 
							elements     []interface{}
 | 
				
			||||||
		expect       *api.Event
 | 
							expect       *v1.Event
 | 
				
			||||||
		expectLog    string
 | 
							expectLog    string
 | 
				
			||||||
		expectUpdate bool
 | 
							expectUpdate bool
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef,
 | 
								obj:        testRef,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Started",
 | 
								reason:     "Started",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -154,25 +154,25 @@ func TestEventf(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Started",
 | 
									Reason:  "Started",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   1,
 | 
									Count:   1,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: false,
 | 
								expectUpdate: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testPod,
 | 
								obj:        testPod,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Killed",
 | 
								reason:     "Killed",
 | 
				
			||||||
			messageFmt: "some other verbose message: %v",
 | 
								messageFmt: "some other verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -181,25 +181,25 @@ func TestEventf(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Killed",
 | 
									Reason:  "Killed",
 | 
				
			||||||
				Message: "some other verbose message: 1",
 | 
									Message: "some other verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   1,
 | 
									Count:   1,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`,
 | 
				
			||||||
			expectUpdate: false,
 | 
								expectUpdate: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef,
 | 
								obj:        testRef,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Started",
 | 
								reason:     "Started",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -209,25 +209,25 @@ func TestEventf(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Started",
 | 
									Reason:  "Started",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   2,
 | 
									Count:   2,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: true,
 | 
								expectUpdate: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef2,
 | 
								obj:        testRef2,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Started",
 | 
								reason:     "Started",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -237,25 +237,25 @@ func TestEventf(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Started",
 | 
									Reason:  "Started",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   1,
 | 
									Count:   1,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: false,
 | 
								expectUpdate: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef,
 | 
								obj:        testRef,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Started",
 | 
								reason:     "Started",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -265,25 +265,25 @@ func TestEventf(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Started",
 | 
									Reason:  "Started",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   3,
 | 
									Count:   3,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: true,
 | 
								expectUpdate: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef2,
 | 
								obj:        testRef2,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Stopped",
 | 
								reason:     "Stopped",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -293,25 +293,25 @@ func TestEventf(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Stopped",
 | 
									Reason:  "Stopped",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   1,
 | 
									Count:   1,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: false,
 | 
								expectUpdate: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef2,
 | 
								obj:        testRef2,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Stopped",
 | 
								reason:     "Stopped",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -321,23 +321,23 @@ func TestEventf(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Stopped",
 | 
									Reason:  "Stopped",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   2,
 | 
									Count:   2,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: true,
 | 
								expectUpdate: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	testCache := map[string]*api.Event{}
 | 
						testCache := map[string]*v1.Event{}
 | 
				
			||||||
	logCalled := make(chan struct{})
 | 
						logCalled := make(chan struct{})
 | 
				
			||||||
	createEvent := make(chan *api.Event)
 | 
						createEvent := make(chan *v1.Event)
 | 
				
			||||||
	updateEvent := make(chan *api.Event)
 | 
						updateEvent := make(chan *v1.Event)
 | 
				
			||||||
	patchEvent := make(chan *api.Event)
 | 
						patchEvent := make(chan *v1.Event)
 | 
				
			||||||
	testEvents := testEventSink{
 | 
						testEvents := testEventSink{
 | 
				
			||||||
		OnCreate: OnCreateFactory(testCache, createEvent),
 | 
							OnCreate: OnCreateFactory(testCache, createEvent),
 | 
				
			||||||
		OnUpdate: func(event *api.Event) (*api.Event, error) {
 | 
							OnUpdate: func(event *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
			updateEvent <- event
 | 
								updateEvent <- event
 | 
				
			||||||
			return event, nil
 | 
								return event, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -347,7 +347,7 @@ func TestEventf(t *testing.T) {
 | 
				
			|||||||
	sinkWatcher := eventBroadcaster.StartRecordingToSink(&testEvents)
 | 
						sinkWatcher := eventBroadcaster.StartRecordingToSink(&testEvents)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	clock := clock.NewFakeClock(time.Now())
 | 
						clock := clock.NewFakeClock(time.Now())
 | 
				
			||||||
	recorder := recorderWithFakeClock(api.EventSource{Component: "eventTest"}, eventBroadcaster, clock)
 | 
						recorder := recorderWithFakeClock(v1.EventSource{Component: "eventTest"}, eventBroadcaster, clock)
 | 
				
			||||||
	for index, item := range table {
 | 
						for index, item := range table {
 | 
				
			||||||
		clock.Step(1 * time.Second)
 | 
							clock.Step(1 * time.Second)
 | 
				
			||||||
		logWatcher := eventBroadcaster.StartLogging(func(formatter string, args ...interface{}) {
 | 
							logWatcher := eventBroadcaster.StartLogging(func(formatter string, args ...interface{}) {
 | 
				
			||||||
@@ -373,7 +373,7 @@ func TestEventf(t *testing.T) {
 | 
				
			|||||||
	sinkWatcher.Stop()
 | 
						sinkWatcher.Stop()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func recorderWithFakeClock(eventSource api.EventSource, eventBroadcaster EventBroadcaster, clock clock.Clock) EventRecorder {
 | 
					func recorderWithFakeClock(eventSource v1.EventSource, eventBroadcaster EventBroadcaster, clock clock.Clock) EventRecorder {
 | 
				
			||||||
	return &recorderImpl{eventSource, eventBroadcaster.(*eventBroadcasterImpl).Broadcaster, clock}
 | 
						return &recorderImpl{eventSource, eventBroadcaster.(*eventBroadcasterImpl).Broadcaster, clock}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -417,7 +417,7 @@ func TestWriteEventError(t *testing.T) {
 | 
				
			|||||||
	for caseName, ent := range table {
 | 
						for caseName, ent := range table {
 | 
				
			||||||
		attempts := 0
 | 
							attempts := 0
 | 
				
			||||||
		sink := &testEventSink{
 | 
							sink := &testEventSink{
 | 
				
			||||||
			OnCreate: func(event *api.Event) (*api.Event, error) {
 | 
								OnCreate: func(event *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
				attempts++
 | 
									attempts++
 | 
				
			||||||
				if attempts < ent.timesToSendError {
 | 
									if attempts < ent.timesToSendError {
 | 
				
			||||||
					return nil, ent.err
 | 
										return nil, ent.err
 | 
				
			||||||
@@ -425,7 +425,7 @@ func TestWriteEventError(t *testing.T) {
 | 
				
			|||||||
				return event, nil
 | 
									return event, nil
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		ev := &api.Event{}
 | 
							ev := &v1.Event{}
 | 
				
			||||||
		recordToSink(sink, ev, eventCorrelator, randGen, 0)
 | 
							recordToSink(sink, ev, eventCorrelator, randGen, 0)
 | 
				
			||||||
		if attempts != ent.attemptsWanted {
 | 
							if attempts != ent.attemptsWanted {
 | 
				
			||||||
			t.Errorf("case %v: wanted %d, got %d attempts", caseName, ent.attemptsWanted, attempts)
 | 
								t.Errorf("case %v: wanted %d, got %d attempts", caseName, ent.attemptsWanted, attempts)
 | 
				
			||||||
@@ -437,23 +437,23 @@ func TestUpdateExpiredEvent(t *testing.T) {
 | 
				
			|||||||
	eventCorrelator := NewEventCorrelator(clock.RealClock{})
 | 
						eventCorrelator := NewEventCorrelator(clock.RealClock{})
 | 
				
			||||||
	randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
 | 
						randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var createdEvent *api.Event
 | 
						var createdEvent *v1.Event
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sink := &testEventSink{
 | 
						sink := &testEventSink{
 | 
				
			||||||
		OnPatch: func(*api.Event, []byte) (*api.Event, error) {
 | 
							OnPatch: func(*v1.Event, []byte) (*v1.Event, error) {
 | 
				
			||||||
			return nil, &errors.StatusError{
 | 
								return nil, &errors.StatusError{
 | 
				
			||||||
				ErrStatus: unversioned.Status{
 | 
									ErrStatus: unversioned.Status{
 | 
				
			||||||
					Code:   http.StatusNotFound,
 | 
										Code:   http.StatusNotFound,
 | 
				
			||||||
					Reason: unversioned.StatusReasonNotFound,
 | 
										Reason: unversioned.StatusReasonNotFound,
 | 
				
			||||||
				}}
 | 
									}}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		OnCreate: func(event *api.Event) (*api.Event, error) {
 | 
							OnCreate: func(event *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
			createdEvent = event
 | 
								createdEvent = event
 | 
				
			||||||
			return event, nil
 | 
								return event, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ev := &api.Event{}
 | 
						ev := &v1.Event{}
 | 
				
			||||||
	ev.ResourceVersion = "updated-resource-version"
 | 
						ev.ResourceVersion = "updated-resource-version"
 | 
				
			||||||
	ev.Count = 2
 | 
						ev.Count = 2
 | 
				
			||||||
	recordToSink(sink, ev, eventCorrelator, randGen, 0)
 | 
						recordToSink(sink, ev, eventCorrelator, randGen, 0)
 | 
				
			||||||
@@ -475,7 +475,7 @@ func TestLotsOfEvents(t *testing.T) {
 | 
				
			|||||||
	// Fail each event a few times to ensure there's some load on the tested code.
 | 
						// Fail each event a few times to ensure there's some load on the tested code.
 | 
				
			||||||
	var counts [1000]int
 | 
						var counts [1000]int
 | 
				
			||||||
	testEvents := testEventSink{
 | 
						testEvents := testEventSink{
 | 
				
			||||||
		OnCreate: func(event *api.Event) (*api.Event, error) {
 | 
							OnCreate: func(event *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
			num, err := strconv.Atoi(event.Message)
 | 
								num, err := strconv.Atoi(event.Message)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				t.Error(err)
 | 
									t.Error(err)
 | 
				
			||||||
@@ -495,8 +495,8 @@ func TestLotsOfEvents(t *testing.T) {
 | 
				
			|||||||
	logWatcher := eventBroadcaster.StartLogging(func(formatter string, args ...interface{}) {
 | 
						logWatcher := eventBroadcaster.StartLogging(func(formatter string, args ...interface{}) {
 | 
				
			||||||
		loggerCalled <- struct{}{}
 | 
							loggerCalled <- struct{}{}
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	recorder := eventBroadcaster.NewRecorder(api.EventSource{Component: "eventTest"})
 | 
						recorder := eventBroadcaster.NewRecorder(v1.EventSource{Component: "eventTest"})
 | 
				
			||||||
	ref := &api.ObjectReference{
 | 
						ref := &v1.ObjectReference{
 | 
				
			||||||
		Kind:       "Pod",
 | 
							Kind:       "Pod",
 | 
				
			||||||
		Name:       "foo",
 | 
							Name:       "foo",
 | 
				
			||||||
		Namespace:  "baz",
 | 
							Namespace:  "baz",
 | 
				
			||||||
@@ -505,7 +505,7 @@ func TestLotsOfEvents(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	for i := 0; i < maxQueuedEvents; i++ {
 | 
						for i := 0; i < maxQueuedEvents; i++ {
 | 
				
			||||||
		// we need to vary the reason to prevent aggregation
 | 
							// we need to vary the reason to prevent aggregation
 | 
				
			||||||
		go recorder.Eventf(ref, api.EventTypeNormal, "Reason-"+string(i), strconv.Itoa(i))
 | 
							go recorder.Eventf(ref, v1.EventTypeNormal, "Reason-"+string(i), strconv.Itoa(i))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Make sure no events were dropped by either of the listeners.
 | 
						// Make sure no events were dropped by either of the listeners.
 | 
				
			||||||
	for i := 0; i < maxQueuedEvents; i++ {
 | 
						for i := 0; i < maxQueuedEvents; i++ {
 | 
				
			||||||
@@ -523,14 +523,14 @@ func TestLotsOfEvents(t *testing.T) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestEventfNoNamespace(t *testing.T) {
 | 
					func TestEventfNoNamespace(t *testing.T) {
 | 
				
			||||||
	testPod := &api.Pod{
 | 
						testPod := &v1.Pod{
 | 
				
			||||||
		ObjectMeta: api.ObjectMeta{
 | 
							ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
			SelfLink: "/api/version/pods/foo",
 | 
								SelfLink: "/api/version/pods/foo",
 | 
				
			||||||
			Name:     "foo",
 | 
								Name:     "foo",
 | 
				
			||||||
			UID:      "bar",
 | 
								UID:      "bar",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	testRef, err := api.GetPartialReference(testPod, "spec.containers[2]")
 | 
						testRef, err := v1.GetPartialReference(testPod, "spec.containers[2]")
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Fatal(err)
 | 
							t.Fatal(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -540,22 +540,22 @@ func TestEventfNoNamespace(t *testing.T) {
 | 
				
			|||||||
		reason       string
 | 
							reason       string
 | 
				
			||||||
		messageFmt   string
 | 
							messageFmt   string
 | 
				
			||||||
		elements     []interface{}
 | 
							elements     []interface{}
 | 
				
			||||||
		expect       *api.Event
 | 
							expect       *v1.Event
 | 
				
			||||||
		expectLog    string
 | 
							expectLog    string
 | 
				
			||||||
		expectUpdate bool
 | 
							expectUpdate bool
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef,
 | 
								obj:        testRef,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Started",
 | 
								reason:     "Started",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "default",
 | 
										Namespace: "default",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "",
 | 
										Namespace:  "",
 | 
				
			||||||
@@ -565,23 +565,23 @@ func TestEventfNoNamespace(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Started",
 | 
									Reason:  "Started",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   1,
 | 
									Count:   1,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: false,
 | 
								expectUpdate: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	testCache := map[string]*api.Event{}
 | 
						testCache := map[string]*v1.Event{}
 | 
				
			||||||
	logCalled := make(chan struct{})
 | 
						logCalled := make(chan struct{})
 | 
				
			||||||
	createEvent := make(chan *api.Event)
 | 
						createEvent := make(chan *v1.Event)
 | 
				
			||||||
	updateEvent := make(chan *api.Event)
 | 
						updateEvent := make(chan *v1.Event)
 | 
				
			||||||
	patchEvent := make(chan *api.Event)
 | 
						patchEvent := make(chan *v1.Event)
 | 
				
			||||||
	testEvents := testEventSink{
 | 
						testEvents := testEventSink{
 | 
				
			||||||
		OnCreate: OnCreateFactory(testCache, createEvent),
 | 
							OnCreate: OnCreateFactory(testCache, createEvent),
 | 
				
			||||||
		OnUpdate: func(event *api.Event) (*api.Event, error) {
 | 
							OnUpdate: func(event *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
			updateEvent <- event
 | 
								updateEvent <- event
 | 
				
			||||||
			return event, nil
 | 
								return event, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -591,7 +591,7 @@ func TestEventfNoNamespace(t *testing.T) {
 | 
				
			|||||||
	sinkWatcher := eventBroadcaster.StartRecordingToSink(&testEvents)
 | 
						sinkWatcher := eventBroadcaster.StartRecordingToSink(&testEvents)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	clock := clock.NewFakeClock(time.Now())
 | 
						clock := clock.NewFakeClock(time.Now())
 | 
				
			||||||
	recorder := recorderWithFakeClock(api.EventSource{Component: "eventTest"}, eventBroadcaster, clock)
 | 
						recorder := recorderWithFakeClock(v1.EventSource{Component: "eventTest"}, eventBroadcaster, clock)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for index, item := range table {
 | 
						for index, item := range table {
 | 
				
			||||||
		clock.Step(1 * time.Second)
 | 
							clock.Step(1 * time.Second)
 | 
				
			||||||
@@ -620,24 +620,24 @@ func TestEventfNoNamespace(t *testing.T) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestMultiSinkCache(t *testing.T) {
 | 
					func TestMultiSinkCache(t *testing.T) {
 | 
				
			||||||
	testPod := &api.Pod{
 | 
						testPod := &v1.Pod{
 | 
				
			||||||
		ObjectMeta: api.ObjectMeta{
 | 
							ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
			SelfLink:  "/api/version/pods/foo",
 | 
								SelfLink:  "/api/version/pods/foo",
 | 
				
			||||||
			Name:      "foo",
 | 
								Name:      "foo",
 | 
				
			||||||
			Namespace: "baz",
 | 
								Namespace: "baz",
 | 
				
			||||||
			UID:       "bar",
 | 
								UID:       "bar",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	testPod2 := &api.Pod{
 | 
						testPod2 := &v1.Pod{
 | 
				
			||||||
		ObjectMeta: api.ObjectMeta{
 | 
							ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
			SelfLink:  "/api/version/pods/foo",
 | 
								SelfLink:  "/api/version/pods/foo",
 | 
				
			||||||
			Name:      "foo",
 | 
								Name:      "foo",
 | 
				
			||||||
			Namespace: "baz",
 | 
								Namespace: "baz",
 | 
				
			||||||
			UID:       "differentUid",
 | 
								UID:       "differentUid",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	testRef, err := api.GetPartialReference(testPod, "spec.containers[2]")
 | 
						testRef, err := v1.GetPartialReference(testPod, "spec.containers[2]")
 | 
				
			||||||
	testRef2, err := api.GetPartialReference(testPod2, "spec.containers[3]")
 | 
						testRef2, err := v1.GetPartialReference(testPod2, "spec.containers[3]")
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Fatal(err)
 | 
							t.Fatal(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -647,22 +647,22 @@ func TestMultiSinkCache(t *testing.T) {
 | 
				
			|||||||
		reason       string
 | 
							reason       string
 | 
				
			||||||
		messageFmt   string
 | 
							messageFmt   string
 | 
				
			||||||
		elements     []interface{}
 | 
							elements     []interface{}
 | 
				
			||||||
		expect       *api.Event
 | 
							expect       *v1.Event
 | 
				
			||||||
		expectLog    string
 | 
							expectLog    string
 | 
				
			||||||
		expectUpdate bool
 | 
							expectUpdate bool
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef,
 | 
								obj:        testRef,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Started",
 | 
								reason:     "Started",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -672,25 +672,25 @@ func TestMultiSinkCache(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Started",
 | 
									Reason:  "Started",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   1,
 | 
									Count:   1,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: false,
 | 
								expectUpdate: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testPod,
 | 
								obj:        testPod,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Killed",
 | 
								reason:     "Killed",
 | 
				
			||||||
			messageFmt: "some other verbose message: %v",
 | 
								messageFmt: "some other verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -699,25 +699,25 @@ func TestMultiSinkCache(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Killed",
 | 
									Reason:  "Killed",
 | 
				
			||||||
				Message: "some other verbose message: 1",
 | 
									Message: "some other verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   1,
 | 
									Count:   1,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`,
 | 
				
			||||||
			expectUpdate: false,
 | 
								expectUpdate: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef,
 | 
								obj:        testRef,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Started",
 | 
								reason:     "Started",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -727,25 +727,25 @@ func TestMultiSinkCache(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Started",
 | 
									Reason:  "Started",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   2,
 | 
									Count:   2,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: true,
 | 
								expectUpdate: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef2,
 | 
								obj:        testRef2,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Started",
 | 
								reason:     "Started",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -755,25 +755,25 @@ func TestMultiSinkCache(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Started",
 | 
									Reason:  "Started",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   1,
 | 
									Count:   1,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: false,
 | 
								expectUpdate: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef,
 | 
								obj:        testRef,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Started",
 | 
								reason:     "Started",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -783,25 +783,25 @@ func TestMultiSinkCache(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Started",
 | 
									Reason:  "Started",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   3,
 | 
									Count:   3,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: true,
 | 
								expectUpdate: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef2,
 | 
								obj:        testRef2,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Stopped",
 | 
								reason:     "Stopped",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -811,25 +811,25 @@ func TestMultiSinkCache(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Stopped",
 | 
									Reason:  "Stopped",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   1,
 | 
									Count:   1,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: false,
 | 
								expectUpdate: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			obj:        testRef2,
 | 
								obj:        testRef2,
 | 
				
			||||||
			eventtype:  api.EventTypeNormal,
 | 
								eventtype:  v1.EventTypeNormal,
 | 
				
			||||||
			reason:     "Stopped",
 | 
								reason:     "Stopped",
 | 
				
			||||||
			messageFmt: "some verbose message: %v",
 | 
								messageFmt: "some verbose message: %v",
 | 
				
			||||||
			elements:   []interface{}{1},
 | 
								elements:   []interface{}{1},
 | 
				
			||||||
			expect: &api.Event{
 | 
								expect: &v1.Event{
 | 
				
			||||||
				ObjectMeta: api.ObjectMeta{
 | 
									ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
					Name:      "foo",
 | 
										Name:      "foo",
 | 
				
			||||||
					Namespace: "baz",
 | 
										Namespace: "baz",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				InvolvedObject: api.ObjectReference{
 | 
									InvolvedObject: v1.ObjectReference{
 | 
				
			||||||
					Kind:       "Pod",
 | 
										Kind:       "Pod",
 | 
				
			||||||
					Name:       "foo",
 | 
										Name:       "foo",
 | 
				
			||||||
					Namespace:  "baz",
 | 
										Namespace:  "baz",
 | 
				
			||||||
@@ -839,35 +839,35 @@ func TestMultiSinkCache(t *testing.T) {
 | 
				
			|||||||
				},
 | 
									},
 | 
				
			||||||
				Reason:  "Stopped",
 | 
									Reason:  "Stopped",
 | 
				
			||||||
				Message: "some verbose message: 1",
 | 
									Message: "some verbose message: 1",
 | 
				
			||||||
				Source:  api.EventSource{Component: "eventTest"},
 | 
									Source:  v1.EventSource{Component: "eventTest"},
 | 
				
			||||||
				Count:   2,
 | 
									Count:   2,
 | 
				
			||||||
				Type:    api.EventTypeNormal,
 | 
									Type:    v1.EventTypeNormal,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectLog:    `Event(api.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
 | 
								expectLog:    `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
 | 
				
			||||||
			expectUpdate: true,
 | 
								expectUpdate: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	testCache := map[string]*api.Event{}
 | 
						testCache := map[string]*v1.Event{}
 | 
				
			||||||
	createEvent := make(chan *api.Event)
 | 
						createEvent := make(chan *v1.Event)
 | 
				
			||||||
	updateEvent := make(chan *api.Event)
 | 
						updateEvent := make(chan *v1.Event)
 | 
				
			||||||
	patchEvent := make(chan *api.Event)
 | 
						patchEvent := make(chan *v1.Event)
 | 
				
			||||||
	testEvents := testEventSink{
 | 
						testEvents := testEventSink{
 | 
				
			||||||
		OnCreate: OnCreateFactory(testCache, createEvent),
 | 
							OnCreate: OnCreateFactory(testCache, createEvent),
 | 
				
			||||||
		OnUpdate: func(event *api.Event) (*api.Event, error) {
 | 
							OnUpdate: func(event *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
			updateEvent <- event
 | 
								updateEvent <- event
 | 
				
			||||||
			return event, nil
 | 
								return event, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		OnPatch: OnPatchFactory(testCache, patchEvent),
 | 
							OnPatch: OnPatchFactory(testCache, patchEvent),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	testCache2 := map[string]*api.Event{}
 | 
						testCache2 := map[string]*v1.Event{}
 | 
				
			||||||
	createEvent2 := make(chan *api.Event)
 | 
						createEvent2 := make(chan *v1.Event)
 | 
				
			||||||
	updateEvent2 := make(chan *api.Event)
 | 
						updateEvent2 := make(chan *v1.Event)
 | 
				
			||||||
	patchEvent2 := make(chan *api.Event)
 | 
						patchEvent2 := make(chan *v1.Event)
 | 
				
			||||||
	testEvents2 := testEventSink{
 | 
						testEvents2 := testEventSink{
 | 
				
			||||||
		OnCreate: OnCreateFactory(testCache2, createEvent2),
 | 
							OnCreate: OnCreateFactory(testCache2, createEvent2),
 | 
				
			||||||
		OnUpdate: func(event *api.Event) (*api.Event, error) {
 | 
							OnUpdate: func(event *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
			updateEvent2 <- event
 | 
								updateEvent2 <- event
 | 
				
			||||||
			return event, nil
 | 
								return event, nil
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -876,7 +876,7 @@ func TestMultiSinkCache(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	eventBroadcaster := NewBroadcasterForTests(0)
 | 
						eventBroadcaster := NewBroadcasterForTests(0)
 | 
				
			||||||
	clock := clock.NewFakeClock(time.Now())
 | 
						clock := clock.NewFakeClock(time.Now())
 | 
				
			||||||
	recorder := recorderWithFakeClock(api.EventSource{Component: "eventTest"}, eventBroadcaster, clock)
 | 
						recorder := recorderWithFakeClock(v1.EventSource{Component: "eventTest"}, eventBroadcaster, clock)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sinkWatcher := eventBroadcaster.StartRecordingToSink(&testEvents)
 | 
						sinkWatcher := eventBroadcaster.StartRecordingToSink(&testEvents)
 | 
				
			||||||
	for index, item := range table {
 | 
						for index, item := range table {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,7 +25,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"github.com/golang/groupcache/lru"
 | 
						"github.com/golang/groupcache/lru"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/clock"
 | 
						"k8s.io/kubernetes/pkg/util/clock"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/sets"
 | 
						"k8s.io/kubernetes/pkg/util/sets"
 | 
				
			||||||
@@ -42,7 +42,7 @@ const (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// getEventKey builds unique event key based on source, involvedObject, reason, message
 | 
					// getEventKey builds unique event key based on source, involvedObject, reason, message
 | 
				
			||||||
func getEventKey(event *api.Event) string {
 | 
					func getEventKey(event *v1.Event) string {
 | 
				
			||||||
	return strings.Join([]string{
 | 
						return strings.Join([]string{
 | 
				
			||||||
		event.Source.Component,
 | 
							event.Source.Component,
 | 
				
			||||||
		event.Source.Host,
 | 
							event.Source.Host,
 | 
				
			||||||
@@ -59,10 +59,10 @@ func getEventKey(event *api.Event) string {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// EventFilterFunc is a function that returns true if the event should be skipped
 | 
					// EventFilterFunc is a function that returns true if the event should be skipped
 | 
				
			||||||
type EventFilterFunc func(event *api.Event) bool
 | 
					type EventFilterFunc func(event *v1.Event) bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DefaultEventFilterFunc returns false for all incoming events
 | 
					// DefaultEventFilterFunc returns false for all incoming events
 | 
				
			||||||
func DefaultEventFilterFunc(event *api.Event) bool {
 | 
					func DefaultEventFilterFunc(event *v1.Event) bool {
 | 
				
			||||||
	return false
 | 
						return false
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -70,10 +70,10 @@ func DefaultEventFilterFunc(event *api.Event) bool {
 | 
				
			|||||||
// It returns a tuple of the following:
 | 
					// It returns a tuple of the following:
 | 
				
			||||||
// aggregateKey - key the identifies the aggregate group to bucket this event
 | 
					// aggregateKey - key the identifies the aggregate group to bucket this event
 | 
				
			||||||
// localKey - key that makes this event in the local group
 | 
					// localKey - key that makes this event in the local group
 | 
				
			||||||
type EventAggregatorKeyFunc func(event *api.Event) (aggregateKey string, localKey string)
 | 
					type EventAggregatorKeyFunc func(event *v1.Event) (aggregateKey string, localKey string)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// EventAggregatorByReasonFunc aggregates events by exact match on event.Source, event.InvolvedObject, event.Type and event.Reason
 | 
					// EventAggregatorByReasonFunc aggregates events by exact match on event.Source, event.InvolvedObject, event.Type and event.Reason
 | 
				
			||||||
func EventAggregatorByReasonFunc(event *api.Event) (string, string) {
 | 
					func EventAggregatorByReasonFunc(event *v1.Event) (string, string) {
 | 
				
			||||||
	return strings.Join([]string{
 | 
						return strings.Join([]string{
 | 
				
			||||||
		event.Source.Component,
 | 
							event.Source.Component,
 | 
				
			||||||
		event.Source.Host,
 | 
							event.Source.Host,
 | 
				
			||||||
@@ -89,10 +89,10 @@ func EventAggregatorByReasonFunc(event *api.Event) (string, string) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// EventAggregatorMessageFunc is responsible for producing an aggregation message
 | 
					// EventAggregatorMessageFunc is responsible for producing an aggregation message
 | 
				
			||||||
type EventAggregatorMessageFunc func(event *api.Event) string
 | 
					type EventAggregatorMessageFunc func(event *v1.Event) string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// EventAggregratorByReasonMessageFunc returns an aggregate message by prefixing the incoming message
 | 
					// EventAggregratorByReasonMessageFunc returns an aggregate message by prefixing the incoming message
 | 
				
			||||||
func EventAggregatorByReasonMessageFunc(event *api.Event) string {
 | 
					func EventAggregatorByReasonMessageFunc(event *v1.Event) string {
 | 
				
			||||||
	return "(events with common reason combined)"
 | 
						return "(events with common reason combined)"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -142,7 +142,7 @@ type aggregateRecord struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// EventAggregate identifies similar events and groups into a common event if required
 | 
					// EventAggregate identifies similar events and groups into a common event if required
 | 
				
			||||||
func (e *EventAggregator) EventAggregate(newEvent *api.Event) (*api.Event, error) {
 | 
					func (e *EventAggregator) EventAggregate(newEvent *v1.Event) (*v1.Event, error) {
 | 
				
			||||||
	aggregateKey, localKey := e.keyFunc(newEvent)
 | 
						aggregateKey, localKey := e.keyFunc(newEvent)
 | 
				
			||||||
	now := unversioned.NewTime(e.clock.Now())
 | 
						now := unversioned.NewTime(e.clock.Now())
 | 
				
			||||||
	record := aggregateRecord{localKeys: sets.NewString(), lastTimestamp: now}
 | 
						record := aggregateRecord{localKeys: sets.NewString(), lastTimestamp: now}
 | 
				
			||||||
@@ -171,8 +171,8 @@ func (e *EventAggregator) EventAggregate(newEvent *api.Event) (*api.Event, error
 | 
				
			|||||||
	record.localKeys.PopAny()
 | 
						record.localKeys.PopAny()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// create a new aggregate event
 | 
						// create a new aggregate event
 | 
				
			||||||
	eventCopy := &api.Event{
 | 
						eventCopy := &v1.Event{
 | 
				
			||||||
		ObjectMeta: api.ObjectMeta{
 | 
							ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
			Name:      fmt.Sprintf("%v.%x", newEvent.InvolvedObject.Name, now.UnixNano()),
 | 
								Name:      fmt.Sprintf("%v.%x", newEvent.InvolvedObject.Name, now.UnixNano()),
 | 
				
			||||||
			Namespace: newEvent.Namespace,
 | 
								Namespace: newEvent.Namespace,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -216,7 +216,7 @@ func newEventLogger(lruCacheEntries int, clock clock.Clock) *eventLogger {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// eventObserve records the event, and determines if its frequency should update
 | 
					// eventObserve records the event, and determines if its frequency should update
 | 
				
			||||||
func (e *eventLogger) eventObserve(newEvent *api.Event) (*api.Event, []byte, error) {
 | 
					func (e *eventLogger) eventObserve(newEvent *v1.Event) (*v1.Event, []byte, error) {
 | 
				
			||||||
	var (
 | 
						var (
 | 
				
			||||||
		patch []byte
 | 
							patch []byte
 | 
				
			||||||
		err   error
 | 
							err   error
 | 
				
			||||||
@@ -261,7 +261,7 @@ func (e *eventLogger) eventObserve(newEvent *api.Event) (*api.Event, []byte, err
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// updateState updates its internal tracking information based on latest server state
 | 
					// updateState updates its internal tracking information based on latest server state
 | 
				
			||||||
func (e *eventLogger) updateState(event *api.Event) {
 | 
					func (e *eventLogger) updateState(event *v1.Event) {
 | 
				
			||||||
	key := getEventKey(event)
 | 
						key := getEventKey(event)
 | 
				
			||||||
	e.Lock()
 | 
						e.Lock()
 | 
				
			||||||
	defer e.Unlock()
 | 
						defer e.Unlock()
 | 
				
			||||||
@@ -305,7 +305,7 @@ type EventCorrelator struct {
 | 
				
			|||||||
// EventCorrelateResult is the result of a Correlate
 | 
					// EventCorrelateResult is the result of a Correlate
 | 
				
			||||||
type EventCorrelateResult struct {
 | 
					type EventCorrelateResult struct {
 | 
				
			||||||
	// the event after correlation
 | 
						// the event after correlation
 | 
				
			||||||
	Event *api.Event
 | 
						Event *v1.Event
 | 
				
			||||||
	// if provided, perform a strategic patch when updating the record on the server
 | 
						// if provided, perform a strategic patch when updating the record on the server
 | 
				
			||||||
	Patch []byte
 | 
						Patch []byte
 | 
				
			||||||
	// if true, do no further processing of the event
 | 
						// if true, do no further processing of the event
 | 
				
			||||||
@@ -342,7 +342,7 @@ func NewEventCorrelator(clock clock.Clock) *EventCorrelator {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// EventCorrelate filters, aggregates, counts, and de-duplicates all incoming events
 | 
					// EventCorrelate filters, aggregates, counts, and de-duplicates all incoming events
 | 
				
			||||||
func (c *EventCorrelator) EventCorrelate(newEvent *api.Event) (*EventCorrelateResult, error) {
 | 
					func (c *EventCorrelator) EventCorrelate(newEvent *v1.Event) (*EventCorrelateResult, error) {
 | 
				
			||||||
	if c.filterFunc(newEvent) {
 | 
						if c.filterFunc(newEvent) {
 | 
				
			||||||
		return &EventCorrelateResult{Skip: true}, nil
 | 
							return &EventCorrelateResult{Skip: true}, nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -355,6 +355,6 @@ func (c *EventCorrelator) EventCorrelate(newEvent *api.Event) (*EventCorrelateRe
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UpdateState based on the latest observed state from server
 | 
					// UpdateState based on the latest observed state from server
 | 
				
			||||||
func (c *EventCorrelator) UpdateState(event *api.Event) {
 | 
					func (c *EventCorrelator) UpdateState(event *v1.Event) {
 | 
				
			||||||
	c.logger.updateState(event)
 | 
						c.logger.updateState(event)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,14 +22,14 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/clock"
 | 
						"k8s.io/kubernetes/pkg/util/clock"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/diff"
 | 
						"k8s.io/kubernetes/pkg/util/diff"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func makeObjectReference(kind, name, namespace string) api.ObjectReference {
 | 
					func makeObjectReference(kind, name, namespace string) v1.ObjectReference {
 | 
				
			||||||
	return api.ObjectReference{
 | 
						return v1.ObjectReference{
 | 
				
			||||||
		Kind:       kind,
 | 
							Kind:       kind,
 | 
				
			||||||
		Name:       name,
 | 
							Name:       name,
 | 
				
			||||||
		Namespace:  namespace,
 | 
							Namespace:  namespace,
 | 
				
			||||||
@@ -38,34 +38,34 @@ func makeObjectReference(kind, name, namespace string) api.ObjectReference {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func makeEvent(reason, message string, involvedObject api.ObjectReference) api.Event {
 | 
					func makeEvent(reason, message string, involvedObject v1.ObjectReference) v1.Event {
 | 
				
			||||||
	eventTime := unversioned.Now()
 | 
						eventTime := unversioned.Now()
 | 
				
			||||||
	event := api.Event{
 | 
						event := v1.Event{
 | 
				
			||||||
		Reason:         reason,
 | 
							Reason:         reason,
 | 
				
			||||||
		Message:        message,
 | 
							Message:        message,
 | 
				
			||||||
		InvolvedObject: involvedObject,
 | 
							InvolvedObject: involvedObject,
 | 
				
			||||||
		Source: api.EventSource{
 | 
							Source: v1.EventSource{
 | 
				
			||||||
			Component: "kubelet",
 | 
								Component: "kubelet",
 | 
				
			||||||
			Host:      "kublet.node1",
 | 
								Host:      "kublet.node1",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		Count:          1,
 | 
							Count:          1,
 | 
				
			||||||
		FirstTimestamp: eventTime,
 | 
							FirstTimestamp: eventTime,
 | 
				
			||||||
		LastTimestamp:  eventTime,
 | 
							LastTimestamp:  eventTime,
 | 
				
			||||||
		Type:           api.EventTypeNormal,
 | 
							Type:           v1.EventTypeNormal,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return event
 | 
						return event
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func makeEvents(num int, template api.Event) []api.Event {
 | 
					func makeEvents(num int, template v1.Event) []v1.Event {
 | 
				
			||||||
	events := []api.Event{}
 | 
						events := []v1.Event{}
 | 
				
			||||||
	for i := 0; i < num; i++ {
 | 
						for i := 0; i < num; i++ {
 | 
				
			||||||
		events = append(events, template)
 | 
							events = append(events, template)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return events
 | 
						return events
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func makeUniqueEvents(num int) []api.Event {
 | 
					func makeUniqueEvents(num int) []v1.Event {
 | 
				
			||||||
	events := []api.Event{}
 | 
						events := []v1.Event{}
 | 
				
			||||||
	kind := "Pod"
 | 
						kind := "Pod"
 | 
				
			||||||
	for i := 0; i < num; i++ {
 | 
						for i := 0; i < num; i++ {
 | 
				
			||||||
		reason := strings.Join([]string{"reason", string(i)}, "-")
 | 
							reason := strings.Join([]string{"reason", string(i)}, "-")
 | 
				
			||||||
@@ -78,7 +78,7 @@ func makeUniqueEvents(num int) []api.Event {
 | 
				
			|||||||
	return events
 | 
						return events
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func makeSimilarEvents(num int, template api.Event, messagePrefix string) []api.Event {
 | 
					func makeSimilarEvents(num int, template v1.Event, messagePrefix string) []v1.Event {
 | 
				
			||||||
	events := makeEvents(num, template)
 | 
						events := makeEvents(num, template)
 | 
				
			||||||
	for i := range events {
 | 
						for i := range events {
 | 
				
			||||||
		events[i].Message = strings.Join([]string{messagePrefix, string(i), events[i].Message}, "-")
 | 
							events[i].Message = strings.Join([]string{messagePrefix, string(i), events[i].Message}, "-")
 | 
				
			||||||
@@ -86,12 +86,12 @@ func makeSimilarEvents(num int, template api.Event, messagePrefix string) []api.
 | 
				
			|||||||
	return events
 | 
						return events
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func setCount(event api.Event, count int) api.Event {
 | 
					func setCount(event v1.Event, count int) v1.Event {
 | 
				
			||||||
	event.Count = int32(count)
 | 
						event.Count = int32(count)
 | 
				
			||||||
	return event
 | 
						return event
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func validateEvent(messagePrefix string, actualEvent *api.Event, expectedEvent *api.Event, t *testing.T) (*api.Event, error) {
 | 
					func validateEvent(messagePrefix string, actualEvent *v1.Event, expectedEvent *v1.Event, t *testing.T) (*v1.Event, error) {
 | 
				
			||||||
	recvEvent := *actualEvent
 | 
						recvEvent := *actualEvent
 | 
				
			||||||
	expectCompression := expectedEvent.Count > 1
 | 
						expectCompression := expectedEvent.Count > 1
 | 
				
			||||||
	t.Logf("%v - expectedEvent.Count is %d\n", messagePrefix, expectedEvent.Count)
 | 
						t.Logf("%v - expectedEvent.Count is %d\n", messagePrefix, expectedEvent.Count)
 | 
				
			||||||
@@ -172,13 +172,13 @@ func TestEventCorrelator(t *testing.T) {
 | 
				
			|||||||
	similarEvent := makeEvent("similar", "similar message", makeObjectReference("Pod", "my-pod", "my-ns"))
 | 
						similarEvent := makeEvent("similar", "similar message", makeObjectReference("Pod", "my-pod", "my-ns"))
 | 
				
			||||||
	aggregateEvent := makeEvent(similarEvent.Reason, EventAggregatorByReasonMessageFunc(&similarEvent), similarEvent.InvolvedObject)
 | 
						aggregateEvent := makeEvent(similarEvent.Reason, EventAggregatorByReasonMessageFunc(&similarEvent), similarEvent.InvolvedObject)
 | 
				
			||||||
	scenario := map[string]struct {
 | 
						scenario := map[string]struct {
 | 
				
			||||||
		previousEvents  []api.Event
 | 
							previousEvents  []v1.Event
 | 
				
			||||||
		newEvent        api.Event
 | 
							newEvent        v1.Event
 | 
				
			||||||
		expectedEvent   api.Event
 | 
							expectedEvent   v1.Event
 | 
				
			||||||
		intervalSeconds int
 | 
							intervalSeconds int
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		"create-a-single-event": {
 | 
							"create-a-single-event": {
 | 
				
			||||||
			previousEvents:  []api.Event{},
 | 
								previousEvents:  []v1.Event{},
 | 
				
			||||||
			newEvent:        firstEvent,
 | 
								newEvent:        firstEvent,
 | 
				
			||||||
			expectedEvent:   setCount(firstEvent, 1),
 | 
								expectedEvent:   setCount(firstEvent, 1),
 | 
				
			||||||
			intervalSeconds: 5,
 | 
								intervalSeconds: 5,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/meta"
 | 
						"k8s.io/kubernetes/pkg/api/meta"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/runtime"
 | 
						"k8s.io/kubernetes/pkg/runtime"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/types"
 | 
						"k8s.io/kubernetes/pkg/types"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/watch"
 | 
						"k8s.io/kubernetes/pkg/watch"
 | 
				
			||||||
@@ -161,7 +162,7 @@ func (f *FakeControllerSource) getListItemsLocked() ([]runtime.Object, error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// List returns a list object, with its resource version set.
 | 
					// List returns a list object, with its resource version set.
 | 
				
			||||||
func (f *FakeControllerSource) List(options api.ListOptions) (runtime.Object, error) {
 | 
					func (f *FakeControllerSource) List(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
	f.lock.RLock()
 | 
						f.lock.RLock()
 | 
				
			||||||
	defer f.lock.RUnlock()
 | 
						defer f.lock.RUnlock()
 | 
				
			||||||
	list, err := f.getListItemsLocked()
 | 
						list, err := f.getListItemsLocked()
 | 
				
			||||||
@@ -182,14 +183,14 @@ func (f *FakeControllerSource) List(options api.ListOptions) (runtime.Object, er
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// List returns a list object, with its resource version set.
 | 
					// List returns a list object, with its resource version set.
 | 
				
			||||||
func (f *FakePVControllerSource) List(options api.ListOptions) (runtime.Object, error) {
 | 
					func (f *FakePVControllerSource) List(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
	f.lock.RLock()
 | 
						f.lock.RLock()
 | 
				
			||||||
	defer f.lock.RUnlock()
 | 
						defer f.lock.RUnlock()
 | 
				
			||||||
	list, err := f.FakeControllerSource.getListItemsLocked()
 | 
						list, err := f.FakeControllerSource.getListItemsLocked()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	listObj := &api.PersistentVolumeList{}
 | 
						listObj := &v1.PersistentVolumeList{}
 | 
				
			||||||
	if err := meta.SetList(listObj, list); err != nil {
 | 
						if err := meta.SetList(listObj, list); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -203,14 +204,14 @@ func (f *FakePVControllerSource) List(options api.ListOptions) (runtime.Object,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// List returns a list object, with its resource version set.
 | 
					// List returns a list object, with its resource version set.
 | 
				
			||||||
func (f *FakePVCControllerSource) List(options api.ListOptions) (runtime.Object, error) {
 | 
					func (f *FakePVCControllerSource) List(options v1.ListOptions) (runtime.Object, error) {
 | 
				
			||||||
	f.lock.RLock()
 | 
						f.lock.RLock()
 | 
				
			||||||
	defer f.lock.RUnlock()
 | 
						defer f.lock.RUnlock()
 | 
				
			||||||
	list, err := f.FakeControllerSource.getListItemsLocked()
 | 
						list, err := f.FakeControllerSource.getListItemsLocked()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	listObj := &api.PersistentVolumeClaimList{}
 | 
						listObj := &v1.PersistentVolumeClaimList{}
 | 
				
			||||||
	if err := meta.SetList(listObj, list); err != nil {
 | 
						if err := meta.SetList(listObj, list); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -225,7 +226,7 @@ func (f *FakePVCControllerSource) List(options api.ListOptions) (runtime.Object,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Watch returns a watch, which will be pre-populated with all changes
 | 
					// Watch returns a watch, which will be pre-populated with all changes
 | 
				
			||||||
// after resourceVersion.
 | 
					// after resourceVersion.
 | 
				
			||||||
func (f *FakeControllerSource) Watch(options api.ListOptions) (watch.Interface, error) {
 | 
					func (f *FakeControllerSource) Watch(options v1.ListOptions) (watch.Interface, error) {
 | 
				
			||||||
	f.lock.RLock()
 | 
						f.lock.RLock()
 | 
				
			||||||
	defer f.lock.RUnlock()
 | 
						defer f.lock.RUnlock()
 | 
				
			||||||
	rc, err := strconv.Atoi(options.ResourceVersion)
 | 
						rc, err := strconv.Atoi(options.ResourceVersion)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,6 +21,7 @@ import (
 | 
				
			|||||||
	"testing"
 | 
						"testing"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api"
 | 
						"k8s.io/kubernetes/pkg/api"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/api/v1"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/watch"
 | 
						"k8s.io/kubernetes/pkg/watch"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -33,7 +34,7 @@ func consume(t *testing.T, w watch.Interface, rvs []string, done *sync.WaitGroup
 | 
				
			|||||||
			t.Errorf("%#v: unexpected channel close, wanted %v", rvs, rv)
 | 
								t.Errorf("%#v: unexpected channel close, wanted %v", rvs, rv)
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		gotRV := got.Object.(*api.Pod).ObjectMeta.ResourceVersion
 | 
							gotRV := got.Object.(*v1.Pod).ObjectMeta.ResourceVersion
 | 
				
			||||||
		if e, a := rv, gotRV; e != a {
 | 
							if e, a := rv, gotRV; e != a {
 | 
				
			||||||
			t.Errorf("wanted %v, got %v", e, a)
 | 
								t.Errorf("wanted %v, got %v", e, a)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
@@ -48,9 +49,9 @@ func consume(t *testing.T, w watch.Interface, rvs []string, done *sync.WaitGroup
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestRCNumber(t *testing.T) {
 | 
					func TestRCNumber(t *testing.T) {
 | 
				
			||||||
	pod := func(name string) *api.Pod {
 | 
						pod := func(name string) *v1.Pod {
 | 
				
			||||||
		return &api.Pod{
 | 
							return &v1.Pod{
 | 
				
			||||||
			ObjectMeta: api.ObjectMeta{
 | 
								ObjectMeta: v1.ObjectMeta{
 | 
				
			||||||
				Name: name,
 | 
									Name: name,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -64,13 +65,13 @@ func TestRCNumber(t *testing.T) {
 | 
				
			|||||||
	source.Modify(pod("foo"))
 | 
						source.Modify(pod("foo"))
 | 
				
			||||||
	source.Modify(pod("foo"))
 | 
						source.Modify(pod("foo"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	w, err := source.Watch(api.ListOptions{ResourceVersion: "1"})
 | 
						w, err := source.Watch(v1.ListOptions{ResourceVersion: "1"})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Fatalf("Unexpected error: %v", err)
 | 
							t.Fatalf("Unexpected error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	go consume(t, w, []string{"2", "3"}, wg)
 | 
						go consume(t, w, []string{"2", "3"}, wg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	list, err := source.List(api.ListOptions{})
 | 
						list, err := source.List(v1.ListOptions{})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Fatalf("Unexpected error: %v", err)
 | 
							t.Fatalf("Unexpected error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -78,13 +79,13 @@ func TestRCNumber(t *testing.T) {
 | 
				
			|||||||
		t.Errorf("wanted %v, got %v", e, a)
 | 
							t.Errorf("wanted %v, got %v", e, a)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	w2, err := source.Watch(api.ListOptions{ResourceVersion: "2"})
 | 
						w2, err := source.Watch(v1.ListOptions{ResourceVersion: "2"})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Fatalf("Unexpected error: %v", err)
 | 
							t.Fatalf("Unexpected error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	go consume(t, w2, []string{"3"}, wg)
 | 
						go consume(t, w2, []string{"3"}, wg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	w3, err := source.Watch(api.ListOptions{ResourceVersion: "3"})
 | 
						w3, err := source.Watch(v1.ListOptions{ResourceVersion: "3"})
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Fatalf("Unexpected error: %v", err)
 | 
							t.Fatalf("Unexpected error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user