Commit Graph

8 Commits

Author SHA1 Message Date
Zbynek Roubalik 2d4efecc6b
bump to k8s 1.18 (#1428)
* bump to k8s 1.18.8

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* plumbing ctx through

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* add more ctx plumbing

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* ctx WithCancel()

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-09-11 07:54:00 -07:00
Markus Thömmes bf436d5e55
Remove our copy of the proxy watcher. (#1560) 2020-07-27 16:21:59 -07:00
grac3gao 46cfce8d99 Add check in informer to make controllers work when process invalid resources (#880)
* #2047 sources-controller can't recover from faulty sink (in eventing)

* #2047 sources-controller can't recover from faulty sink (in eventing)

* add unit test

* change after review

* change after review-2

Co-Authored-By: Victor Agababov <vagababov@gmail.com>
2019-11-26 14:16:21 -08:00
Victor Agababov 74c5d67ea0 Fix the issues pointed out by staticcheck (#541)
* Fix the issues pointed out by staticcheck

* review fix
2019-07-23 13:13:36 -07:00
Matt Moore 222dd25986 Migrate pkg to use the knative.dev/pkg import path (#489)
* Manual changes.

* scripted changes.
2019-06-26 13:02:06 -07:00
Victor Agababov c2f344436b Better for loop for iterating over the channel (#458) 2019-06-12 13:40:44 -07:00
Matt Moore fd1e3cc5c9 Add logic to convert the watch.Interface. (#106)
The watch logic returns events containing `unstructured.Unstructured`.  This adds a proxy that converts those to the appropriate structured type.
2018-09-29 21:38:22 -07:00
Matt Moore 3473880674 Informers / Listers for Duck Types. (#86)
This starts to sketch common libraries for instantiating informers/listers for a particular GroupVersionResource as one of our duck types.

You can instantiate a duck.InformerFactory like so:
```go
        dynaClient, err := dynamic.NewForConfig(cfg)
        if err != nil {
                logger.Fatalf("Error building dynamic clientset: %v", err)
        }

	// Cache as the outermost layer so we only register the EventHandler once.
        dif := &duck.CachedInformerFactory{
                Delegate: &duck.EnqueueInformerFactory{
			Delegate: &duck.TypedInformerFactory{
        	                Client:       dynaClient,
                	        Type:         &duckv1alpha1.Target{},
                        	ResyncPeriod: 30 * time.Second,
	                        StopChannel:  stopCh,
			},
			EventHandler: cache.ResourceEventHandlerFuncs{
				AddFunc: func(obj interface{}) {
					// Enqueue, obj is: *duckerv1alpha1.Target
				},
				UpdateFunc: func(old, new interface{}) {
					// Enqueue, old and new are: *duckerv1alpha1.Target
				},
			},
                },
        }
```

Then, as you come across new GroupVersionResources that you want to handle:
```go
        informer, lister, err := dif.Get(gvr)
        if err != nil {
               logger.Fatalf("Error starting shared index informer: %v", err)
        }
```

With the `duck.TypedInformerFactory` the objects will be returned as the provided `Type:`, so in this example, you could safely write:
```go
        elt, err := lister.ByNamespace(ns).Get(name)
        if err != nil { ... }

        target := elt.(*duckv1alpha1.Target)
        // Stuff involving target.
```
2018-09-24 20:10:20 -07:00