From 5b74238e43f6a22fa5fa4a5ca123e5967b21fe11 Mon Sep 17 00:00:00 2001 From: Knative Prow Robot <41213312+knative-prow-robot@users.noreply.github.com> Date: Wed, 4 Mar 2020 10:54:54 -0800 Subject: [PATCH] Auto-update dependencies (#223) Produced via: `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh` /assign n3wscott vagababov /cc n3wscott vagababov --- Gopkg.lock | 6 ++-- .../generators/reconciler_controller.go | 5 +++- .../generators/reconciler_controller_stub.go | 28 +++++++++++++++++-- .../generators/reconciler_reconciler.go | 4 +-- vendor/knative.dev/pkg/injection/README.md | 10 +++---- .../pkg/reconciler/testing/context.go | 7 +++-- 6 files changed, 44 insertions(+), 16 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index ea43ca53..4fd34185 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -966,7 +966,7 @@ [[projects]] branch = "master" - digest = "1:8599e892ef7b4613f138689826e24cf7ce0db32faac658babd6f60bc6c1db8b8" + digest = "1:594e2e8f9e26efdd32cef30b5c099d422bbe23ac6a9f38f3aed473b610351268" name = "knative.dev/pkg" packages = [ "apis", @@ -986,7 +986,7 @@ "reconciler", ] pruneopts = "T" - revision = "73701f1aa50ece37d044bd843a13cac6a84e3939" + revision = "5605ade5242dbce408f2d2e5cf6bbc43355dfd6c" [[projects]] branch = "master" @@ -997,7 +997,7 @@ "tools/dep-collector", ] pruneopts = "UT" - revision = "7b384c28e66cb8561f3620bd91eb9d5680686a8c" + revision = "b818eb8b5c3c93358da6aa219172981c8f79d247" [[projects]] digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c" diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go index 05db6d6d..a41e3a1e 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller.go @@ -154,7 +154,10 @@ const ( defaultControllerAgentName = "{{.type|lowercaseSingular}}-controller" defaultFinalizerName = "{{.type|allLowercasePlural}}.{{.group}}" defaultQueueName = "{{.type|allLowercasePlural}}" - {{if .hasClass}}classAnnotationKey = "{{ .class }}"{{end}} + {{if .hasClass}} + // ClassAnnotationKey points to the annotation for the class of this resource. + ClassAnnotationKey = "{{ .class }}" + {{end}} ) // NewImpl returns a {{.controllerImpl|raw}} that handles queuing and feeding work from diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller_stub.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller_stub.go index 594a6881..4c745e43 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller_stub.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_controller_stub.go @@ -87,6 +87,18 @@ func (g *reconcilerControllerStubGenerator) GenerateType(c *generator.Context, t Package: "knative.dev/pkg/configmap", Name: "Watcher", }), + "classAnnotationKey": c.Universe.Variable(types.Name{ + Package: g.reconcilerPkg, + Name: "ClassAnnotationKey", + }), + "annotationFilterFunc": c.Universe.Function(types.Name{ + Package: "knative.dev/pkg/reconciler", + Name: "AnnotationFilterFunc", + }), + "filterHandler": c.Universe.Type(types.Name{ + Package: "k8s.io/client-go/tools/cache", + Name: "FilteringResourceEventHandler", + }), } sw.Do(reconcilerControllerStub, m) @@ -106,15 +118,27 @@ func NewController( {{.type|lowercaseSingular}}Informer := {{.informerGet|raw}}(ctx) + {{if .hasClass}} + classValue := "default" // TODO: update this to the appropriate value. + classFilter := {{.annotationFilterFunc|raw}}({{.classAnnotationKey|raw}}, classValue, false /*allowUnset*/) + {{end}} + // TODO: setup additional informers here. - {{if .hasClass}}// TODO: pass in the expected value for the class annotation filter.{{end}} + {{if .hasClass}}// TODO: remember to use the classFilter from above to filter appropriately.{{end}} r := &Reconciler{} - impl := {{.reconcilerNewImpl|raw}}(ctx, r{{if .hasClass}}, "default"{{end}}) + impl := {{.reconcilerNewImpl|raw}}(ctx, r{{if .hasClass}}, classValue{{end}}) logger.Info("Setting up event handlers.") + {{if .hasClass}} + {{.type|lowercaseSingular}}Informer.Informer().AddEventHandler({{.filterHandler|raw}}{ + FilterFunc: classFilter, + Handler: controller.HandleAll(impl.Enqueue), + }) + {{else}} {{.type|lowercaseSingular}}Informer.Informer().AddEventHandler(controller.HandleAll(impl.Enqueue)) + {{end}} // TODO: add additional informer event handlers here. diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go index 9bf3b7cf..c3e08bdb 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/reconciler_reconciler.go @@ -263,9 +263,9 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro return err } {{if .hasClass}} - if classValue, found := original.GetAnnotations()[classAnnotationKey]; !found || classValue != r.classValue { + if classValue, found := original.GetAnnotations()[ClassAnnotationKey]; !found || classValue != r.classValue { logger.Debugw("Skip reconciling resource, class annotation value does not match reconciler instance value.", - zap.String("classKey", classAnnotationKey), + zap.String("classKey", ClassAnnotationKey), zap.String("issue", classValue+"!="+r.classValue)) return nil } diff --git a/vendor/knative.dev/pkg/injection/README.md b/vendor/knative.dev/pkg/injection/README.md index 77b0877b..259f0267 100644 --- a/vendor/knative.dev/pkg/injection/README.md +++ b/vendor/knative.dev/pkg/injection/README.md @@ -292,7 +292,7 @@ required = [ ## Generated Reconciler Responsibilities -The goal of generating the reconcilers is to provide the controller implementor +The goal of generating the reconcilers is to provide the controller implementer a strongly typed interface, and ensure correct reconciler behaviour around status updates, Kubernetes event creation, and queue management. @@ -317,7 +317,7 @@ Optionally, support for finalizers: ``` - `ReconcileKind` is only called if the resource's deletion timestamp is empty. -- `FinalizeKind` is optional, and if implemnted by the reconciler will be called +- `FinalizeKind` is optional, and if implemented by the reconciler will be called when the resource's deletion timestamp is set. The responsibility and consequences of using the generated @@ -397,7 +397,7 @@ kindreconciler "knative.dev//pkg/client/injection/reconciler/ Controller related artifacts: -- `NewImpl` - gets an injection based client and lister for , sets up +- `NewImpl` - gets an injection based client and lister for ``, sets up Kubernetes Event recorders, and delegates to `controller.NewImpl` for queue management. @@ -408,7 +408,7 @@ impl := reconciler.NewImpl(ctx, reconcilerInstance) Reconciler related artifacts: - `Interface` - defines the strongly typed interfaces to be implemented by a - controller reconciling . + controller reconciling ``. ```go // Check that our Reconciler implements Interface @@ -416,7 +416,7 @@ var _ addressableservicereconciler.Interface = (*Reconciler)(nil) ``` - `Finalizer` - defines the strongly typed interfaces to be implemented by a - controller finalizing . + controller finalizing ``. ```go // Check that our Reconciler implements Interface diff --git a/vendor/knative.dev/pkg/reconciler/testing/context.go b/vendor/knative.dev/pkg/reconciler/testing/context.go index 116ac48b..7c36d8ed 100644 --- a/vendor/knative.dev/pkg/reconciler/testing/context.go +++ b/vendor/knative.dev/pkg/reconciler/testing/context.go @@ -18,7 +18,8 @@ package testing import ( "context" - "testing" + + "go.uber.org/zap/zaptest" "k8s.io/client-go/rest" "k8s.io/client-go/tools/record" @@ -29,14 +30,14 @@ import ( ) // SetupFakeContext sets up the the Context and the fake informers for the tests. -func SetupFakeContext(t *testing.T) (context.Context, []controller.Informer) { +func SetupFakeContext(t zaptest.TestingT) (context.Context, []controller.Informer) { c, _, is := SetupFakeContextWithCancel(t) return c, is } // SetupFakeContextWithCancel sets up the the Context and the fake informers for the tests // The provided context can be canceled using provided callback. -func SetupFakeContextWithCancel(t *testing.T) (context.Context, context.CancelFunc, []controller.Informer) { +func SetupFakeContextWithCancel(t zaptest.TestingT) (context.Context, context.CancelFunc, []controller.Informer) { ctx, c := context.WithCancel(logtesting.TestContextWithLogger(t)) ctx = controller.WithEventRecorder(ctx, record.NewFakeRecorder(1000)) ctx, is := injection.Fake.SetupInformers(ctx, &rest.Config{})