mirror of https://github.com/knative/caching.git
Auto-update dependencies (#206)
Produced via: `dep ensure -update knative.dev/test-infra knative.dev/pkg` /assign n3wscott /cc n3wscott
This commit is contained in:
parent
22994af264
commit
1f067018c4
|
@ -966,7 +966,7 @@
|
|||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:112a8273481730053f435aee0101436a4b59842ea09c660ee5a3647ee9fc8c7b"
|
||||
digest = "1:6e2169542b76688fe02763aee6b53dedc9d71acb8608705393c4230ffae94e68"
|
||||
name = "knative.dev/pkg"
|
||||
packages = [
|
||||
"apis",
|
||||
|
@ -986,7 +986,7 @@
|
|||
"reconciler",
|
||||
]
|
||||
pruneopts = "T"
|
||||
revision = "d8b36f3593257b2b39ab9bb6fbd8ad6828983755"
|
||||
revision = "1cc7b7152937735a29c9d6fdaf3b244684aa850e"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -997,7 +997,7 @@
|
|||
"tools/dep-collector",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "fb2b3564c1e56cd0dadd4515f3ef0fd803da3755"
|
||||
revision = "9a261621df10478b791e5a320481766b38b43471"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
||||
|
|
|
@ -70,6 +70,10 @@ func (g *reconcilerReconcilerGenerator) GenerateType(c *generator.Context, t *ty
|
|||
Package: "knative.dev/pkg/controller",
|
||||
Name: "Reconciler",
|
||||
}),
|
||||
"controllerWithEventRecorder": c.Universe.Type(types.Name{
|
||||
Package: "knative.dev/pkg/controller",
|
||||
Name: "WithEventRecorder",
|
||||
}),
|
||||
"corev1EventSource": c.Universe.Function(types.Name{
|
||||
Package: "k8s.io/api/core/v1",
|
||||
Name: "EventSource",
|
||||
|
@ -222,6 +226,9 @@ func (r *reconcilerImpl) Reconcile(ctx {{.contextContext|raw}}, key string) erro
|
|||
ctx = r.configStore.ToContext(ctx)
|
||||
}
|
||||
|
||||
// Add the recorder to context.
|
||||
ctx = {{.controllerWithEventRecorder|raw}}(ctx, r.Recorder)
|
||||
|
||||
// Convert the namespace/name string into a distinct namespace and name
|
||||
namespace, name, err := {{.cacheSplitMetaNamespaceKey|raw}}(key)
|
||||
if err != nil {
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"knative.dev/pkg/configmap"
|
||||
"knative.dev/pkg/controller"
|
||||
"knative.dev/pkg/logging"
|
||||
kindreconciler "knative.dev/<repo>/pkg/client/injection/reconciler/<clientgroup>/<version>/<resource>"
|
||||
)
|
||||
|
||||
func NewController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
|
||||
|
@ -22,10 +23,10 @@ func NewController(ctx context.Context, cmw configmap.Watcher) *controller.Impl
|
|||
|
||||
// TODO(you): Access informers
|
||||
|
||||
c := &Reconciler{
|
||||
r := &Reconciler{
|
||||
// TODO(you): Pass listers, clients, and other stuff.
|
||||
}
|
||||
impl := controller.NewImpl(c, logger, "NameOfController")
|
||||
impl := kindreconciler.NewImpl(ctx, r)
|
||||
|
||||
// TODO(you): Set up event handlers.
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@ package testing
|
|||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zaptest"
|
||||
|
||||
|
@ -27,7 +25,7 @@ import (
|
|||
)
|
||||
|
||||
// TestLogger gets a logger to use in unit and end to end tests
|
||||
func TestLogger(t *testing.T) *zap.SugaredLogger {
|
||||
func TestLogger(t zaptest.TestingT) *zap.SugaredLogger {
|
||||
opts := zaptest.WrapOptions(
|
||||
zap.AddCaller(),
|
||||
zap.Development(),
|
||||
|
@ -41,6 +39,6 @@ func TestLogger(t *testing.T) *zap.SugaredLogger {
|
|||
func ClearAll() {}
|
||||
|
||||
// TestContextWithLogger returns a context with a logger to be used in tests
|
||||
func TestContextWithLogger(t *testing.T) context.Context {
|
||||
func TestContextWithLogger(t zaptest.TestingT) context.Context {
|
||||
return logging.WithLogger(context.TODO(), TestLogger(t))
|
||||
}
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
Copyright 2020 The Knative 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 reconciler
|
||||
|
||||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
// AnnotationFilterFunc creates a FilterFunc only accepting objects with given annotation key and value
|
||||
func AnnotationFilterFunc(key string, value string, allowUnset bool) func(interface{}) bool {
|
||||
return func(obj interface{}) bool {
|
||||
if mo, ok := obj.(metav1.Object); ok {
|
||||
return mapHasOrDefault(mo.GetAnnotations(), key, value, allowUnset)
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// LabelExistsFilterFunc creates a FilterFunc only accepting objects which have a given label.
|
||||
func LabelExistsFilterFunc(label string) func(obj interface{}) bool {
|
||||
return func(obj interface{}) bool {
|
||||
if mo, ok := obj.(metav1.Object); ok {
|
||||
labels := mo.GetLabels()
|
||||
_, ok := labels[label]
|
||||
return ok
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// LabelFilterFunc creates a FilterFunc only accepting objects where a label is set to a specific value.
|
||||
func LabelFilterFunc(label string, value string, allowUnset bool) func(interface{}) bool {
|
||||
return func(obj interface{}) bool {
|
||||
if mo, ok := obj.(metav1.Object); ok {
|
||||
return mapHasOrDefault(mo.GetLabels(), label, value, allowUnset)
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// NameFilterFunc creates a FilterFunc only accepting objects with the given name.
|
||||
func NameFilterFunc(name string) func(interface{}) bool {
|
||||
return func(obj interface{}) bool {
|
||||
if mo, ok := obj.(metav1.Object); ok {
|
||||
return mo.GetName() == name
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// NamespaceFilterFunc creates a FilterFunc only accepting objects in the given namespace.
|
||||
func NamespaceFilterFunc(namespace string) func(interface{}) bool {
|
||||
return func(obj interface{}) bool {
|
||||
if mo, ok := obj.(metav1.Object); ok {
|
||||
return mo.GetNamespace() == namespace
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Not inverts the result of the predicate.
|
||||
func Not(f func(interface{}) bool) func(interface{}) bool {
|
||||
return func(obj interface{}) bool {
|
||||
return !f(obj)
|
||||
}
|
||||
}
|
||||
|
||||
// ChainFilterFuncs creates a FilterFunc which performs an AND of the passed FilterFuncs.
|
||||
func ChainFilterFuncs(funcs ...func(interface{}) bool) func(interface{}) bool {
|
||||
return func(obj interface{}) bool {
|
||||
for _, f := range funcs {
|
||||
if !f(obj) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// mapHasOrDefault returns true if the map has the key and its value is equal to value.
|
||||
// If the key is not found, it returns defaultValue.
|
||||
func mapHasOrDefault(m map[string]string, key string, value string, defaultValue bool) bool {
|
||||
val, ok := m[key]
|
||||
if !ok {
|
||||
return defaultValue
|
||||
}
|
||||
return val == value
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
/*
|
||||
Copyright 2020 The Knative Authors
|
||||
|
||||
Licensed under the Apache License, Veroute.on 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.
|
||||
|
|
|
@ -33,8 +33,12 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
boskosURI = "http://boskos.test-pods.svc.cluster.local."
|
||||
defaultWaitDuration = time.Minute * 20
|
||||
boskosURI = "http://boskos.test-pods.svc.cluster.local."
|
||||
// Keep Boskos for 2 hours, which will be used to release Boskos resource
|
||||
// only when a job forgot or failed to release Boskos, which shouldn't
|
||||
// happen that often. Using this can avoid keeping "heartbeat" which is
|
||||
// almost not doable for Go
|
||||
defaultWaitDuration = 2 * time.Hour
|
||||
)
|
||||
|
||||
// Operation defines actions for handling GKE resources
|
||||
|
|
Loading…
Reference in New Issue