mirror of https://github.com/knative/caching.git
Auto-update dependencies (#223)
Produced via: `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh` /assign n3wscott vagababov /cc n3wscott vagababov
This commit is contained in:
parent
6acd3ce6bd
commit
5b74238e43
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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/<repo>/pkg/client/injection/reconciler/<clientgroup>
|
|||
|
||||
Controller related artifacts:
|
||||
|
||||
- `NewImpl` - gets an injection based client and lister for <kind>, sets up
|
||||
- `NewImpl` - gets an injection based client and lister for `<kind>`, 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 <kind>.
|
||||
controller reconciling `<kind>`.
|
||||
|
||||
```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 <kind>.
|
||||
controller finalizing `<kind>`.
|
||||
|
||||
```go
|
||||
// Check that our Reconciler implements Interface
|
||||
|
|
|
@ -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{})
|
||||
|
|
Loading…
Reference in New Issue