From 1f067018c4f94180d969f9f4e76ecfe02887ca1d Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Tue, 18 Feb 2020 06:46:59 -0800 Subject: [PATCH] Auto-update dependencies (#206) Produced via: `dep ensure -update knative.dev/test-infra knative.dev/pkg` /assign n3wscott /cc n3wscott --- Gopkg.lock | 6 +- .../generators/reconciler_reconciler.go | 7 ++ vendor/knative.dev/pkg/injection/README.md | 5 +- .../knative.dev/pkg/logging/testing/util.go | 6 +- vendor/knative.dev/pkg/reconciler/filter.go | 100 ++++++++++++++++++ vendor/knative.dev/pkg/reconciler/retry.go | 3 + .../clustermanager/e2e-tests/boskos/boskos.go | 8 +- 7 files changed, 124 insertions(+), 11 deletions(-) create mode 100644 vendor/knative.dev/pkg/reconciler/filter.go diff --git a/Gopkg.lock b/Gopkg.lock index 9598f808..1eb10fc4 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -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" 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 283d6864..537da77d 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 @@ -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 { diff --git a/vendor/knative.dev/pkg/injection/README.md b/vendor/knative.dev/pkg/injection/README.md index ca156408..806d9445 100644 --- a/vendor/knative.dev/pkg/injection/README.md +++ b/vendor/knative.dev/pkg/injection/README.md @@ -15,6 +15,7 @@ import ( "knative.dev/pkg/configmap" "knative.dev/pkg/controller" "knative.dev/pkg/logging" + kindreconciler "knative.dev//pkg/client/injection/reconciler///" ) 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. diff --git a/vendor/knative.dev/pkg/logging/testing/util.go b/vendor/knative.dev/pkg/logging/testing/util.go index 6773a10f..3c844aad 100644 --- a/vendor/knative.dev/pkg/logging/testing/util.go +++ b/vendor/knative.dev/pkg/logging/testing/util.go @@ -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)) } diff --git a/vendor/knative.dev/pkg/reconciler/filter.go b/vendor/knative.dev/pkg/reconciler/filter.go new file mode 100644 index 00000000..f9042cb9 --- /dev/null +++ b/vendor/knative.dev/pkg/reconciler/filter.go @@ -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 +} diff --git a/vendor/knative.dev/pkg/reconciler/retry.go b/vendor/knative.dev/pkg/reconciler/retry.go index 63c2af24..dd9d4145 100644 --- a/vendor/knative.dev/pkg/reconciler/retry.go +++ b/vendor/knative.dev/pkg/reconciler/retry.go @@ -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. diff --git a/vendor/knative.dev/pkg/testutils/clustermanager/e2e-tests/boskos/boskos.go b/vendor/knative.dev/pkg/testutils/clustermanager/e2e-tests/boskos/boskos.go index 28f309c1..07450b5a 100644 --- a/vendor/knative.dev/pkg/testutils/clustermanager/e2e-tests/boskos/boskos.go +++ b/vendor/knative.dev/pkg/testutils/clustermanager/e2e-tests/boskos/boskos.go @@ -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