From a6ac8111e82f1f8b6a5c9e52acb8ec59782394e3 Mon Sep 17 00:00:00 2001 From: Knative Automation Date: Thu, 27 Jun 2024 02:01:50 -0400 Subject: [PATCH] [main] Upgrade to latest dependencies (#8032) upgrade to latest dependencies bumping knative.dev/pkg 8535fcc...3f6a546: > 3f6a546 Fix rand source in name (# 3070) > ee1db86 Update linter config and address lint warnings/failures (# 3068) > 26bc7b4 Register AuthenticatableType in schema (# 3069) Signed-off-by: Knative Automation --- go.mod | 2 +- go.sum | 4 ++-- vendor/knative.dev/pkg/apis/condition_set.go | 3 ++- vendor/knative.dev/pkg/apis/deprecated.go | 2 +- .../pkg/apis/duck/v1/destination.go | 4 ++-- .../pkg/apis/duck/v1/knative_reference.go | 1 - .../knative.dev/pkg/apis/duck/v1/register.go | 2 ++ .../pkg/apis/duck/v1/status_types.go | 1 - .../pkg/apis/duck/v1beta1/destination.go | 4 ++-- vendor/knative.dev/pkg/apis/kind2resource.go | 5 ++-- .../pkg/apis/testing/roundtrip/roundtrip.go | 2 +- .../codegen/cmd/injection-gen/args/args.go | 8 +++---- .../cmd/injection-gen/generators/packages.go | 8 +------ vendor/knative.dev/pkg/configmap/filter.go | 8 +++---- .../pkg/configmap/informer/synced_callback.go | 4 ++-- .../knative.dev/pkg/controller/controller.go | 15 ++++-------- vendor/knative.dev/pkg/hack/format-code.sh | 23 +++++++++++++++++++ vendor/knative.dev/pkg/injection/informers.go | 2 +- vendor/knative.dev/pkg/kmeta/names.go | 3 ++- .../pkg/leaderelection/chaosduck/main.go | 1 - .../knative.dev/pkg/leaderelection/context.go | 7 ++---- .../pkg/metrics/opencensus_exporter.go | 4 +++- .../pkg/metrics/prometheus_exporter.go | 1 - .../knative.dev/pkg/metrics/resource_view.go | 2 +- .../knative.dev/pkg/reconciler/configstore.go | 2 +- vendor/knative.dev/pkg/reconciler/events.go | 2 +- .../pkg/reconciler/testing/context.go | 2 +- .../pkg/reconciler/testing/table.go | 4 +++- vendor/knative.dev/pkg/test/helpers/name.go | 12 ++++++++-- .../knative.dev/pkg/test/ingress/ingress.go | 5 ++-- .../knative.dev/pkg/test/logging/logging.go | 2 ++ .../pkg/test/logstream/v2/stream.go | 1 - .../knative.dev/pkg/tracing/config/tracing.go | 6 ++--- vendor/knative.dev/pkg/webhook/json/decode.go | 3 ++- .../pkg/webhook/psbinding/reconciler.go | 3 +-- .../validation/validation_admit.go | 3 ++- vendor/knative.dev/pkg/webhook/webhook.go | 1 + vendor/modules.txt | 2 +- 38 files changed, 94 insertions(+), 70 deletions(-) create mode 100644 vendor/knative.dev/pkg/hack/format-code.sh diff --git a/go.mod b/go.mod index 42bc77eab08..55a5c979746 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( k8s.io/utils v0.0.0-20240102154912-e7106e64919e knative.dev/hack v0.0.0-20240607132042-09143140a254 knative.dev/hack/schema v0.0.0-20240607132042-09143140a254 - knative.dev/pkg v0.0.0-20240625072707-8535fcc248ae + knative.dev/pkg v0.0.0-20240626134149-3f6a546ac3a4 knative.dev/reconciler-test v0.0.0-20240618170853-5bf0b86114f8 sigs.k8s.io/yaml v1.4.0 ) diff --git a/go.sum b/go.sum index 84bda4c9d2b..5046b4dbd16 100644 --- a/go.sum +++ b/go.sum @@ -842,8 +842,8 @@ knative.dev/hack v0.0.0-20240607132042-09143140a254 h1:1YFnu3U6dWZg0oxm6GU8kEdA9 knative.dev/hack v0.0.0-20240607132042-09143140a254/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q= knative.dev/hack/schema v0.0.0-20240607132042-09143140a254 h1:b9hFHGtxx0Kpm4EEjSD72lL0jms91To3OEVBTbqfOYI= knative.dev/hack/schema v0.0.0-20240607132042-09143140a254/go.mod h1:3pWwBLnTZSM9psSgCAvhKOHIPTzqfEMlWRpDu6IYhK0= -knative.dev/pkg v0.0.0-20240625072707-8535fcc248ae h1:unXplcQLqwO+QtSepyRI2zy4ZD/tciPro9Y4uVG6n6g= -knative.dev/pkg v0.0.0-20240625072707-8535fcc248ae/go.mod h1:Wikg4u73T6vk9TctrxZt60VXzqmGEQIx0iKfk1+9o4c= +knative.dev/pkg v0.0.0-20240626134149-3f6a546ac3a4 h1:slPKf3UKdBFZlz+hFy+KXzTgY9yOePLzRuEhKzgc5a4= +knative.dev/pkg v0.0.0-20240626134149-3f6a546ac3a4/go.mod h1:Wikg4u73T6vk9TctrxZt60VXzqmGEQIx0iKfk1+9o4c= knative.dev/reconciler-test v0.0.0-20240618170853-5bf0b86114f8 h1:A+rsitEiTX3GudM51g7zUMza+Ripj+boncmlJ2jZp50= knative.dev/reconciler-test v0.0.0-20240618170853-5bf0b86114f8/go.mod h1:2uUx3U6kdIzgJgMGgrGmdDdcFrFiex/DjuI2gM7Tte8= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/vendor/knative.dev/pkg/apis/condition_set.go b/vendor/knative.dev/pkg/apis/condition_set.go index 9ad14902e78..940d1b3ab32 100644 --- a/vendor/knative.dev/pkg/apis/condition_set.go +++ b/vendor/knative.dev/pkg/apis/condition_set.go @@ -17,6 +17,7 @@ limitations under the License. package apis import ( + "errors" "fmt" "reflect" "sort" @@ -233,7 +234,7 @@ func (r conditionsImpl) ClearCondition(t ConditionType) error { } // Terminal conditions are not handled as they can't be nil if r.isTerminal(t) { - return fmt.Errorf("clearing terminal conditions not implemented") + return errors.New("clearing terminal conditions not implemented") } cond := r.GetCondition(t) if cond == nil { diff --git a/vendor/knative.dev/pkg/apis/deprecated.go b/vendor/knative.dev/pkg/apis/deprecated.go index 8f07e71b31b..b5dfde2fbb4 100644 --- a/vendor/knative.dev/pkg/apis/deprecated.go +++ b/vendor/knative.dev/pkg/apis/deprecated.go @@ -94,7 +94,7 @@ func getPrefixedNamedFieldValues(prefix string, obj interface{}) (map[string]ref return fields, inlined } - for i := 0; i < objValue.NumField(); i++ { + for i := range objValue.NumField() { tf := objValue.Type().Field(i) if v := objValue.Field(i); v.IsValid() { jTag := tf.Tag.Get("json") diff --git a/vendor/knative.dev/pkg/apis/duck/v1/destination.go b/vendor/knative.dev/pkg/apis/duck/v1/destination.go index 720d4067766..34c1af94f99 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/destination.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/destination.go @@ -103,11 +103,11 @@ func (d *Destination) SetDefaults(ctx context.Context) { } } -func validateCACerts(CACert *string) *apis.FieldError { +func validateCACerts(caCert *string) *apis.FieldError { // Check the object. var errs *apis.FieldError - block, err := pem.Decode([]byte(*CACert)) + block, err := pem.Decode([]byte(*caCert)) if err != nil && block == nil { errs = errs.Also(apis.ErrInvalidValue("CA Cert provided is invalid", "caCert")) return errs diff --git a/vendor/knative.dev/pkg/apis/duck/v1/knative_reference.go b/vendor/knative.dev/pkg/apis/duck/v1/knative_reference.go index 4d03b6b97ce..2609fb1c99c 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/knative_reference.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/knative_reference.go @@ -102,7 +102,6 @@ func (kr *KReference) Validate(ctx context.Context) *apis.FieldError { Details: fmt.Sprintf("parent namespace: %q does not match ref: %q", parentNS, kr.Namespace), }) } - } } return errs diff --git a/vendor/knative.dev/pkg/apis/duck/v1/register.go b/vendor/knative.dev/pkg/apis/duck/v1/register.go index fb4348a0585..b7366b66044 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/register.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/register.go @@ -52,6 +52,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { (&KResource{}).GetListType(), &AddressableType{}, (&AddressableType{}).GetListType(), + &AuthenticatableType{}, + (&AuthenticatableType{}).GetListType(), &Source{}, (&Source{}).GetListType(), &WithPod{}, diff --git a/vendor/knative.dev/pkg/apis/duck/v1/status_types.go b/vendor/knative.dev/pkg/apis/duck/v1/status_types.go index 15e26453466..2e8d66f93b4 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/status_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/status_types.go @@ -97,7 +97,6 @@ func (s *Status) ConvertTo(ctx context.Context, sink *Status, predicates ...func conditions := make(apis.Conditions, 0, len(s.Conditions)) for _, c := range s.Conditions { - // Copy over the "happy" condition, which is the only condition that // we can reliably transfer. if c.Type == apis.ConditionReady || c.Type == apis.ConditionSucceeded { diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/destination.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/destination.go index 41c7702df16..bc6e56ae41c 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/destination.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/destination.go @@ -168,11 +168,11 @@ func validateDestinationRef(ref corev1.ObjectReference) *apis.FieldError { return errs } -func validateCACerts(CACert *string) *apis.FieldError { +func validateCACerts(caCert *string) *apis.FieldError { // Check the object. var errs *apis.FieldError - block, err := pem.Decode([]byte(*CACert)) + block, err := pem.Decode([]byte(*caCert)) if err != nil && block == nil { errs = errs.Also(apis.ErrInvalidValue("CA Cert provided is invalid", "caCert")) return errs diff --git a/vendor/knative.dev/pkg/apis/kind2resource.go b/vendor/knative.dev/pkg/apis/kind2resource.go index 37ffe080345..b1937086e6f 100644 --- a/vendor/knative.dev/pkg/apis/kind2resource.go +++ b/vendor/knative.dev/pkg/apis/kind2resource.go @@ -17,7 +17,6 @@ limitations under the License. package apis import ( - "fmt" "strings" "k8s.io/apimachinery/pkg/runtime/schema" @@ -41,7 +40,7 @@ func KindToResource(gvk schema.GroupVersionKind) schema.GroupVersionResource { func pluralizeKind(kind string) string { ret := strings.ToLower(kind) if strings.HasSuffix(ret, "s") { - return fmt.Sprintf("%ses", ret) + return ret + "es" } - return fmt.Sprintf("%ss", ret) + return ret + "s" } diff --git a/vendor/knative.dev/pkg/apis/testing/roundtrip/roundtrip.go b/vendor/knative.dev/pkg/apis/testing/roundtrip/roundtrip.go index bdf33349f10..54493b02e24 100644 --- a/vendor/knative.dev/pkg/apis/testing/roundtrip/roundtrip.go +++ b/vendor/knative.dev/pkg/apis/testing/roundtrip/roundtrip.go @@ -144,7 +144,7 @@ func ExternalTypesViaHub(t *testing.T, scheme, hubs *runtime.Scheme, fuzzerFuncs } t.Run(gvk.Group+"."+gvk.Version+"."+gvk.Kind, func(t *testing.T) { - for i := 0; i < *roundtrip.FuzzIters; i++ { + for range *roundtrip.FuzzIters { roundTripViaHub(t, gvk, scheme, hubs, f) if t.Failed() { diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/args/args.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/args/args.go index 265b4e40ae0..92595e2ffec 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/args/args.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/args/args.go @@ -17,7 +17,7 @@ limitations under the License. package args import ( - "fmt" + "errors" "github.com/spf13/pflag" "k8s.io/gengo/args" @@ -59,13 +59,13 @@ func Validate(genericArgs *args.GeneratorArgs) error { customArgs := genericArgs.CustomArgs.(*CustomArgs) if len(genericArgs.OutputPackagePath) == 0 { - return fmt.Errorf("output package cannot be empty") + return errors.New("output package cannot be empty") } if len(customArgs.VersionedClientSetPackage) == 0 { - return fmt.Errorf("versioned clientset package cannot be empty") + return errors.New("versioned clientset package cannot be empty") } if len(customArgs.ExternalVersionsInformersPackage) == 0 { - return fmt.Errorf("external versions informers package cannot be empty") + return errors.New("external versions informers package cannot be empty") } return nil diff --git a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go index f0ca43f2bf2..02f61519f08 100644 --- a/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go +++ b/vendor/knative.dev/pkg/codegen/cmd/injection-gen/generators/packages.go @@ -43,7 +43,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat klog.Fatalf("Wrong CustomArgs type: %T", arguments.CustomArgs) } - versionPackagePath := filepath.Join(arguments.OutputPackagePath) + versionPackagePath := filepath.Clean(arguments.OutputPackagePath) var packageList generator.Packages @@ -389,8 +389,6 @@ func versionInformerPackages(basePackage string, groupPkgName string, gv clientg vers := make([]generator.Package, 0, 2*len(typesToGenerate)) for _, t := range typesToGenerate { - // Fix for golang iterator bug. - t := t packagePath := packagePath + "/" + strings.ToLower(t.Name.Name) typedInformerPackage := typedInformerPackage(groupPkgName, gv, customArgs.ExternalVersionsInformersPackage) @@ -501,7 +499,6 @@ func versionInformerPackages(basePackage string, groupPkgName string, gv clientg return tags.NeedsInformerInjection() }, }) - } return vers } @@ -513,8 +510,6 @@ func reconcilerPackages(basePackage string, groupPkgName string, gv clientgentyp vers := make([]generator.Package, 0, 4*len(typesToGenerate)) for _, t := range typesToGenerate { - // Fix for golang iterator bug. - t := t extracted := extractCommentTags(t) reconcilerClasses, hasReconcilerClass := extractReconcilerClassesTag(extracted) nonNamespaced := isNonNamespaced(extracted) @@ -677,7 +672,6 @@ func versionDuckPackages(basePackage string, groupPkgName string, gv clientgenty for _, t := range typesToGenerate { // Fix for golang iterator bug. - t := t packagePath := filepath.Join(packagePath, strings.ToLower(t.Name.Name)) // Impl diff --git a/vendor/knative.dev/pkg/configmap/filter.go b/vendor/knative.dev/pkg/configmap/filter.go index ed1040e27b3..6fb332a8cff 100644 --- a/vendor/knative.dev/pkg/configmap/filter.go +++ b/vendor/knative.dev/pkg/configmap/filter.go @@ -17,7 +17,7 @@ limitations under the License. package configmap import ( - "fmt" + "errors" "reflect" corev1 "k8s.io/api/core/v1" @@ -58,17 +58,17 @@ func ValidateConstructor(constructor interface{}) error { cType := reflect.TypeOf(constructor) if cType.Kind() != reflect.Func { - return fmt.Errorf("config constructor must be a function") + return errors.New("config constructor must be a function") } if cType.NumIn() != 1 || cType.In(0) != reflect.TypeOf(&corev1.ConfigMap{}) { - return fmt.Errorf("config constructor must be of the type func(*k8s.io/api/core/v1/ConfigMap) (..., error)") + return errors.New("config constructor must be of the type func(*k8s.io/api/core/v1/ConfigMap) (..., error)") } errorType := reflect.TypeOf((*error)(nil)).Elem() if cType.NumOut() != 2 || !cType.Out(1).Implements(errorType) { - return fmt.Errorf("config constructor must be of the type func(*k8s.io/api/core/v1/ConfigMap) (..., error)") + return errors.New("config constructor must be of the type func(*k8s.io/api/core/v1/ConfigMap) (..., error)") } return nil } diff --git a/vendor/knative.dev/pkg/configmap/informer/synced_callback.go b/vendor/knative.dev/pkg/configmap/informer/synced_callback.go index 0b3e2d3a9aa..80e776aa906 100644 --- a/vendor/knative.dev/pkg/configmap/informer/synced_callback.go +++ b/vendor/knative.dev/pkg/configmap/informer/synced_callback.go @@ -17,10 +17,10 @@ limitations under the License. package informer import ( + "context" "sync" "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/apimachinery/pkg/util/wait" ) // namedWaitGroup is used to increment and decrement a WaitGroup by name @@ -107,6 +107,6 @@ func (s *syncedCallback) WaitForAllKeys(stopCh <-chan struct{}) error { case <-c: return nil case <-stopCh: - return wait.ErrWaitTimeout + return context.DeadlineExceeded } } diff --git a/vendor/knative.dev/pkg/controller/controller.go b/vendor/knative.dev/pkg/controller/controller.go index bc7c4be495a..152d837d6d6 100644 --- a/vendor/knative.dev/pkg/controller/controller.go +++ b/vendor/knative.dev/pkg/controller/controller.go @@ -224,7 +224,7 @@ type Impl struct { // ControllerOptions encapsulates options for creating a new controller, // including throttling and stats behavior. -type ControllerOptions struct { //nolint // for backcompat. +type ControllerOptions struct { WorkQueueName string Logger *zap.SugaredLogger Reporter StatsReporter @@ -482,7 +482,7 @@ func (c *Impl) RunContext(ctx context.Context, threadiness int) error { // Launch workers to process resources that get enqueued to our workqueue. c.logger.Info("Starting controller and workers") - for i := 0; i < threadiness; i++ { + for range threadiness { sg.Add(1) go func() { defer sg.Done() @@ -623,7 +623,6 @@ func IsSkipKey(err error) bool { // Is implements the Is() interface of error. It returns whether the target // error can be treated as equivalent to a permanentError. func (skipKeyError) Is(target error) bool { - //nolint: errorlint // This check is actually fine. _, ok := target.(skipKeyError) return ok } @@ -650,7 +649,6 @@ func IsPermanentError(err error) bool { // Is implements the Is() interface of error. It returns whether the target // error can be treated as equivalent to a permanentError. func (permanentError) Is(target error) bool { - //nolint: errorlint // This check is actually fine. _, ok := target.(permanentError) return ok } @@ -710,7 +708,6 @@ func IsRequeueKey(err error) (bool, time.Duration) { // Is implements the Is() interface of error. It returns whether the target // error can be treated as equivalent to a requeueKeyError. func (requeueKeyError) Is(target error) bool { - //nolint: errorlint // This check is actually fine. _, ok := target.(requeueKeyError) return ok } @@ -726,7 +723,6 @@ type Informer interface { // of them to synchronize. func StartInformers(stopCh <-chan struct{}, informers ...Informer) error { for _, informer := range informers { - informer := informer go informer.Run(stopCh) } @@ -744,7 +740,6 @@ func RunInformers(stopCh <-chan struct{}, informers ...Informer) (func(), error) var wg sync.WaitGroup wg.Add(len(informers)) for _, informer := range informers { - informer := informer go func() { defer wg.Done() informer.Run(stopCh) @@ -762,8 +757,8 @@ func RunInformers(stopCh <-chan struct{}, informers ...Informer) (func(), error) // WaitForCacheSyncQuick is the same as cache.WaitForCacheSync but with a much reduced // check-rate for the sync period. func WaitForCacheSyncQuick(stopCh <-chan struct{}, cacheSyncs ...cache.InformerSynced) bool { - err := wait.PollImmediateUntil(time.Millisecond, - func() (bool, error) { + err := wait.PollUntilContextCancel(wait.ContextForChannel(stopCh), time.Millisecond, true, + func(context.Context) (bool, error) { for _, syncFunc := range cacheSyncs { if !syncFunc() { return false, nil @@ -771,7 +766,7 @@ func WaitForCacheSyncQuick(stopCh <-chan struct{}, cacheSyncs ...cache.InformerS } return true, nil }, - stopCh) + ) return err == nil } diff --git a/vendor/knative.dev/pkg/hack/format-code.sh b/vendor/knative.dev/pkg/hack/format-code.sh new file mode 100644 index 00000000000..b9ccea8fc93 --- /dev/null +++ b/vendor/knative.dev/pkg/hack/format-code.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Copyright 2024 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. + +set -o errexit +set -o nounset +set -o pipefail + + +go run mvdan.cc/gofumpt@latest -l -w . + diff --git a/vendor/knative.dev/pkg/injection/informers.go b/vendor/knative.dev/pkg/injection/informers.go index 9356f8d7f9b..2c7a283c289 100644 --- a/vendor/knative.dev/pkg/injection/informers.go +++ b/vendor/knative.dev/pkg/injection/informers.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +//nolint:fatcontext package injection import ( @@ -93,7 +94,6 @@ func (i *impl) SetupInformers(ctx context.Context, cfg *rest.Config) (context.Co for _, fii := range i.GetFilteredInformers() { ctx, filteredinfs = fii(ctx) informers = append(informers, filteredinfs...) - } return ctx, informers } diff --git a/vendor/knative.dev/pkg/kmeta/names.go b/vendor/knative.dev/pkg/kmeta/names.go index 963b121d29f..0977544c8ca 100644 --- a/vendor/knative.dev/pkg/kmeta/names.go +++ b/vendor/knative.dev/pkg/kmeta/names.go @@ -18,6 +18,7 @@ package kmeta import ( "crypto/md5" //nolint:gosec // No strong cryptography needed. + "encoding/hex" "fmt" "regexp" ) @@ -53,7 +54,7 @@ func ChildName(parent, suffix string) string { // Format the return string, if it's shorter than longest: pad with // beginning of the suffix. This happens, for example, when parent is // short, but the suffix is very long. - ret := parent + fmt.Sprintf("%x", h) + ret := parent + hex.EncodeToString(h[:]) if d := longest - len(ret); d > 0 { ret += suffix[:d] } diff --git a/vendor/knative.dev/pkg/leaderelection/chaosduck/main.go b/vendor/knative.dev/pkg/leaderelection/chaosduck/main.go index 3125d8e3b9d..1e9420f53be 100644 --- a/vendor/knative.dev/pkg/leaderelection/chaosduck/main.go +++ b/vendor/knative.dev/pkg/leaderelection/chaosduck/main.go @@ -153,7 +153,6 @@ func main() { continue } - name, leaders := name, leaders eg.Go(func() error { return quack(ctx, kc, name, leaders) }) diff --git a/vendor/knative.dev/pkg/leaderelection/context.go b/vendor/knative.dev/pkg/leaderelection/context.go index 4cd6830639c..15f9376ed9f 100644 --- a/vendor/knative.dev/pkg/leaderelection/context.go +++ b/vendor/knative.dev/pkg/leaderelection/context.go @@ -133,9 +133,6 @@ func (b *standardBuilder) buildElector(ctx context.Context, la reconciler.Leader bkts := newStandardBuckets(queueName, b.lec) electors := make([]Elector, 0, b.lec.Buckets) for _, bkt := range bkts { - // Use a local var which won't change across the for loop since it is - // used in a callback asynchronously. - bkt := bkt rl, err := resourcelock.New(knativeResourceLock, system.Namespace(), // use namespace we are running in bkt.Name(), @@ -192,7 +189,7 @@ func newStandardBuckets(queueName string, cc ComponentConfig) []reconciler.Bucke } } names := make(sets.Set[string], cc.Buckets) - for i := uint32(0); i < cc.Buckets; i++ { + for i := range cc.Buckets { names.Insert(ln(i)) } @@ -239,7 +236,7 @@ func NewStatefulSetBucketAndSet(buckets int) (reconciler.Bucket, *hash.BucketSet } names := make(sets.Set[string], buckets) - for i := 0; i < buckets; i++ { + for i := range buckets { names.Insert(statefulSetPodDNS(i, ssc)) } diff --git a/vendor/knative.dev/pkg/metrics/opencensus_exporter.go b/vendor/knative.dev/pkg/metrics/opencensus_exporter.go index 59e33ab0995..8ea0f6e4197 100644 --- a/vendor/knative.dev/pkg/metrics/opencensus_exporter.go +++ b/vendor/knative.dev/pkg/metrics/opencensus_exporter.go @@ -64,7 +64,9 @@ func getFactory(defaultExporter view.Exporter, stored []ocagent.ExporterOption) // Don't create duplicate exporters for the default exporter. return defaultExporter, nil } - opts := append(stored, ocagent.WithResourceDetector( + opts := make([]ocagent.ExporterOption, 0, len(stored)+1) + opts = append(opts, stored...) + opts = append(opts, ocagent.WithResourceDetector( func(context.Context) (*resource.Resource, error) { return r, nil })) diff --git a/vendor/knative.dev/pkg/metrics/prometheus_exporter.go b/vendor/knative.dev/pkg/metrics/prometheus_exporter.go index cb5238476f3..7dfcc094d8f 100644 --- a/vendor/knative.dev/pkg/metrics/prometheus_exporter.go +++ b/vendor/knative.dev/pkg/metrics/prometheus_exporter.go @@ -42,7 +42,6 @@ func (emptyPromExporter) ExportView(viewData *view.Data) { // a signal to enrich the internal Meters with Resource information. } -// nolint: unparam // False positive of flagging the second result of this function unused. func newPrometheusExporter(config *metricsConfig, logger *zap.SugaredLogger) (view.Exporter, ResourceExporterFactory, error) { e, err := prom.NewExporter(prom.Options{Namespace: config.component}) if err != nil { diff --git a/vendor/knative.dev/pkg/metrics/resource_view.go b/vendor/knative.dev/pkg/metrics/resource_view.go index 930b389319c..d4e2c599daa 100644 --- a/vendor/knative.dev/pkg/metrics/resource_view.go +++ b/vendor/knative.dev/pkg/metrics/resource_view.go @@ -307,7 +307,7 @@ func optionForResource(r *resource.Resource) (stats.Options, error) { // If we can't create exporters but we have a Meter, return that. return mE.o, nil } - return nil, fmt.Errorf("whoops, allMeters.factory is nil") + return nil, errors.New("whoops, allMeters.factory is nil") } exporter, err := allMeters.factory(r) if err != nil { diff --git a/vendor/knative.dev/pkg/reconciler/configstore.go b/vendor/knative.dev/pkg/reconciler/configstore.go index 6b61856d566..3cbfbbffbab 100644 --- a/vendor/knative.dev/pkg/reconciler/configstore.go +++ b/vendor/knative.dev/pkg/reconciler/configstore.go @@ -33,7 +33,7 @@ var _ ConfigStore = ConfigStores{} func (stores ConfigStores) ToContext(ctx context.Context) context.Context { for _, s := range stores { - ctx = s.ToContext(ctx) + ctx = s.ToContext(ctx) //nolint:fatcontext } return ctx } diff --git a/vendor/knative.dev/pkg/reconciler/events.go b/vendor/knative.dev/pkg/reconciler/events.go index df4c366cca5..9d249bc9db5 100644 --- a/vendor/knative.dev/pkg/reconciler/events.go +++ b/vendor/knative.dev/pkg/reconciler/events.go @@ -62,7 +62,7 @@ func NewEvent(eventtype, reason, messageFmt string, args ...interface{}) Event { // ReconcilerEvent wraps the fields required for recorders to create a // kubernetes recorder Event. -type ReconcilerEvent struct { //nolint:revive // for backcompat. +type ReconcilerEvent struct { //nolint:errname EventType string Reason string Format string diff --git a/vendor/knative.dev/pkg/reconciler/testing/context.go b/vendor/knative.dev/pkg/reconciler/testing/context.go index 58b3b8d29ab..eb4d45b73c8 100644 --- a/vendor/knative.dev/pkg/reconciler/testing/context.go +++ b/vendor/knative.dev/pkg/reconciler/testing/context.go @@ -51,7 +51,7 @@ func SetupFakeContextWithCancel(t testing.TB, fs ...func(context.Context) contex ctx, c := context.WithCancel(logtesting.TestContextWithLogger(t)) ctx = controller.WithEventRecorder(ctx, record.NewFakeRecorder(1000)) for _, f := range fs { - ctx = f(ctx) + ctx = f(ctx) //nolint:fatcontext } ctx = injection.WithConfig(ctx, &rest.Config{}) diff --git a/vendor/knative.dev/pkg/reconciler/testing/table.go b/vendor/knative.dev/pkg/reconciler/testing/table.go index 18a83a2bb52..97cc921572f 100644 --- a/vendor/knative.dev/pkg/reconciler/testing/table.go +++ b/vendor/knative.dev/pkg/reconciler/testing/table.go @@ -20,6 +20,7 @@ import ( "context" "path" "reflect" + "slices" "strings" "testing" @@ -168,7 +169,8 @@ func (r *TableRow) Test(t *testing.T, factory Factory) { t.Errorf("Error capturing actions by verb: %q", err) } - effectiveOpts := append(r.CmpOpts, defaultCmpOpts...) + effectiveOpts := slices.Concat(r.CmpOpts, defaultCmpOpts) + // Previous state is used to diff resource expected state for update requests that were missed. objPrevState := make(map[string]runtime.Object, len(r.Objects)) for _, o := range r.Objects { diff --git a/vendor/knative.dev/pkg/test/helpers/name.go b/vendor/knative.dev/pkg/test/helpers/name.go index 0ceaed59430..18a93f2518b 100644 --- a/vendor/knative.dev/pkg/test/helpers/name.go +++ b/vendor/knative.dev/pkg/test/helpers/name.go @@ -19,6 +19,7 @@ package helpers import ( "math/rand" "strings" + "sync" "time" "unicode" ) @@ -32,12 +33,17 @@ const ( testNamePrefix = "Test" ) +var ( + nameRand *rand.Rand + nameMu sync.Mutex +) + func init() { // Properly seed the random number generator so RandomString() is actually random. // Otherwise, rerunning tests will generate the same names for the test resources, causing conflicts with // already existing resources. seed := time.Now().UTC().UnixNano() - rand.Seed(seed) + nameRand = rand.New(rand.NewSource(seed)) } type named interface { @@ -73,9 +79,11 @@ func AppendRandomString(prefix string) string { // RandomString will generate a random string. func RandomString() string { suffix := make([]byte, randSuffixLen) + nameMu.Lock() for i := range suffix { - suffix[i] = letterBytes[rand.Intn(len(letterBytes))] + suffix[i] = letterBytes[nameRand.Intn(len(letterBytes))] } + nameMu.Unlock() return string(suffix) } diff --git a/vendor/knative.dev/pkg/test/ingress/ingress.go b/vendor/knative.dev/pkg/test/ingress/ingress.go index 8de4052c75f..1bf38b8cc5c 100644 --- a/vendor/knative.dev/pkg/test/ingress/ingress.go +++ b/vendor/knative.dev/pkg/test/ingress/ingress.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "os" + "strconv" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -59,8 +60,8 @@ func GetIngressEndpoint(ctx context.Context, kubeClientset kubernetes.Interface, if endpointOverride != "" { return endpointOverride, func(port string) string { for _, sp := range ingress.Spec.Ports { - if fmt.Sprint(sp.Port) == port { - return fmt.Sprint(sp.NodePort) + if strconv.Itoa(int(sp.Port)) == port { + return strconv.Itoa(int(sp.NodePort)) } } return port diff --git a/vendor/knative.dev/pkg/test/logging/logging.go b/vendor/knative.dev/pkg/test/logging/logging.go index 74df6dfdeaa..0946077aa65 100644 --- a/vendor/knative.dev/pkg/test/logging/logging.go +++ b/vendor/knative.dev/pkg/test/logging/logging.go @@ -67,6 +67,8 @@ func (e *zapMetricExporter) ExportView(vd *view.Data) { // GetEmitableSpan starts and returns a trace.Span with a name that // is used by the ExportSpan method to emit the span. +// +//nolint:spancheck func GetEmitableSpan(ctx context.Context, metricName string) *trace.Span { _, span := trace.StartSpan(ctx, emitableSpanNamePrefix+metricName) return span diff --git a/vendor/knative.dev/pkg/test/logstream/v2/stream.go b/vendor/knative.dev/pkg/test/logstream/v2/stream.go index 1a37a54d2fa..9b5c42454db 100644 --- a/vendor/knative.dev/pkg/test/logstream/v2/stream.go +++ b/vendor/knative.dev/pkg/test/logstream/v2/stream.go @@ -156,7 +156,6 @@ func (s *logSource) watchPods() error { s.startForPod(p) } } - } } }() diff --git a/vendor/knative.dev/pkg/tracing/config/tracing.go b/vendor/knative.dev/pkg/tracing/config/tracing.go index 4d1831fc1bc..633ce3d4b20 100644 --- a/vendor/knative.dev/pkg/tracing/config/tracing.go +++ b/vendor/knative.dev/pkg/tracing/config/tracing.go @@ -135,12 +135,12 @@ func JSONToTracingConfig(jsonCfg string) (*Config, error) { cfg, err := NewTracingConfigFromMap(configMap) if err != nil { - return NoopConfig(), nil + return NoopConfig(), nil //nolint:nilerr } return cfg, nil } -func TracingConfigToJSON(cfg *Config) (string, error) { //nolint // for backcompat. +func TracingConfigToJSON(cfg *Config) (string, error) { if cfg == nil { return "", nil } @@ -150,7 +150,7 @@ func TracingConfigToJSON(cfg *Config) (string, error) { //nolint // for backcomp if cfg.ZipkinEndpoint != "" { out[zipkinEndpointKey] = cfg.ZipkinEndpoint } - out[debugKey] = fmt.Sprint(cfg.Debug) + out[debugKey] = strconv.FormatBool(cfg.Debug) out[sampleRateKey] = fmt.Sprint(cfg.SampleRate) jsonCfg, err := json.Marshal(out) diff --git a/vendor/knative.dev/pkg/webhook/json/decode.go b/vendor/knative.dev/pkg/webhook/json/decode.go index c8e57079074..57720e81d23 100644 --- a/vendor/knative.dev/pkg/webhook/json/decode.go +++ b/vendor/knative.dev/pkg/webhook/json/decode.go @@ -19,6 +19,7 @@ package json import ( "bytes" "encoding/json" + "errors" "io" ) @@ -95,7 +96,7 @@ func findMetadataOffsets(bites []byte) (start, end int64, err error) { for { t, err = dec.Token() - if err == io.EOF { //nolint + if errors.Is(err, io.EOF) { break } if err != nil { diff --git a/vendor/knative.dev/pkg/webhook/psbinding/reconciler.go b/vendor/knative.dev/pkg/webhook/psbinding/reconciler.go index 233af0d389d..b7f1ba0c7e7 100644 --- a/vendor/knative.dev/pkg/webhook/psbinding/reconciler.go +++ b/vendor/knative.dev/pkg/webhook/psbinding/reconciler.go @@ -113,7 +113,7 @@ func (r *BaseReconciler) Reconcile(ctx context.Context, key string) error { namespace, name, err := cache.SplitMetaNamespaceKey(key) if err != nil { logging.FromContext(ctx).Error("invalid resource key: ", key) - return nil + return nil //nolint:nilerr } // Only the leader should reconcile binding resources. @@ -391,7 +391,6 @@ func (r *BaseReconciler) ReconcileSubject(ctx context.Context, fb Bindable, muta // For each of the referents, apply the mutation. eg := errgroup.Group{} for _, ps := range referents { - ps := ps eg.Go(func() error { // Do the binding to the pod specable. orig := ps.DeepCopy() diff --git a/vendor/knative.dev/pkg/webhook/resourcesemantics/validation/validation_admit.go b/vendor/knative.dev/pkg/webhook/resourcesemantics/validation/validation_admit.go index ed5b8349207..94093e64825 100644 --- a/vendor/knative.dev/pkg/webhook/resourcesemantics/validation/validation_admit.go +++ b/vendor/knative.dev/pkg/webhook/resourcesemantics/validation/validation_admit.go @@ -160,7 +160,8 @@ func (ac *reconciler) decodeRequestAndPrepareContext( return ctx, newObj, nil } -func validate(ctx context.Context, resource resourcesemantics.GenericCRD, req *admissionv1.AdmissionRequest) (err error, warn []error) { //nolint +//nolint:stylecheck +func validate(ctx context.Context, resource resourcesemantics.GenericCRD, req *admissionv1.AdmissionRequest) (err error, warn []error) { logger := logging.FromContext(ctx) // Only run validation for supported create and update validation. diff --git a/vendor/knative.dev/pkg/webhook/webhook.go b/vendor/knative.dev/pkg/webhook/webhook.go index e91262db2c1..e05c6f041ef 100644 --- a/vendor/knative.dev/pkg/webhook/webhook.go +++ b/vendor/knative.dev/pkg/webhook/webhook.go @@ -176,6 +176,7 @@ func New( // a new secret informer from it. secretInformer := kubeinformerfactory.Get(ctx).Core().V1().Secrets() + //nolint:gosec // operator configures TLS min version (default is 1.3) webhook.tlsConfig = &tls.Config{ MinVersion: opts.TLSMinVersion, diff --git a/vendor/modules.txt b/vendor/modules.txt index d9867624908..a0c170ce403 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1058,7 +1058,7 @@ knative.dev/hack/schema/commands knative.dev/hack/schema/docs knative.dev/hack/schema/registry knative.dev/hack/schema/schema -# knative.dev/pkg v0.0.0-20240625072707-8535fcc248ae +# knative.dev/pkg v0.0.0-20240626134149-3f6a546ac3a4 ## explicit; go 1.22 knative.dev/pkg/apiextensions/storageversion knative.dev/pkg/apiextensions/storageversion/cmd/migrate