From 1b8531e578e51f6b178273b30707ae5aa0fc9520 Mon Sep 17 00:00:00 2001 From: Jintao Zhang Date: Fri, 10 May 2024 02:12:31 +0800 Subject: [PATCH 1/5] chore(deps): group update k8s.io to v0.30.0 and controller-runtime to v0.18.2 Signed-off-by: Jintao Zhang --- controllers/license/konglicense_controller.go | 42 +- go.mod | 73 +-- go.sum | 161 +++-- .../generators/controllers/networking/main.go | 57 +- .../configuration/kongadminapi_controller.go | 32 +- .../kongupstreampolicy_controller.go | 99 ++- .../configuration/secret_controller.go | 33 +- .../configuration/zz_generated_controllers.go | 585 +++++++++--------- .../controllers/crds/dynamic_controller.go | 32 +- .../controllers/gateway/gateway_controller.go | 99 ++- .../gateway/gatewayclass_controller.go | 35 +- .../gateway/grpcroute_controller.go | 95 ++- .../gateway/httproute_controller.go | 104 ++-- .../gateway/referencegrant_controller.go | 30 +- .../gateway/tcproute_controller.go | 94 ++- .../gateway/tlsroute_controller.go | 90 ++- .../gateway/udproute_controller.go | 94 ++- 17 files changed, 814 insertions(+), 941 deletions(-) diff --git a/controllers/license/konglicense_controller.go b/controllers/license/konglicense_controller.go index 0d782f0f6b..24c6ac4d29 100644 --- a/controllers/license/konglicense_controller.go +++ b/controllers/license/konglicense_controller.go @@ -18,6 +18,7 @@ import ( k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/cache" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" @@ -129,34 +130,33 @@ func kongLicenseKeyFunc(obj interface{}) (string, error) { // SetupWithManager sets up the controller with the Manager. func (r *KongV1Alpha1KongLicenseReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongV1Alpha1KongLicense", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + Named("KongV1Alpha1KongLicense"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) + // if configured, start the status updater controller if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ + blder.WatchesRawSource( + source.Channel(r.StatusQueue.Subscribe(schema.GroupVersionKind{ Group: "configuration.konghq.com", Version: "v1alpha1", Kind: "KongLicense", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + }), + &handler.EnqueueRequestForObject{}, + ), + ) } - return c.Watch( - source.Kind(mgr.GetCache(), &kongv1alpha1.KongLicense{}), + return blder.Watches(&kongv1alpha1.KongLicense{}, &handler.EnqueueRequestForObject{}, - predicate.NewPredicateFuncs(isKongLicenseEnabled), - ) + builder.WithPredicates(predicate.NewPredicateFuncs(isKongLicenseEnabled)), + ). + Complete(r) } // SetLogger sets the logger. diff --git a/go.mod b/go.mod index 40ea2a0390..f9014e32b9 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/kong/kubernetes-ingress-controller/v3 -go 1.22 +go 1.22.0 + +toolchain go1.22.2 // TODO: this is disabled by FOSSA action doesn't support go 1.21's toolchain clause: // @@ -49,12 +51,12 @@ require ( github.com/testcontainers/testcontainers-go v0.30.0 go.uber.org/zap v1.27.0 google.golang.org/api v0.178.0 - k8s.io/api v0.29.4 - k8s.io/apiextensions-apiserver v0.29.3 - k8s.io/apimachinery v0.29.4 - k8s.io/client-go v0.29.4 - k8s.io/component-base v0.29.4 - sigs.k8s.io/controller-runtime v0.17.3 + k8s.io/api v0.30.0 + k8s.io/apiextensions-apiserver v0.30.0 + k8s.io/apimachinery v0.30.0 + k8s.io/client-go v0.30.0 + k8s.io/component-base v0.30.0 + sigs.k8s.io/controller-runtime v0.18.2 sigs.k8s.io/gateway-api v1.0.1-0.20240409212030-c57c131b49f8 sigs.k8s.io/kustomize/api v0.17.1 sigs.k8s.io/kustomize/kyaml v0.17.0 @@ -64,6 +66,9 @@ require ( require ( cloud.google.com/go/auth v0.3.0 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 // indirect + go.opentelemetry.io/otel/sdk v1.26.0 // indirect + go.opentelemetry.io/proto/otlp v1.2.0 // indirect ) require ( @@ -82,7 +87,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bombsimon/logrusr/v3 v3.1.0 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chai2010/gettext-go v1.0.2 // indirect github.com/containerd/containerd v1.7.12 // indirect github.com/containerd/log v0.1.0 // indirect @@ -92,8 +97,8 @@ require ( github.com/docker/docker v26.1.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 // indirect - github.com/emicklei/go-restful/v3 v3.11.2 // indirect - github.com/evanphx/json-patch v5.7.0+incompatible // indirect + github.com/emicklei/go-restful/v3 v3.12.0 // indirect + github.com/evanphx/json-patch v5.9.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.9.0 github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect github.com/fatih/camelcase v1.0.0 // indirect @@ -106,9 +111,9 @@ require ( github.com/go-errors/errors v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect - github.com/go-openapi/jsonpointer v0.20.2 // indirect - github.com/go-openapi/jsonreference v0.20.4 // indirect - github.com/go-openapi/swag v0.22.7 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.21.0 // indirect + github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -160,16 +165,14 @@ require ( github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/onsi/ginkgo v1.16.4 // indirect - github.com/onsi/ginkgo/v2 v2.15.0 // indirect - github.com/onsi/gomega v1.31.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect - github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/procfs v0.14.0 // indirect github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil/v3 v3.24.3 // indirect @@ -191,28 +194,28 @@ require ( github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/otel v1.24.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect + go.opentelemetry.io/otel v1.26.0 // indirect + go.opentelemetry.io/otel/metric v1.26.0 // indirect + go.opentelemetry.io/otel/trace v1.26.0 // indirect go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect go.uber.org/multierr v1.11.0 // indirect go4.org/netipx v0.0.0-20230728184502-ec4c8b891b28 // indirect - golang.org/x/crypto v0.22.0 // indirect - golang.org/x/exp v0.0.0-20231226003508-02704c960a9b // indirect - golang.org/x/mod v0.16.0 // indirect - golang.org/x/net v0.24.0 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.25.0 // indirect golang.org/x/oauth2 v0.20.0 // indirect golang.org/x/sync v0.7.0 - golang.org/x/sys v0.19.0 // indirect - golang.org/x/term v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/term v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/tools v0.21.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240429193739-8cf5692501f6 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae // indirect google.golang.org/grpc v1.63.2 google.golang.org/protobuf v1.34.1 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect @@ -220,10 +223,10 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/cli-runtime v0.29.4 - k8s.io/klog/v2 v2.120.0 // indirect - k8s.io/kube-openapi v0.0.0-20240105020646-a37d4de58910 // indirect + k8s.io/klog/v2 v2.120.1 // indirect + k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f // indirect k8s.io/kubectl v0.29.4 - k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect + k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 // indirect sigs.k8s.io/e2e-framework v0.3.1-0.20231113122213-262cac32d35e sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/kind v0.22.0 // indirect diff --git a/go.sum b/go.sum index 31a14a2a47..729ecd454a 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,6 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= -github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= @@ -55,8 +53,8 @@ github.com/bombsimon/logrusr/v3 v3.1.0/go.mod h1:PksPPgSFEL2I52pla2glgCyyd2OqOHA github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk= github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -86,14 +84,14 @@ github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/emicklei/go-restful/v3 v3.11.2 h1:1onLa9DcsMYO9P+CXaL0dStDqQ2EHHXLiz+BtnqkLAU= -github.com/emicklei/go-restful/v3 v3.11.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.12.0 h1:y2DdzBAURM29NFF94q6RaY4vjIH1rtwDapwQtU84iWk= +github.com/emicklei/go-restful/v3 v3.12.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ2tG6yudJd8LBksgI= -github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls= +github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= @@ -129,15 +127,16 @@ github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= -github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q= -github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= -github.com/go-openapi/jsonreference v0.20.4 h1:bKlDxQxQJgwpUSgOENiMPzCTBVuc7vTdXSSgNeAhojU= -github.com/go-openapi/jsonreference v0.20.4/go.mod h1:5pZJyJP2MnYCpoeoMAql78cCHauHj0V9Lhc506VOpw4= -github.com/go-openapi/swag v0.22.7 h1:JWrc1uc/P9cSomxfnsFSVWoE1FW6bNbrVPmpQYpCcR8= -github.com/go-openapi/swag v0.22.7/go.mod h1:Gl91UqO+btAM0plGGxHqJcQZ1ZTy6jbmridBTsDy8A0= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= +github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-task/slim-sprig v2.20.0+incompatible h1:4Xh3bDzO29j4TWNOI+24ubc0vbVFMg2PMnXKxK54/CA= -github.com/go-task/slim-sprig v2.20.0+incompatible/go.mod h1:N/mhXZITr/EQAOErEHciKvO1bFei2Lld2Ym6h96pdy0= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -182,8 +181,8 @@ github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 h1:pUa4ghanp6q4IJHwE9RwLgmVFfReJN+KbQ8ExNEUUoQ= -github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= +github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2/go.mod h1:Tv1PlzqC9t8wNnpPdctvtSUOPUUg4SHeE6vR1Ir2hmg= @@ -203,8 +202,8 @@ github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZH github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= @@ -333,12 +332,12 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= -github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= +github.com/onsi/ginkgo/v2 v2.17.2 h1:7eMhcy3GimbsA3hEnVKdw/PQM9XN9krpKVXsZdph0/g= +github.com/onsi/ginkgo/v2 v2.17.2/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo= -github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0= +github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= +github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= @@ -360,12 +359,12 @@ github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b/go.mod h1:Om github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+aLCE= github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/procfs v0.14.0 h1:Lw4VdGGoKEZilJsayHf0B+9YgLGREba2C6xr+Fdfq6s= +github.com/prometheus/procfs v0.14.0/go.mod h1:XL+Iwz8k8ZabyZfMFHPiilCniixqQarAy5Mu67pHlNQ= github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU= github.com/puzpuzpuz/xsync/v2 v2.5.1/go.mod h1:gD2H2krq/w52MfPLE+Uy64TzJDVY7lP2znR9qmR35kU= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= @@ -455,24 +454,24 @@ github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 h1:A3SayB3rNyt+1S6qpI9mHPkeHTZbD7XILEqWnYZb2l0= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0/go.mod h1:27iA5uvhuRNmalO+iEUdVn5ZMj2qy10Mm+XRIpRmyuU= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 h1:Xs2Ncz0gNihqu9iosIZ5SkBbWo5T8JhhLJFMQL1qmLI= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0/go.mod h1:vy+2G/6NvVMpwGX/NyLqcC41fxepnuKHk16E6IZUcJc= +go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= +go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0 h1:1u/AyyOqAWzy+SkPxDpahCNZParHV8Vid1RnI2clyDE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.26.0/go.mod h1:z46paqbJ9l7c9fIPCXTqTGwhQZ5XoTIsfeFYWboizjs= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0 h1:FyjCyI9jVEfqhUh2MoSkmolPjfh5fp2hnV0b0irxH4Q= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0/go.mod h1:hYwym2nDEeZfG/motx0p7L7J1N1vyzIThemQsb4g2qY= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= -go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= -go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30= +go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4= +go.opentelemetry.io/otel/sdk v1.26.0 h1:Y7bumHf5tAiDlRYFmGqetNcLaVUZmh4iYfmGxtmz7F8= +go.opentelemetry.io/otel/sdk v1.26.0/go.mod h1:0p8MXpqLeJ0pzcszQQN4F0S5FVjBLgypeGSngLsmirs= +go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= +go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= +go.opentelemetry.io/proto/otlp v1.2.0 h1:pVeZGk7nXDC9O2hncA6nHldxEjm6LByfA2aN8IOkz94= +go.opentelemetry.io/proto/otlp v1.2.0/go.mod h1:gGpR8txAl5M03pDhMC79G6SdqNV26naRm/KDsgaHD8A= go.starlark.net v0.0.0-20230525235612-a134d8f9ddca h1:VdD38733bfYv5tUZwEIskMM93VanwNIi5bIKnDrJdEY= go.starlark.net v0.0.0-20230525235612-a134d8f9ddca/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= @@ -488,19 +487,19 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231226003508-02704c960a9b h1:kLiC65FbiHWFAOu+lxwNPujcsl8VYyTYYEZnsOO1WK4= -golang.org/x/exp v0.0.0-20231226003508-02704c960a9b/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= +golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= -golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -516,8 +515,8 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= @@ -558,20 +557,20 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -584,8 +583,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= +golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -599,10 +598,10 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto/googleapis/api v0.0.0-20240429193739-8cf5692501f6 h1:DTJM0R8LECCgFeUwApvcEJHz85HLagW8uRENYxHh1ww= -google.golang.org/genproto/googleapis/api v0.0.0-20240429193739-8cf5692501f6/go.mod h1:10yRODfgim2/T8csjQsMPgZOMvtytXKTDRzH6HRGzRw= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 h1:DujSIu+2tC9Ht0aPNA7jgj23Iq8Ewi5sgkQ++wdvonE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae h1:AH34z6WAGVNkllnKs5raNq3yRq93VnjBG6rpfub/jYk= +google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:FfiGhwUm6CJviekPrc0oJ+7h29e+DmWU6UtjX0ZvI7Y= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae h1:c55+MER4zkBS14uJhSZMGGmya0yJx5iHV4x/fpOSNRk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= @@ -646,28 +645,28 @@ gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -k8s.io/api v0.29.4 h1:WEnF/XdxuCxdG3ayHNRR8yH3cI1B/llkWBma6bq4R3w= -k8s.io/api v0.29.4/go.mod h1:DetSv0t4FBTcEpfA84NJV3g9a7+rSzlUHk5ADAYHUv0= -k8s.io/apiextensions-apiserver v0.29.3 h1:9HF+EtZaVpFjStakF4yVufnXGPRppWFEQ87qnO91YeI= -k8s.io/apiextensions-apiserver v0.29.3/go.mod h1:po0XiY5scnpJfFizNGo6puNU6Fq6D70UJY2Cb2KwAVc= -k8s.io/apimachinery v0.29.4 h1:RaFdJiDmuKs/8cm1M6Dh1Kvyh59YQFDcFuFTSmXes6Q= -k8s.io/apimachinery v0.29.4/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y= +k8s.io/api v0.30.0 h1:siWhRq7cNjy2iHssOB9SCGNCl2spiF1dO3dABqZ8niA= +k8s.io/api v0.30.0/go.mod h1:OPlaYhoHs8EQ1ql0R/TsUgaRPhpKNxIMrKQfWUp8QSE= +k8s.io/apiextensions-apiserver v0.30.0 h1:jcZFKMqnICJfRxTgnC4E+Hpcq8UEhT8B2lhBcQ+6uAs= +k8s.io/apiextensions-apiserver v0.30.0/go.mod h1:N9ogQFGcrbWqAY9p2mUAL5mGxsLqwgtUce127VtRX5Y= +k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA= +k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= k8s.io/cli-runtime v0.29.4 h1:QvUrddBxVX6XFJ6z64cGpEk7e4bQduKweqbqq+qBd9g= k8s.io/cli-runtime v0.29.4/go.mod h1:NmklYuZ4DLfOr2XEIT8Nzl883KMZUCv7KMj3wMHayCA= -k8s.io/client-go v0.29.4 h1:79ytIedxVfyXV8rpH3jCBW0u+un0fxHDwX5F9K8dPR8= -k8s.io/client-go v0.29.4/go.mod h1:kC1thZQ4zQWYwldsfI088BbK6RkxK+aF5ebV8y9Q4tk= -k8s.io/component-base v0.29.4 h1:xeKzuuHI/1tjleu5jycDAcYbhAxeGHCQBZUY2eRIkOo= -k8s.io/component-base v0.29.4/go.mod h1:pYjt+oEZP9gtmwSikwAJgfSBikqKX2gOqRat0QjmQt0= -k8s.io/klog/v2 v2.120.0 h1:z+q5mfovBj1fKFxiRzsa2DsJLPIVMk/KFL81LMOfK+8= -k8s.io/klog/v2 v2.120.0/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20240105020646-a37d4de58910 h1:1Rp/XEKP5uxPs6QrsngEHAxBjaAR78iJRiJq5Fi7LSU= -k8s.io/kube-openapi v0.0.0-20240105020646-a37d4de58910/go.mod h1:Pa1PvrP7ACSkuX6I7KYomY6cmMA0Tx86waBhDUgoKPw= +k8s.io/client-go v0.30.0 h1:sB1AGGlhY/o7KCyCEQ0bPWzYDL0pwOZO4vAtTSh/gJQ= +k8s.io/client-go v0.30.0/go.mod h1:g7li5O5256qe6TYdAMyX/otJqMhIiGgTapdLchhmOaY= +k8s.io/component-base v0.30.0 h1:cj6bp38g0ainlfYtaOQuRELh5KSYjhKxM+io7AUIk4o= +k8s.io/component-base v0.30.0/go.mod h1:V9x/0ePFNaKeKYA3bOvIbrNoluTSG+fSJKjLdjOoeXQ= +k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= +k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f h1:0LQagt0gDpKqvIkAMPaRGcXawNMouPECM1+F9BVxEaM= +k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f/go.mod h1:S9tOR0FxgyusSNR+MboCuiDpVWkAifZvaYI1Q2ubgro= k8s.io/kubectl v0.29.4 h1:2LFrAznoDZjN8JFMSUcuhER5o+yjTLzWWbOiDzVjmd8= k8s.io/kubectl v0.29.4/go.mod h1:YTKRF9y1/ccqZ2bnpOWaJD8V7johKqZR/qOMq+0pfxU= -k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= -k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.17.3 h1:65QmN7r3FWgTxDMz9fvGnO1kbf2nu+acg9p2R9oYYYk= -sigs.k8s.io/controller-runtime v0.17.3/go.mod h1:N0jpP5Lo7lMTF9aL56Z/B2oWBJjey6StQM0jRbKQXtY= +k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 h1:jgGTlFYnhF1PM1Ax/lAlxUPE+KfCIXHaathvJg1C3ak= +k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/controller-runtime v0.18.2 h1:RqVW6Kpeaji67CY5nPEfRz6ZfFMk0lWQlNrLqlNpx+Q= +sigs.k8s.io/controller-runtime v0.18.2/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw= sigs.k8s.io/e2e-framework v0.3.1-0.20231113122213-262cac32d35e h1:lJqSZb2bAyfkPpBhUbzXsoAHKJn+3/KzBpvktR1wlMQ= sigs.k8s.io/e2e-framework v0.3.1-0.20231113122213-262cac32d35e/go.mod h1:VIozg+of0zhkVGZcCWvKqH7vn7GTDDAa3h+w1OfH7Co= sigs.k8s.io/gateway-api v1.0.1-0.20240409212030-c57c131b49f8 h1:5oIx2TXIMN7ijoQuKsOFordYU1/pwq+Qi0nV1a8Lhi4= diff --git a/hack/generators/controllers/networking/main.go b/hack/generators/controllers/networking/main.go index 3adcc5ef1d..124764c512 100644 --- a/hack/generators/controllers/networking/main.go +++ b/hack/generators/controllers/networking/main.go @@ -454,6 +454,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" k8stypes "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" @@ -516,52 +517,48 @@ var _ controllers.Reconciler = &{{.PackageAlias}}{{.Kind}}Reconciler{} // SetupWithManager sets up the controller with the Manager. func (r *{{.PackageAlias}}{{.Kind}}Reconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("{{.PackageAlias}}{{.Kind}}", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("{{.PackageAlias}}{{.Kind}}"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) {{- if .ConfigStatusNotificationsEnabled }} // if configured, start the status updater controller if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: "{{.Group}}", - Version: "{{.Version}}", - Kind: "{{.Kind}}", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: "{{.Group}}", + Version: "{{.Version}}", + Kind: "{{.Kind}}", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } {{- end}} {{- if .AcceptsIngressClassNameAnnotation}} if !r.DisableIngressClassLookups { - err = c.Watch( - source.Kind(mgr.GetCache(), &netv1.IngressClass{}), + blder.Watches(&netv1.IngressClass{}, handler.EnqueueRequestsFromMapFunc(r.listClassless), - predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass), + builder.WithPredicates(predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass)), ) - if err != nil { - return err - } } preds := ctrlutils.GeneratePredicateFuncsForIngressClassFilter(r.IngressClassName) {{- end}} - return c.Watch( - source.Kind(mgr.GetCache(), &{{.PackageImportAlias}}.{{.Kind}}{}), + return blder.Watches(&{{.PackageImportAlias}}.{{.Kind}}{}, &handler.EnqueueRequestForObject{}, {{- if .AcceptsIngressClassNameAnnotation}} - preds, + builder.WithPredicates(preds), {{- end}} - ) + ). + Complete(r) } {{- if .AcceptsIngressClassNameAnnotation}} diff --git a/internal/controllers/configuration/kongadminapi_controller.go b/internal/controllers/configuration/kongadminapi_controller.go index 06cd0c6de0..7ccbb68a8a 100644 --- a/internal/controllers/configuration/kongadminapi_controller.go +++ b/internal/controllers/configuration/kongadminapi_controller.go @@ -13,12 +13,12 @@ import ( k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" "github.com/kong/kubernetes-ingress-controller/v3/internal/adminapi" "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers" @@ -59,26 +59,26 @@ var _ controllers.Reconciler = &KongAdminAPIServiceReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *KongAdminAPIServiceReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongAdminAPIEndpoints", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } if r.Cache == nil { r.Cache = make(DiscoveredAdminAPIsCache) } - return c.Watch( - source.Kind(mgr.GetCache(), &discoveryv1.EndpointSlice{}), - &handler.EnqueueRequestForObject{}, - predicate.NewPredicateFuncs(r.shouldReconcileEndpointSlice), - ) + return ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("KongAdminAPIEndpoints"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + Watches(&discoveryv1.EndpointSlice{}, + &handler.EnqueueRequestForObject{}, + builder.WithPredicates(predicate.NewPredicateFuncs(r.shouldReconcileEndpointSlice)), + ). + Complete(r) } // SetLogger sets the logger. diff --git a/internal/controllers/configuration/kongupstreampolicy_controller.go b/internal/controllers/configuration/kongupstreampolicy_controller.go index 9ca17c6119..5e9ecbc3f7 100644 --- a/internal/controllers/configuration/kongupstreampolicy_controller.go +++ b/internal/controllers/configuration/kongupstreampolicy_controller.go @@ -12,6 +12,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" k8stypes "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" @@ -51,84 +52,66 @@ type KongUpstreamPolicyReconciler struct { // SetupWithManager sets up the controller with the Manager. func (r *KongUpstreamPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongUpstreamPolicy", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - if err := r.setupIndices(mgr); err != nil { return err } - if err := c.Watch( - source.Kind(mgr.GetCache(), &corev1.Service{}), - handler.EnqueueRequestsFromMapFunc(r.getUpstreamPolicyForObject), - predicate.NewPredicateFuncs(doesObjectReferUpstreamPolicy), - ); err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + Named("KongUpstreamPolicy"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + Watches(&corev1.Service{}, + handler.EnqueueRequestsFromMapFunc(r.getUpstreamPolicyForObject), + builder.WithPredicates(predicate.NewPredicateFuncs(doesObjectReferUpstreamPolicy)), + ) if r.HTTPRouteEnabled { // Watch for HTTPRoute changes to trigger reconciliation for the KongUpstreamPolicies referenced by the Services // of the HTTPRoute. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.HTTPRoute{}), + blder.Watches(&gatewayapi.HTTPRoute{}, handler.EnqueueRequestsFromMapFunc(r.getUpstreamPoliciesForHTTPRouteServices), - ); err != nil { - return err - } + ) } if r.KongServiceFacadeEnabled { - if err := c.Watch( - source.Kind(mgr.GetCache(), &incubatorv1alpha1.KongServiceFacade{}), + blder.Watches(&incubatorv1alpha1.KongServiceFacade{}, handler.EnqueueRequestsFromMapFunc(r.getUpstreamPolicyForObject), - predicate.NewPredicateFuncs(doesObjectReferUpstreamPolicy), - ); err != nil { - return err - } - } - - if err := c.Watch( - source.Kind(mgr.GetCache(), &kongv1beta1.KongUpstreamPolicy{}), - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err + builder.WithPredicates(predicate.NewPredicateFuncs(doesObjectReferUpstreamPolicy)), + ) } if r.StatusQueue != nil { // Watch for notifications on the status queue from Services and KongServiceFacades as their status change // needs to be propagated to the KongUpstreamPolicy's ancestor Programmed status. - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Version: "v1", - Kind: "Service", - })}, - handler.EnqueueRequestsFromMapFunc(r.getUpstreamPolicyForObject), - predicate.NewPredicateFuncs(doesObjectReferUpstreamPolicy), - ); err != nil { - return err - } - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Version: incubatorv1alpha1.SchemeGroupVersion.Version, - Group: incubatorv1alpha1.SchemeGroupVersion.Group, - Kind: incubatorv1alpha1.KongServiceFacadeKind, - })}, - handler.EnqueueRequestsFromMapFunc(r.getUpstreamPolicyForObject), - predicate.NewPredicateFuncs(doesObjectReferUpstreamPolicy), - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Version: "v1", + Kind: "Service", + }), + handler.EnqueueRequestsFromMapFunc(r.getUpstreamPolicyForObject), + source.WithPredicates(predicate.NewPredicateFuncs(doesObjectReferUpstreamPolicy)), + ), + ). + WatchesRawSource( + source.Channel(r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Version: incubatorv1alpha1.SchemeGroupVersion.Version, + Group: incubatorv1alpha1.SchemeGroupVersion.Group, + Kind: incubatorv1alpha1.KongServiceFacadeKind, + }), + handler.EnqueueRequestsFromMapFunc(r.getUpstreamPolicyForObject), + source.WithPredicates(predicate.NewPredicateFuncs(doesObjectReferUpstreamPolicy)), + ), + ) } - return nil + return blder.For(&kongv1beta1.KongUpstreamPolicy{}). + Complete(r) } func (r *KongUpstreamPolicyReconciler) setupIndices(mgr ctrl.Manager) error { diff --git a/internal/controllers/configuration/secret_controller.go b/internal/controllers/configuration/secret_controller.go index ad58cbefcc..66f2f43165 100644 --- a/internal/controllers/configuration/secret_controller.go +++ b/internal/controllers/configuration/secret_controller.go @@ -9,13 +9,13 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers" ctrlref "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/reference" @@ -47,25 +47,26 @@ var _ controllers.Reconciler = &CoreV1SecretReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *CoreV1SecretReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("CoreV1Secret", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } predicateFuncs := predicate.NewPredicateFuncs(r.shouldReconcileSecret) // we should always try to delete secrets in caches when they are deleted in cluster. predicateFuncs.DeleteFunc = func(_ event.DeleteEvent) bool { return true } - return c.Watch( - source.Kind(mgr.GetCache(), &corev1.Secret{}), - &handler.EnqueueRequestForObject{}, - predicateFuncs, - ) + + return ctrl.NewControllerManagedBy(mgr). + Named("CoreV1Secret"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + Watches(&corev1.Secret{}, + &handler.EnqueueRequestForObject{}, + builder.WithPredicates(predicateFuncs), + ). + Complete(r) + } // SetLogger sets the logger. diff --git a/internal/controllers/configuration/zz_generated_controllers.go b/internal/controllers/configuration/zz_generated_controllers.go index fadccec529..b91616d738 100644 --- a/internal/controllers/configuration/zz_generated_controllers.go +++ b/internal/controllers/configuration/zz_generated_controllers.go @@ -32,6 +32,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" k8stypes "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" @@ -70,20 +71,20 @@ var _ controllers.Reconciler = &CoreV1ServiceReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *CoreV1ServiceReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("CoreV1Service", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - return c.Watch( - source.Kind(mgr.GetCache(), &corev1.Service{}), + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("CoreV1Service"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) + return blder.Watches(&corev1.Service{}, &handler.EnqueueRequestForObject{}, - ) + ). + Complete(r) } // SetLogger sets the logger. @@ -175,20 +176,20 @@ var _ controllers.Reconciler = &DiscoveryV1EndpointSliceReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *DiscoveryV1EndpointSliceReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("DiscoveryV1EndpointSlice", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - return c.Watch( - source.Kind(mgr.GetCache(), &discoveryv1.EndpointSlice{}), + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("DiscoveryV1EndpointSlice"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) + return blder.Watches(&discoveryv1.EndpointSlice{}, &handler.EnqueueRequestForObject{}, - ) + ). + Complete(r) } // SetLogger sets the logger. @@ -266,45 +267,41 @@ var _ controllers.Reconciler = &NetV1IngressReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *NetV1IngressReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("NetV1Ingress", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("NetV1Ingress"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) // if configured, start the status updater controller if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: "networking.k8s.io", - Version: "v1", - Kind: "Ingress", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: "networking.k8s.io", + Version: "v1", + Kind: "Ingress", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } if !r.DisableIngressClassLookups { - err = c.Watch( - source.Kind(mgr.GetCache(), &netv1.IngressClass{}), + blder.Watches(&netv1.IngressClass{}, handler.EnqueueRequestsFromMapFunc(r.listClassless), - predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass), + builder.WithPredicates(predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass)), ) - if err != nil { - return err - } } preds := ctrlutils.GeneratePredicateFuncsForIngressClassFilter(r.IngressClassName) - return c.Watch( - source.Kind(mgr.GetCache(), &netv1.Ingress{}), + return blder.Watches(&netv1.Ingress{}, &handler.EnqueueRequestForObject{}, - preds, - ) + builder.WithPredicates(preds), + ). + Complete(r) } // listClassless finds and reconciles all objects without ingress class information @@ -462,20 +459,20 @@ var _ controllers.Reconciler = &NetV1IngressClassReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *NetV1IngressClassReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("NetV1IngressClass", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - return c.Watch( - source.Kind(mgr.GetCache(), &netv1.IngressClass{}), + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("NetV1IngressClass"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) + return blder.Watches(&netv1.IngressClass{}, &handler.EnqueueRequestForObject{}, - ) + ). + Complete(r) } // SetLogger sets the logger. @@ -546,20 +543,20 @@ var _ controllers.Reconciler = &KongV1KongIngressReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *KongV1KongIngressReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongV1KongIngress", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - return c.Watch( - source.Kind(mgr.GetCache(), &kongv1.KongIngress{}), + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("KongV1KongIngress"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) + return blder.Watches(&kongv1.KongIngress{}, &handler.EnqueueRequestForObject{}, - ) + ). + Complete(r) } // SetLogger sets the logger. @@ -632,20 +629,20 @@ var _ controllers.Reconciler = &KongV1KongPluginReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *KongV1KongPluginReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongV1KongPlugin", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - return c.Watch( - source.Kind(mgr.GetCache(), &kongv1.KongPlugin{}), + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("KongV1KongPlugin"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) + return blder.Watches(&kongv1.KongPlugin{}, &handler.EnqueueRequestForObject{}, - ) + ). + Complete(r) } // SetLogger sets the logger. @@ -741,32 +738,28 @@ var _ controllers.Reconciler = &KongV1KongClusterPluginReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *KongV1KongClusterPluginReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongV1KongClusterPlugin", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("KongV1KongClusterPlugin"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) if !r.DisableIngressClassLookups { - err = c.Watch( - source.Kind(mgr.GetCache(), &netv1.IngressClass{}), + blder.Watches(&netv1.IngressClass{}, handler.EnqueueRequestsFromMapFunc(r.listClassless), - predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass), + builder.WithPredicates(predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass)), ) - if err != nil { - return err - } } preds := ctrlutils.GeneratePredicateFuncsForIngressClassFilter(r.IngressClassName) - return c.Watch( - source.Kind(mgr.GetCache(), &kongv1.KongClusterPlugin{}), + return blder.Watches(&kongv1.KongClusterPlugin{}, &handler.EnqueueRequestForObject{}, - preds, - ) + builder.WithPredicates(preds), + ). + Complete(r) } // listClassless finds and reconciles all objects without ingress class information @@ -904,45 +897,41 @@ var _ controllers.Reconciler = &KongV1KongConsumerReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *KongV1KongConsumerReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongV1KongConsumer", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("KongV1KongConsumer"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) // if configured, start the status updater controller if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: "configuration.konghq.com", - Version: "v1", - Kind: "KongConsumer", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: "configuration.konghq.com", + Version: "v1", + Kind: "KongConsumer", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } if !r.DisableIngressClassLookups { - err = c.Watch( - source.Kind(mgr.GetCache(), &netv1.IngressClass{}), + blder.Watches(&netv1.IngressClass{}, handler.EnqueueRequestsFromMapFunc(r.listClassless), - predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass), + builder.WithPredicates(predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass)), ) - if err != nil { - return err - } } preds := ctrlutils.GeneratePredicateFuncsForIngressClassFilter(r.IngressClassName) - return c.Watch( - source.Kind(mgr.GetCache(), &kongv1.KongConsumer{}), + return blder.Watches(&kongv1.KongConsumer{}, &handler.EnqueueRequestForObject{}, - preds, - ) + builder.WithPredicates(preds), + ). + Complete(r) } // listClassless finds and reconciles all objects without ingress class information @@ -1095,45 +1084,41 @@ var _ controllers.Reconciler = &KongV1Beta1KongConsumerGroupReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *KongV1Beta1KongConsumerGroupReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongV1Beta1KongConsumerGroup", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("KongV1Beta1KongConsumerGroup"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) // if configured, start the status updater controller if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: "configuration.konghq.com", - Version: "v1beta1", - Kind: "KongConsumerGroup", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: "configuration.konghq.com", + Version: "v1beta1", + Kind: "KongConsumerGroup", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } if !r.DisableIngressClassLookups { - err = c.Watch( - source.Kind(mgr.GetCache(), &netv1.IngressClass{}), + blder.Watches(&netv1.IngressClass{}, handler.EnqueueRequestsFromMapFunc(r.listClassless), - predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass), + builder.WithPredicates(predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass)), ) - if err != nil { - return err - } } preds := ctrlutils.GeneratePredicateFuncsForIngressClassFilter(r.IngressClassName) - return c.Watch( - source.Kind(mgr.GetCache(), &kongv1beta1.KongConsumerGroup{}), + return blder.Watches(&kongv1beta1.KongConsumerGroup{}, &handler.EnqueueRequestForObject{}, - preds, - ) + builder.WithPredicates(preds), + ). + Complete(r) } // listClassless finds and reconciles all objects without ingress class information @@ -1288,45 +1273,41 @@ var _ controllers.Reconciler = &KongV1Beta1TCPIngressReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *KongV1Beta1TCPIngressReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongV1Beta1TCPIngress", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("KongV1Beta1TCPIngress"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) // if configured, start the status updater controller if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: "configuration.konghq.com", - Version: "v1beta1", - Kind: "TCPIngress", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: "configuration.konghq.com", + Version: "v1beta1", + Kind: "TCPIngress", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } if !r.DisableIngressClassLookups { - err = c.Watch( - source.Kind(mgr.GetCache(), &netv1.IngressClass{}), + blder.Watches(&netv1.IngressClass{}, handler.EnqueueRequestsFromMapFunc(r.listClassless), - predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass), + builder.WithPredicates(predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass)), ) - if err != nil { - return err - } } preds := ctrlutils.GeneratePredicateFuncsForIngressClassFilter(r.IngressClassName) - return c.Watch( - source.Kind(mgr.GetCache(), &kongv1beta1.TCPIngress{}), + return blder.Watches(&kongv1beta1.TCPIngress{}, &handler.EnqueueRequestForObject{}, - preds, - ) + builder.WithPredicates(preds), + ). + Complete(r) } // listClassless finds and reconciles all objects without ingress class information @@ -1490,45 +1471,41 @@ var _ controllers.Reconciler = &KongV1Beta1UDPIngressReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *KongV1Beta1UDPIngressReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongV1Beta1UDPIngress", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("KongV1Beta1UDPIngress"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) // if configured, start the status updater controller if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: "configuration.konghq.com", - Version: "v1beta1", - Kind: "UDPIngress", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: "configuration.konghq.com", + Version: "v1beta1", + Kind: "UDPIngress", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } if !r.DisableIngressClassLookups { - err = c.Watch( - source.Kind(mgr.GetCache(), &netv1.IngressClass{}), + blder.Watches(&netv1.IngressClass{}, handler.EnqueueRequestsFromMapFunc(r.listClassless), - predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass), + builder.WithPredicates(predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass)), ) - if err != nil { - return err - } } preds := ctrlutils.GeneratePredicateFuncsForIngressClassFilter(r.IngressClassName) - return c.Watch( - source.Kind(mgr.GetCache(), &kongv1beta1.UDPIngress{}), + return blder.Watches(&kongv1beta1.UDPIngress{}, &handler.EnqueueRequestForObject{}, - preds, - ) + builder.WithPredicates(preds), + ). + Complete(r) } // listClassless finds and reconciles all objects without ingress class information @@ -1666,20 +1643,20 @@ var _ controllers.Reconciler = &KongV1Alpha1IngressClassParametersReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *KongV1Alpha1IngressClassParametersReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongV1Alpha1IngressClassParameters", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - return c.Watch( - source.Kind(mgr.GetCache(), &kongv1alpha1.IngressClassParameters{}), + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("KongV1Alpha1IngressClassParameters"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) + return blder.Watches(&kongv1alpha1.IngressClassParameters{}, &handler.EnqueueRequestForObject{}, - ) + ). + Complete(r) } // SetLogger sets the logger. @@ -1754,45 +1731,41 @@ var _ controllers.Reconciler = &IncubatorV1Alpha1KongServiceFacadeReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *IncubatorV1Alpha1KongServiceFacadeReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("IncubatorV1Alpha1KongServiceFacade", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("IncubatorV1Alpha1KongServiceFacade"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) // if configured, start the status updater controller if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: "incubator.ingress-controller.konghq.com", - Version: "v1alpha1", - Kind: "KongServiceFacade", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: "incubator.ingress-controller.konghq.com", + Version: "v1alpha1", + Kind: "KongServiceFacade", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } if !r.DisableIngressClassLookups { - err = c.Watch( - source.Kind(mgr.GetCache(), &netv1.IngressClass{}), + blder.Watches(&netv1.IngressClass{}, handler.EnqueueRequestsFromMapFunc(r.listClassless), - predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass), + builder.WithPredicates(predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass)), ) - if err != nil { - return err - } } preds := ctrlutils.GeneratePredicateFuncsForIngressClassFilter(r.IngressClassName) - return c.Watch( - source.Kind(mgr.GetCache(), &incubatorv1alpha1.KongServiceFacade{}), + return blder.Watches(&incubatorv1alpha1.KongServiceFacade{}, &handler.EnqueueRequestForObject{}, - preds, - ) + builder.WithPredicates(preds), + ). + Complete(r) } // listClassless finds and reconciles all objects without ingress class information @@ -1925,45 +1898,41 @@ var _ controllers.Reconciler = &KongV1Alpha1KongVaultReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *KongV1Alpha1KongVaultReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("KongV1Alpha1KongVault", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("KongV1Alpha1KongVault"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }) // if configured, start the status updater controller if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: "configuration.konghq.com", - Version: "v1alpha1", - Kind: "KongVault", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: "configuration.konghq.com", + Version: "v1alpha1", + Kind: "KongVault", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } if !r.DisableIngressClassLookups { - err = c.Watch( - source.Kind(mgr.GetCache(), &netv1.IngressClass{}), + blder.Watches(&netv1.IngressClass{}, handler.EnqueueRequestsFromMapFunc(r.listClassless), - predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass), + builder.WithPredicates(predicate.NewPredicateFuncs(ctrlutils.IsDefaultIngressClass)), ) - if err != nil { - return err - } } preds := ctrlutils.GeneratePredicateFuncsForIngressClassFilter(r.IngressClassName) - return c.Watch( - source.Kind(mgr.GetCache(), &kongv1alpha1.KongVault{}), + return blder.Watches(&kongv1alpha1.KongVault{}, &handler.EnqueueRequestForObject{}, - preds, - ) + builder.WithPredicates(preds), + ). + Complete(r) } // listClassless finds and reconciles all objects without ingress class information diff --git a/internal/controllers/crds/dynamic_controller.go b/internal/controllers/crds/dynamic_controller.go index 6059c13e49..18d1d27958 100644 --- a/internal/controllers/crds/dynamic_controller.go +++ b/internal/controllers/crds/dynamic_controller.go @@ -11,12 +11,12 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime/schema" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/utils" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" @@ -51,22 +51,20 @@ func (r *DynamicCRDController) SetupWithManager(mgr ctrl.Manager) error { r.Log.Info("Required CustomResourceDefinitions are not installed, setting up a watch for them in case they are installed afterward") - c, err := controller.New("DynamicCRDController", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - - return c.Watch( - source.Kind(mgr.GetCache(), &apiextensionsv1.CustomResourceDefinition{}), - &handler.EnqueueRequestForObject{}, - predicate.NewPredicateFuncs(r.isOneOfRequiredCRDs), - ) + return ctrl.NewControllerManagedBy(mgr). + Named("DynamicCRDController"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + Watches(&apiextensionsv1.CustomResourceDefinition{}, + &handler.EnqueueRequestForObject{}, + builder.WithPredicates(predicate.NewPredicateFuncs(r.isOneOfRequiredCRDs)), + ). + Complete(r) } func (r *DynamicCRDController) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { diff --git a/internal/controllers/gateway/gateway_controller.go b/internal/controllers/gateway/gateway_controller.go index 7838b1e2da..842a356bd2 100644 --- a/internal/controllers/gateway/gateway_controller.go +++ b/internal/controllers/gateway/gateway_controller.go @@ -20,12 +20,12 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" k8stypes "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" "github.com/kong/kubernetes-ingress-controller/v3/internal/annotations" @@ -89,67 +89,50 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error { Resource: "referencegrants", }) - // generate the controller object and attach it to the manager and link the reconciler object - c, err := controller.New("gateway-controller", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - - // watch Gateway objects, filtering out any Gateways which are not configured with - // a supported GatewayClass controller name. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.Gateway{}), - &handler.EnqueueRequestForObject{}, - predicate.NewPredicateFuncs(r.gatewayHasMatchingGatewayClass), - ); err != nil { - return err - } - - // watch for updates to gatewayclasses, if any gateway classes change, enqueue - // reconciliation for all supported gateway objects which reference it. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.GatewayClass{}), - handler.EnqueueRequestsFromMapFunc(r.listGatewaysForGatewayClass), - predicate.NewPredicateFuncs(r.gatewayClassMatchesController), - ); err != nil { - return err - } - - // if an update to the gateway service occurs, we need to make sure to trigger - // reconciliation on all Gateway objects referenced by it (in the most common - // deployments this will be a single Gateway). - if err := c.Watch( - source.Kind(mgr.GetCache(), &corev1.Service{}), - handler.EnqueueRequestsFromMapFunc(r.listGatewaysForService), - predicate.NewPredicateFuncs(r.isGatewayService), - ); err != nil { - return err - } - - // if a HTTPRoute gets accepted by a Gateway, we need to make sure to trigger - // reconciliation on the gateway, as we need to update the number of attachedRoutes. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.HTTPRoute{}), - handler.EnqueueRequestsFromMapFunc(r.listGatewaysForHTTPRoute), - ); err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("gateway-controller"). + // set the controller options + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + // watch Gateway objects, filtering out any Gateways which are not configured with + // a supported GatewayClass controller name. + For(&gatewayapi.Gateway{}). + WithEventFilter(predicate.NewPredicateFuncs(r.gatewayHasMatchingGatewayClass)). + // watch for updates to gatewayclasses, if any gateway classes change, enqueue + // reconciliation for all supported gateway objects which reference it. + Watches(&gatewayapi.GatewayClass{}, + handler.EnqueueRequestsFromMapFunc(r.listGatewaysForGatewayClass), + builder.WithPredicates(predicate.NewPredicateFuncs(r.gatewayClassMatchesController)), + ). + // if an update to the gateway service occurs, we need to make sure to trigger + // reconciliation on all Gateway objects referenced by it (in the most common + // deployments this will be a single Gateway). + Watches(&corev1.Service{}, + handler.EnqueueRequestsFromMapFunc(r.listGatewaysForService), + builder.WithPredicates(predicate.NewPredicateFuncs(r.isGatewayService)), + ). + // if a HTTPRoute gets accepted by a Gateway, we need to make sure to trigger + // reconciliation on the gateway, as we need to update the number of attachedRoutes. + Watches(&gatewayapi.HTTPRoute{}, + handler.EnqueueRequestsFromMapFunc(r.listGatewaysForHTTPRoute), + ) // watch ReferenceGrants, which may invalidate or allow cross-namespace TLSConfigs if r.enableReferenceGrant { - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.ReferenceGrant{}), + blder.Watches(&gatewayapi.ReferenceGrant{}, handler.EnqueueRequestsFromMapFunc(r.listReferenceGrantsForGateway), - predicate.NewPredicateFuncs(referenceGrantHasGatewayFrom), - ); err != nil { - return err - } + builder.WithPredicates(predicate.NewPredicateFuncs(referenceGrantHasGatewayFrom)), + ) + } + + if err := blder.Complete(r); err != nil { + return err } // start the required gatewayclass controller as well diff --git a/internal/controllers/gateway/gatewayclass_controller.go b/internal/controllers/gateway/gatewayclass_controller.go index c835e0f5ae..8f27cf6c70 100644 --- a/internal/controllers/gateway/gatewayclass_controller.go +++ b/internal/controllers/gateway/gatewayclass_controller.go @@ -15,10 +15,8 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" - "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" "github.com/kong/kubernetes-ingress-controller/v3/internal/gatewayapi" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" @@ -64,22 +62,23 @@ type GatewayClassReconciler struct { //nolint:revive // SetupWithManager sets up the controller with the Manager. func (r *GatewayClassReconciler) SetupWithManager(mgr ctrl.Manager) error { - name := strings.ToUpper(gatewayapi.V1GroupVersion) + "GatewayClass" - c, err := controller.New(name, mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - return c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.GatewayClass{}), - &handler.EnqueueRequestForObject{}, - predicate.NewPredicateFuncs(r.GatewayClassIsUnmanaged), - ) + + return ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named(strings.ToUpper(gatewayapi.V1GroupVersion) + "GatewayClass"). + // set the controller options + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + // watch GatewayClass objects + For(&gatewayapi.GatewayClass{}). + // set the event filters + WithEventFilter(predicate.NewPredicateFuncs(r.GatewayClassIsUnmanaged)). + Complete(r) } // ----------------------------------------------------------------------------- diff --git a/internal/controllers/gateway/grpcroute_controller.go b/internal/controllers/gateway/grpcroute_controller.go index 1770f44ec9..858ed3b14f 100644 --- a/internal/controllers/gateway/grpcroute_controller.go +++ b/internal/controllers/gateway/grpcroute_controller.go @@ -14,6 +14,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" k8stypes "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/event" @@ -55,56 +56,48 @@ type GRPCRouteReconciler struct { // SetupWithManager sets up the controller with the Manager. func (r *GRPCRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("grpcroute-controller", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - - // if a GatewayClass updates then we need to enqueue the linked GRPCRoutes to - // ensure that any route objects that may have been orphaned by that change get - // removed from data-plane configurations, and any routes that are now supported - // due to that change get added to data-plane configurations. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.GatewayClass{}), - handler.EnqueueRequestsFromMapFunc(r.listGRPCRoutesForGatewayClass), - predicate.Funcs{ - GenericFunc: func(_ event.GenericEvent) bool { return false }, // we don't need to enqueue from generic - CreateFunc: func(e event.CreateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - UpdateFunc: func(e event.UpdateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - DeleteFunc: func(e event.DeleteEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - }, - ); err != nil { - return err - } - - // if a Gateway updates then we need to enqueue the linked GRPCRoutes to - // ensure that any route objects that may have been orphaned by that change get - // removed from data-plane configurations, and any routes that are now supported - // due to that change get added to data-plane configurations. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.Gateway{}), - handler.EnqueueRequestsFromMapFunc(r.listGRPCRoutesForGateway), - ); err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("grpcroute-controller"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + // if a GatewayClass updates then we need to enqueue the linked GRPCRoutes to + // ensure that any route objects that may have been orphaned by that change get + // removed from data-plane configurations, and any routes that are now supported + // due to that change get added to data-plane configurations. + Watches(&gatewayapi.GatewayClass{}, + handler.EnqueueRequestsFromMapFunc(r.listGRPCRoutesForGatewayClass), + builder.WithPredicates(predicate.Funcs{ + GenericFunc: func(_ event.GenericEvent) bool { return false }, // we don't need to enqueue from generic + CreateFunc: func(e event.CreateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + UpdateFunc: func(e event.UpdateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + DeleteFunc: func(e event.DeleteEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + }), + ). + // if a Gateway updates then we need to enqueue the linked GRPCRoutes to + // ensure that any route objects that may have been orphaned by that change get + // removed from data-plane configurations, and any routes that are now supported + // due to that change get added to data-plane configurations. + Watches(&gatewayapi.Gateway{}, + handler.EnqueueRequestsFromMapFunc(r.listGRPCRoutesForGateway), + ) if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: gatewayv1alpha2.GroupVersion.Group, - Version: gatewayv1alpha2.GroupVersion.Version, - Kind: "GRPCRoute", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: gatewayv1alpha2.GroupVersion.Group, + Version: gatewayv1alpha2.GroupVersion.Version, + Kind: "GRPCRoute", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } // because of the additional burden of having to manage reference data-plane @@ -112,10 +105,8 @@ func (r *GRPCRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { // simply reconcile ALL GRPCRoute objects. This allows us to drop the backend // data-plane config for an GRPCRoute if it somehow becomes disconnected from // a supported Gateway and GatewayClass. - return c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.GRPCRoute{}), - &handler.EnqueueRequestForObject{}, - ) + return blder.For(&gatewayapi.GRPCRoute{}). + Complete(r) } // ----------------------------------------------------------------------------- diff --git a/internal/controllers/gateway/httproute_controller.go b/internal/controllers/gateway/httproute_controller.go index 8088a17c47..5e14ca91a5 100644 --- a/internal/controllers/gateway/httproute_controller.go +++ b/internal/controllers/gateway/httproute_controller.go @@ -17,6 +17,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" k8stypes "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/event" @@ -62,17 +63,6 @@ type HTTPRouteReconciler struct { // SetupWithManager sets up the controller with the Manager. func (r *HTTPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("httproute-controller", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - // We're verifying whether ReferenceGrant CRD is installed at setup of the HTTPRouteReconciler // to decide whether we should run additional ReferenceGrant watch and handle ReferenceGrants // when reconciling HTTPRoutes. @@ -84,55 +74,55 @@ func (r *HTTPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { Resource: "referencegrants", }) - // if a GatewayClass updates then we need to enqueue the linked HTTPRoutes to - // ensure that any route objects that may have been orphaned by that change get - // removed from data-plane configurations, and any routes that are now supported - // due to that change get added to data-plane configurations. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.GatewayClass{}), - handler.EnqueueRequestsFromMapFunc(r.listHTTPRoutesForGatewayClass), - predicate.Funcs{ - GenericFunc: func(_ event.GenericEvent) bool { return false }, // we don't need to enqueue from generic - CreateFunc: func(e event.CreateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - UpdateFunc: func(e event.UpdateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - DeleteFunc: func(e event.DeleteEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - }, - ); err != nil { - return err - } - - // if a Gateway updates then we need to enqueue the linked HTTPRoutes to - // ensure that any route objects that may have been orphaned by that change get - // removed from data-plane configurations, and any routes that are now supported - // due to that change get added to data-plane configurations. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.Gateway{}), - handler.EnqueueRequestsFromMapFunc(r.listHTTPRoutesForGateway), - ); err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("httproute-controller"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + // if a GatewayClass updates then we need to enqueue the linked HTTPRoutes to + // ensure that any route objects that may have been orphaned by that change get + // removed from data-plane configurations, and any routes that are now supported + // due to that change get added to data-plane configurations. + Watches(&gatewayapi.GatewayClass{}, + handler.EnqueueRequestsFromMapFunc(r.listHTTPRoutesForGatewayClass), + builder.WithPredicates(predicate.Funcs{ + GenericFunc: func(_ event.GenericEvent) bool { return false }, // we don't need to enqueue from generic + CreateFunc: func(e event.CreateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + UpdateFunc: func(e event.UpdateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + DeleteFunc: func(e event.DeleteEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + }), + ). + // if a Gateway updates then we need to enqueue the linked HTTPRoutes to + // ensure that any route objects that may have been orphaned by that change get + // removed from data-plane configurations, and any routes that are now supported + // due to that change get added to data-plane configurations. + Watches(&gatewayapi.Gateway{}, + handler.EnqueueRequestsFromMapFunc(r.listHTTPRoutesForGateway), + ) if r.enableReferenceGrant { - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.ReferenceGrant{}), + blder.Watches(&gatewayapi.ReferenceGrant{}, handler.EnqueueRequestsFromMapFunc(r.listReferenceGrantsForHTTPRoute), - predicate.NewPredicateFuncs(referenceGrantHasHTTPRouteFrom), - ); err != nil { - return err - } + builder.WithPredicates(predicate.NewPredicateFuncs(referenceGrantHasHTTPRouteFrom)), + ) } if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: gatewayv1.GroupVersion.Group, - Version: gatewayv1.GroupVersion.Version, - Kind: "HTTPRoute", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: gatewayv1.GroupVersion.Group, + Version: gatewayv1.GroupVersion.Version, + Kind: "HTTPRoute", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } // because of the additional burden of having to manage reference data-plane @@ -140,10 +130,8 @@ func (r *HTTPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { // simply reconcile ALL HTTPRoute objects. This allows us to drop the backend // data-plane config for an HTTPRoute if it somehow becomes disconnected from // a supported Gateway and GatewayClass. - return c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.HTTPRoute{}), - &handler.EnqueueRequestForObject{}, - ) + return blder.For(&gatewayapi.HTTPRoute{}). + Complete(r) } // ----------------------------------------------------------------------------- diff --git a/internal/controllers/gateway/referencegrant_controller.go b/internal/controllers/gateway/referencegrant_controller.go index 9e074ffd87..4de217287e 100644 --- a/internal/controllers/gateway/referencegrant_controller.go +++ b/internal/controllers/gateway/referencegrant_controller.go @@ -26,9 +26,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" - "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers" "github.com/kong/kubernetes-ingress-controller/v3/internal/gatewayapi" @@ -46,21 +44,19 @@ type ReferenceGrantReconciler struct { // SetupWithManager sets up the controller with the Manager. func (r *ReferenceGrantReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("referencegrant-controller", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - - return c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.ReferenceGrant{}), - &handler.EnqueueRequestForObject{}, - ) + return ctrl.NewControllerManagedBy(mgr). + // set the controller name + Named("referencegrant-controller"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + // watch Referencegrant objects + For(&gatewayapi.ReferenceGrant{}). + Complete(r) } // +kubebuilder:rbac:groups=gateway.networking.k8s.io,resources=referencegrants,verbs=get;list;watch diff --git a/internal/controllers/gateway/tcproute_controller.go b/internal/controllers/gateway/tcproute_controller.go index bfeb2f5288..9fc5f6d442 100644 --- a/internal/controllers/gateway/tcproute_controller.go +++ b/internal/controllers/gateway/tcproute_controller.go @@ -14,6 +14,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" k8stypes "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/event" @@ -52,56 +53,47 @@ type TCPRouteReconciler struct { // SetupWithManager sets up the controller with the Manager. func (r *TCPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("tcproute-controller", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - - // if a GatewayClass updates then we need to enqueue the linked TCPRoutes to - // ensure that any route objects that may have been orphaned by that change get - // removed from data-plane configurations, and any routes that are now supported - // due to that change get added to data-plane configurations. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.GatewayClass{}), - handler.EnqueueRequestsFromMapFunc(r.listTCPRoutesForGatewayClass), - predicate.Funcs{ - GenericFunc: func(_ event.GenericEvent) bool { return false }, // we don't need to enqueue from generic - CreateFunc: func(e event.CreateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - UpdateFunc: func(e event.UpdateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - DeleteFunc: func(e event.DeleteEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - }, - ); err != nil { - return err - } - - // if a Gateway updates then we need to enqueue the linked TCPRoutes to - // ensure that any route objects that may have been orphaned by that change get - // removed from data-plane configurations, and any routes that are now supported - // due to that change get added to data-plane configurations. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.Gateway{}), - handler.EnqueueRequestsFromMapFunc(r.listTCPRoutesForGateway), - ); err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + Named("tcproute-controller"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + // if a GatewayClass updates then we need to enqueue the linked TCPRoutes to + // ensure that any route objects that may have been orphaned by that change get + // removed from data-plane configurations, and any routes that are now supported + // due to that change get added to data-plane configurations. + Watches(&gatewayapi.GatewayClass{}, + handler.EnqueueRequestsFromMapFunc(r.listTCPRoutesForGatewayClass), + builder.WithPredicates(predicate.Funcs{ + GenericFunc: func(_ event.GenericEvent) bool { return false }, // we don't need to enqueue from generic + CreateFunc: func(e event.CreateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + UpdateFunc: func(e event.UpdateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + DeleteFunc: func(e event.DeleteEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + }), + ). + // if a Gateway updates then we need to enqueue the linked TCPRoutes to + // ensure that any route objects that may have been orphaned by that change get + // removed from data-plane configurations, and any routes that are now supported + // due to that change get added to data-plane configurations. + Watches(&gatewayapi.Gateway{}, + handler.EnqueueRequestsFromMapFunc(r.listTCPRoutesForGateway), + ) if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: gatewayv1alpha2.GroupVersion.Group, - Version: gatewayv1alpha2.GroupVersion.Version, - Kind: "TCPRoute", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: gatewayv1alpha2.GroupVersion.Group, + Version: gatewayv1alpha2.GroupVersion.Version, + Kind: "TCPRoute", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } // because of the additional burden of having to manage reference data-plane @@ -109,10 +101,8 @@ func (r *TCPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { // simply reconcile ALL TCPRoute objects. This allows us to drop the backend // data-plane config for an TCPRoute if it somehow becomes disconnected from // a supported Gateway and GatewayClass. - return c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.TCPRoute{}), - &handler.EnqueueRequestForObject{}, - ) + return blder.For(&gatewayapi.TCPRoute{}). + Complete(r) } // ----------------------------------------------------------------------------- diff --git a/internal/controllers/gateway/tlsroute_controller.go b/internal/controllers/gateway/tlsroute_controller.go index 7937ba648a..d97ff392f9 100644 --- a/internal/controllers/gateway/tlsroute_controller.go +++ b/internal/controllers/gateway/tlsroute_controller.go @@ -14,6 +14,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" k8stypes "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/event" @@ -51,56 +52,43 @@ type TLSRouteReconciler struct { // SetupWithManager sets up the controller with the Manager. func (r *TLSRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("tlsroute-controller", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - - // if a GatewayClass updates then we need to enqueue the linked TLSRoutes to - // ensure that any route objects that may have been orphaned by that change get - // removed from data-plane configurations, and any routes that are now supported - // due to that change get added to data-plane configurations. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.GatewayClass{}), - handler.EnqueueRequestsFromMapFunc(r.listTLSRoutesForGatewayClass), - predicate.Funcs{ - GenericFunc: func(_ event.GenericEvent) bool { return false }, // we don't need to enqueue from generic - CreateFunc: func(e event.CreateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - UpdateFunc: func(e event.UpdateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - DeleteFunc: func(e event.DeleteEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - }, - ); err != nil { - return err - } - - // if a Gateway updates then we need to enqueue the linked TLSRoutes to - // ensure that any route objects that may have been orphaned by that change get - // removed from data-plane configurations, and any routes that are now supported - // due to that change get added to data-plane configurations. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.Gateway{}), - handler.EnqueueRequestsFromMapFunc(r.listTLSRoutesForGateway), - ); err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + Named("tlsroute-controller"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + Watches(&gatewayapi.GatewayClass{}, + handler.EnqueueRequestsFromMapFunc(r.listTLSRoutesForGatewayClass), + builder.WithPredicates(predicate.Funcs{ + GenericFunc: func(_ event.GenericEvent) bool { return false }, // we don't need to enqueue from generic + CreateFunc: func(e event.CreateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + UpdateFunc: func(e event.UpdateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + DeleteFunc: func(e event.DeleteEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + }), + ). + // if a Gateway updates then we need to enqueue the linked TLSRoutes to + // ensure that any route objects that may have been orphaned by that change get + // removed from data-plane configurations, and any routes that are now supported + // due to that change get added to data-plane configurations. + Watches(&gatewayapi.Gateway{}, + handler.EnqueueRequestsFromMapFunc(r.listTLSRoutesForGateway), + ) if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: gatewayv1alpha2.GroupVersion.Group, - Version: gatewayv1alpha2.GroupVersion.Version, - Kind: "TLSRoute", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: gatewayv1alpha2.GroupVersion.Group, + Version: gatewayv1alpha2.GroupVersion.Version, + Kind: "TLSRoute", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } // because of the additional burden of having to manage reference data-plane @@ -108,10 +96,8 @@ func (r *TLSRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { // simply reconcile ALL TLSRoute objects. This allows us to drop the backend // data-plane config for an TLSRoute if it somehow becomes disconnected from // a supported Gateway and GatewayClass. - return c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.TLSRoute{}), - &handler.EnqueueRequestForObject{}, - ) + return blder.For(&gatewayapi.TLSRoute{}). + Complete(r) } // ----------------------------------------------------------------------------- diff --git a/internal/controllers/gateway/udproute_controller.go b/internal/controllers/gateway/udproute_controller.go index e4f2e17c67..11ab0470cd 100644 --- a/internal/controllers/gateway/udproute_controller.go +++ b/internal/controllers/gateway/udproute_controller.go @@ -14,6 +14,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" k8stypes "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/event" @@ -51,56 +52,47 @@ type UDPRouteReconciler struct { // SetupWithManager sets up the controller with the Manager. func (r *UDPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { - c, err := controller.New("udproute-controller", mgr, controller.Options{ - Reconciler: r, - LogConstructor: func(_ *reconcile.Request) logr.Logger { - return r.Log - }, - CacheSyncTimeout: r.CacheSyncTimeout, - }) - if err != nil { - return err - } - - // if a GatewayClass updates then we need to enqueue the linked UDPRoutes to - // ensure that any route objects that may have been orphaned by that change get - // removed from data-plane configurations, and any routes that are now supported - // due to that change get added to data-plane configurations. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.GatewayClass{}), - handler.EnqueueRequestsFromMapFunc(r.listUDPRoutesForGatewayClass), - predicate.Funcs{ - GenericFunc: func(_ event.GenericEvent) bool { return false }, // we don't need to enqueue from generic - CreateFunc: func(e event.CreateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - UpdateFunc: func(e event.UpdateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - DeleteFunc: func(e event.DeleteEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, - }, - ); err != nil { - return err - } - - // if a Gateway updates then we need to enqueue the linked UDPRoutes to - // ensure that any route objects that may have been orphaned by that change get - // removed from data-plane configurations, and any routes that are now supported - // due to that change get added to data-plane configurations. - if err := c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.Gateway{}), - handler.EnqueueRequestsFromMapFunc(r.listUDPRoutesForGateway), - ); err != nil { - return err - } + blder := ctrl.NewControllerManagedBy(mgr). + Named("udproute-controller"). + WithOptions(controller.Options{ + Reconciler: r, + LogConstructor: func(_ *reconcile.Request) logr.Logger { + return r.Log + }, + CacheSyncTimeout: r.CacheSyncTimeout, + }). + // if a GatewayClass updates then we need to enqueue the linked UDPRoutes to + // ensure that any route objects that may have been orphaned by that change get + // removed from data-plane configurations, and any routes that are now supported + // due to that change get added to data-plane configurations. + Watches(&gatewayapi.GatewayClass{}, + handler.EnqueueRequestsFromMapFunc(r.listUDPRoutesForGatewayClass), + builder.WithPredicates(predicate.Funcs{ + GenericFunc: func(_ event.GenericEvent) bool { return false }, // we don't need to enqueue from generic + CreateFunc: func(e event.CreateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + UpdateFunc: func(e event.UpdateEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + DeleteFunc: func(e event.DeleteEvent) bool { return isGatewayClassEventInClass(r.Log, e) }, + }), + ). + // if a Gateway updates then we need to enqueue the linked UDPRoutes to + // ensure that any route objects that may have been orphaned by that change get + // removed from data-plane configurations, and any routes that are now supported + // due to that change get added to data-plane configurations. + Watches(&gatewayapi.Gateway{}, + handler.EnqueueRequestsFromMapFunc(r.listUDPRoutesForGateway), + ) if r.StatusQueue != nil { - if err := c.Watch( - &source.Channel{Source: r.StatusQueue.Subscribe(schema.GroupVersionKind{ - Group: gatewayv1alpha2.GroupVersion.Group, - Version: gatewayv1alpha2.GroupVersion.Version, - Kind: "UDPRoute", - })}, - &handler.EnqueueRequestForObject{}, - ); err != nil { - return err - } + blder.WatchesRawSource( + source.Channel( + r.StatusQueue.Subscribe(schema.GroupVersionKind{ + Group: gatewayv1alpha2.GroupVersion.Group, + Version: gatewayv1alpha2.GroupVersion.Version, + Kind: "UDPRoute", + }), + &handler.EnqueueRequestForObject{}, + ), + ) } // because of the additional burden of having to manage reference data-plane @@ -108,10 +100,8 @@ func (r *UDPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { // simply reconcile ALL UDPRoute objects. This allows us to drop the backend // data-plane config for an UDPRoute if it somehow becomes disconnected from // a supported Gateway and GatewayClass. - return c.Watch( - source.Kind(mgr.GetCache(), &gatewayapi.UDPRoute{}), - &handler.EnqueueRequestForObject{}, - ) + return blder.For(&gatewayapi.UDPRoute{}). + Complete(r) } // ----------------------------------------------------------------------------- From 96a8ff9cccefb928a1c5d7c00914886705a78796 Mon Sep 17 00:00:00 2001 From: Jintao Zhang Date: Fri, 10 May 2024 02:38:49 +0800 Subject: [PATCH 2/5] Use For function Signed-off-by: Jintao Zhang --- .../generators/controllers/networking/main.go | 7 +++--- .../configuration/kongadminapi_controller.go | 1 - .../configuration/secret_controller.go | 2 -- .../configuration/zz_generated_controllers.go | 24 +++++-------------- .../gateway/gatewayclass_controller.go | 1 - 5 files changed, 10 insertions(+), 25 deletions(-) diff --git a/hack/generators/controllers/networking/main.go b/hack/generators/controllers/networking/main.go index 124764c512..303413b293 100644 --- a/hack/generators/controllers/networking/main.go +++ b/hack/generators/controllers/networking/main.go @@ -551,14 +551,15 @@ func (r *{{.PackageAlias}}{{.Kind}}Reconciler) SetupWithManager(mgr ctrl.Manager ) } preds := ctrlutils.GeneratePredicateFuncsForIngressClassFilter(r.IngressClassName) -{{- end}} return blder.Watches(&{{.PackageImportAlias}}.{{.Kind}}{}, &handler.EnqueueRequestForObject{}, -{{- if .AcceptsIngressClassNameAnnotation}} builder.WithPredicates(preds), -{{- end}} ). Complete(r) +{{- else}} + return blder.For(&{{.PackageImportAlias}}.{{.Kind}}{}). + Complete(r) +{{- end}} } {{- if .AcceptsIngressClassNameAnnotation}} diff --git a/internal/controllers/configuration/kongadminapi_controller.go b/internal/controllers/configuration/kongadminapi_controller.go index 7ccbb68a8a..a98e2a29f6 100644 --- a/internal/controllers/configuration/kongadminapi_controller.go +++ b/internal/controllers/configuration/kongadminapi_controller.go @@ -59,7 +59,6 @@ var _ controllers.Reconciler = &KongAdminAPIServiceReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *KongAdminAPIServiceReconciler) SetupWithManager(mgr ctrl.Manager) error { - if r.Cache == nil { r.Cache = make(DiscoveredAdminAPIsCache) } diff --git a/internal/controllers/configuration/secret_controller.go b/internal/controllers/configuration/secret_controller.go index 66f2f43165..11b6255da6 100644 --- a/internal/controllers/configuration/secret_controller.go +++ b/internal/controllers/configuration/secret_controller.go @@ -47,7 +47,6 @@ var _ controllers.Reconciler = &CoreV1SecretReconciler{} // SetupWithManager sets up the controller with the Manager. func (r *CoreV1SecretReconciler) SetupWithManager(mgr ctrl.Manager) error { - predicateFuncs := predicate.NewPredicateFuncs(r.shouldReconcileSecret) // we should always try to delete secrets in caches when they are deleted in cluster. predicateFuncs.DeleteFunc = func(_ event.DeleteEvent) bool { return true } @@ -66,7 +65,6 @@ func (r *CoreV1SecretReconciler) SetupWithManager(mgr ctrl.Manager) error { builder.WithPredicates(predicateFuncs), ). Complete(r) - } // SetLogger sets the logger. diff --git a/internal/controllers/configuration/zz_generated_controllers.go b/internal/controllers/configuration/zz_generated_controllers.go index b91616d738..00ef3817a3 100644 --- a/internal/controllers/configuration/zz_generated_controllers.go +++ b/internal/controllers/configuration/zz_generated_controllers.go @@ -81,9 +81,7 @@ func (r *CoreV1ServiceReconciler) SetupWithManager(mgr ctrl.Manager) error { }, CacheSyncTimeout: r.CacheSyncTimeout, }) - return blder.Watches(&corev1.Service{}, - &handler.EnqueueRequestForObject{}, - ). + return blder.For(&corev1.Service{}). Complete(r) } @@ -186,9 +184,7 @@ func (r *DiscoveryV1EndpointSliceReconciler) SetupWithManager(mgr ctrl.Manager) }, CacheSyncTimeout: r.CacheSyncTimeout, }) - return blder.Watches(&discoveryv1.EndpointSlice{}, - &handler.EnqueueRequestForObject{}, - ). + return blder.For(&discoveryv1.EndpointSlice{}). Complete(r) } @@ -469,9 +465,7 @@ func (r *NetV1IngressClassReconciler) SetupWithManager(mgr ctrl.Manager) error { }, CacheSyncTimeout: r.CacheSyncTimeout, }) - return blder.Watches(&netv1.IngressClass{}, - &handler.EnqueueRequestForObject{}, - ). + return blder.For(&netv1.IngressClass{}). Complete(r) } @@ -553,9 +547,7 @@ func (r *KongV1KongIngressReconciler) SetupWithManager(mgr ctrl.Manager) error { }, CacheSyncTimeout: r.CacheSyncTimeout, }) - return blder.Watches(&kongv1.KongIngress{}, - &handler.EnqueueRequestForObject{}, - ). + return blder.For(&kongv1.KongIngress{}). Complete(r) } @@ -639,9 +631,7 @@ func (r *KongV1KongPluginReconciler) SetupWithManager(mgr ctrl.Manager) error { }, CacheSyncTimeout: r.CacheSyncTimeout, }) - return blder.Watches(&kongv1.KongPlugin{}, - &handler.EnqueueRequestForObject{}, - ). + return blder.For(&kongv1.KongPlugin{}). Complete(r) } @@ -1653,9 +1643,7 @@ func (r *KongV1Alpha1IngressClassParametersReconciler) SetupWithManager(mgr ctrl }, CacheSyncTimeout: r.CacheSyncTimeout, }) - return blder.Watches(&kongv1alpha1.IngressClassParameters{}, - &handler.EnqueueRequestForObject{}, - ). + return blder.For(&kongv1alpha1.IngressClassParameters{}). Complete(r) } diff --git a/internal/controllers/gateway/gatewayclass_controller.go b/internal/controllers/gateway/gatewayclass_controller.go index 8f27cf6c70..a153b9c4ea 100644 --- a/internal/controllers/gateway/gatewayclass_controller.go +++ b/internal/controllers/gateway/gatewayclass_controller.go @@ -62,7 +62,6 @@ type GatewayClassReconciler struct { //nolint:revive // SetupWithManager sets up the controller with the Manager. func (r *GatewayClassReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). // set the controller name Named(strings.ToUpper(gatewayapi.V1GroupVersion) + "GatewayClass"). From 3a6a2550374c0b497710aea653013cf33f040254 Mon Sep 17 00:00:00 2001 From: Jintao Zhang Date: Fri, 10 May 2024 02:55:19 +0800 Subject: [PATCH 3/5] re-generate manifests Signed-off-by: Jintao Zhang --- config/crd/bases/configuration.konghq.com_tcpingresses.yaml | 1 + config/crd/bases/configuration.konghq.com_udpingresses.yaml | 1 + test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml | 2 ++ test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml | 2 ++ test/e2e/manifests/all-in-one-dbless-konnect.yaml | 2 ++ test/e2e/manifests/all-in-one-dbless.yaml | 2 ++ test/e2e/manifests/all-in-one-postgres-enterprise.yaml | 2 ++ test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml | 2 ++ test/e2e/manifests/all-in-one-postgres.yaml | 2 ++ 9 files changed, 16 insertions(+) diff --git a/config/crd/bases/configuration.konghq.com_tcpingresses.yaml b/config/crd/bases/configuration.konghq.com_tcpingresses.yaml index b1a5c7b0f8..ab693720fa 100644 --- a/config/crd/bases/configuration.konghq.com_tcpingresses.yaml +++ b/config/crd/bases/configuration.konghq.com_tcpingresses.yaml @@ -199,6 +199,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object diff --git a/config/crd/bases/configuration.konghq.com_udpingresses.yaml b/config/crd/bases/configuration.konghq.com_udpingresses.yaml index 7a470d99ab..d0d38c2381 100644 --- a/config/crd/bases/configuration.konghq.com_udpingresses.yaml +++ b/config/crd/bases/configuration.konghq.com_udpingresses.yaml @@ -163,6 +163,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object diff --git a/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml b/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml index 614a7a40a0..fe7fef5742 100644 --- a/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml +++ b/test/e2e/manifests/all-in-one-dbless-k4k8s-enterprise.yaml @@ -2762,6 +2762,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object @@ -2934,6 +2935,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object diff --git a/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml b/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml index 4e510d884a..6e7c6b15be 100644 --- a/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml +++ b/test/e2e/manifests/all-in-one-dbless-konnect-enterprise.yaml @@ -2762,6 +2762,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object @@ -2934,6 +2935,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object diff --git a/test/e2e/manifests/all-in-one-dbless-konnect.yaml b/test/e2e/manifests/all-in-one-dbless-konnect.yaml index cc7758e008..8d38ba4f79 100644 --- a/test/e2e/manifests/all-in-one-dbless-konnect.yaml +++ b/test/e2e/manifests/all-in-one-dbless-konnect.yaml @@ -2762,6 +2762,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object @@ -2934,6 +2935,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object diff --git a/test/e2e/manifests/all-in-one-dbless.yaml b/test/e2e/manifests/all-in-one-dbless.yaml index 2df4bb5db1..b4c71ecaf1 100644 --- a/test/e2e/manifests/all-in-one-dbless.yaml +++ b/test/e2e/manifests/all-in-one-dbless.yaml @@ -2762,6 +2762,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object @@ -2934,6 +2935,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object diff --git a/test/e2e/manifests/all-in-one-postgres-enterprise.yaml b/test/e2e/manifests/all-in-one-postgres-enterprise.yaml index 9172fb833f..a418f204d3 100644 --- a/test/e2e/manifests/all-in-one-postgres-enterprise.yaml +++ b/test/e2e/manifests/all-in-one-postgres-enterprise.yaml @@ -2762,6 +2762,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object @@ -2934,6 +2935,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object diff --git a/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml b/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml index ec6b33a737..b2b10afe5c 100644 --- a/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml +++ b/test/e2e/manifests/all-in-one-postgres-multiple-gateways.yaml @@ -2762,6 +2762,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object @@ -2934,6 +2935,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object diff --git a/test/e2e/manifests/all-in-one-postgres.yaml b/test/e2e/manifests/all-in-one-postgres.yaml index de2f0bb4e4..251a7ca49d 100644 --- a/test/e2e/manifests/all-in-one-postgres.yaml +++ b/test/e2e/manifests/all-in-one-postgres.yaml @@ -2762,6 +2762,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object @@ -2934,6 +2935,7 @@ spec: x-kubernetes-list-type: atomic type: object type: array + x-kubernetes-list-type: atomic type: object type: object type: object From 2af10bdafabc041c8997a7de90d7536efb4117e1 Mon Sep 17 00:00:00 2001 From: Jintao Zhang Date: Fri, 10 May 2024 15:01:27 +0800 Subject: [PATCH 4/5] remove duplicate reconciler Signed-off-by: Jintao Zhang --- controllers/license/konglicense_controller.go | 1 - hack/generators/controllers/networking/main.go | 1 - .../configuration/kongadminapi_controller.go | 1 - .../configuration/kongupstreampolicy_controller.go | 1 - .../controllers/configuration/secret_controller.go | 1 - .../configuration/zz_generated_controllers.go | 14 -------------- internal/controllers/crds/dynamic_controller.go | 1 - internal/controllers/gateway/gateway_controller.go | 1 - .../controllers/gateway/gatewayclass_controller.go | 1 - .../controllers/gateway/grpcroute_controller.go | 1 - .../controllers/gateway/httproute_controller.go | 1 - .../gateway/referencegrant_controller.go | 1 - .../controllers/gateway/tcproute_controller.go | 1 - .../controllers/gateway/tlsroute_controller.go | 1 - .../controllers/gateway/udproute_controller.go | 1 - 15 files changed, 28 deletions(-) diff --git a/controllers/license/konglicense_controller.go b/controllers/license/konglicense_controller.go index 24c6ac4d29..ca9772d218 100644 --- a/controllers/license/konglicense_controller.go +++ b/controllers/license/konglicense_controller.go @@ -133,7 +133,6 @@ func (r *KongV1Alpha1KongLicenseReconciler) SetupWithManager(mgr ctrl.Manager) e blder := ctrl.NewControllerManagedBy(mgr). Named("KongV1Alpha1KongLicense"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/hack/generators/controllers/networking/main.go b/hack/generators/controllers/networking/main.go index 303413b293..ee7bc6ab84 100644 --- a/hack/generators/controllers/networking/main.go +++ b/hack/generators/controllers/networking/main.go @@ -521,7 +521,6 @@ func (r *{{.PackageAlias}}{{.Kind}}Reconciler) SetupWithManager(mgr ctrl.Manager // set the controller name Named("{{.PackageAlias}}{{.Kind}}"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/configuration/kongadminapi_controller.go b/internal/controllers/configuration/kongadminapi_controller.go index a98e2a29f6..441876e4c3 100644 --- a/internal/controllers/configuration/kongadminapi_controller.go +++ b/internal/controllers/configuration/kongadminapi_controller.go @@ -67,7 +67,6 @@ func (r *KongAdminAPIServiceReconciler) SetupWithManager(mgr ctrl.Manager) error // set the controller name Named("KongAdminAPIEndpoints"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/configuration/kongupstreampolicy_controller.go b/internal/controllers/configuration/kongupstreampolicy_controller.go index 5e9ecbc3f7..3b0fcffa20 100644 --- a/internal/controllers/configuration/kongupstreampolicy_controller.go +++ b/internal/controllers/configuration/kongupstreampolicy_controller.go @@ -59,7 +59,6 @@ func (r *KongUpstreamPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error blder := ctrl.NewControllerManagedBy(mgr). Named("KongUpstreamPolicy"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/configuration/secret_controller.go b/internal/controllers/configuration/secret_controller.go index 11b6255da6..1cddb9627a 100644 --- a/internal/controllers/configuration/secret_controller.go +++ b/internal/controllers/configuration/secret_controller.go @@ -54,7 +54,6 @@ func (r *CoreV1SecretReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). Named("CoreV1Secret"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/configuration/zz_generated_controllers.go b/internal/controllers/configuration/zz_generated_controllers.go index 00ef3817a3..0ddb99ca99 100644 --- a/internal/controllers/configuration/zz_generated_controllers.go +++ b/internal/controllers/configuration/zz_generated_controllers.go @@ -75,7 +75,6 @@ func (r *CoreV1ServiceReconciler) SetupWithManager(mgr ctrl.Manager) error { // set the controller name Named("CoreV1Service"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -178,7 +177,6 @@ func (r *DiscoveryV1EndpointSliceReconciler) SetupWithManager(mgr ctrl.Manager) // set the controller name Named("DiscoveryV1EndpointSlice"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -267,7 +265,6 @@ func (r *NetV1IngressReconciler) SetupWithManager(mgr ctrl.Manager) error { // set the controller name Named("NetV1Ingress"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -459,7 +456,6 @@ func (r *NetV1IngressClassReconciler) SetupWithManager(mgr ctrl.Manager) error { // set the controller name Named("NetV1IngressClass"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -541,7 +537,6 @@ func (r *KongV1KongIngressReconciler) SetupWithManager(mgr ctrl.Manager) error { // set the controller name Named("KongV1KongIngress"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -625,7 +620,6 @@ func (r *KongV1KongPluginReconciler) SetupWithManager(mgr ctrl.Manager) error { // set the controller name Named("KongV1KongPlugin"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -732,7 +726,6 @@ func (r *KongV1KongClusterPluginReconciler) SetupWithManager(mgr ctrl.Manager) e // set the controller name Named("KongV1KongClusterPlugin"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -891,7 +884,6 @@ func (r *KongV1KongConsumerReconciler) SetupWithManager(mgr ctrl.Manager) error // set the controller name Named("KongV1KongConsumer"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -1078,7 +1070,6 @@ func (r *KongV1Beta1KongConsumerGroupReconciler) SetupWithManager(mgr ctrl.Manag // set the controller name Named("KongV1Beta1KongConsumerGroup"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -1267,7 +1258,6 @@ func (r *KongV1Beta1TCPIngressReconciler) SetupWithManager(mgr ctrl.Manager) err // set the controller name Named("KongV1Beta1TCPIngress"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -1465,7 +1455,6 @@ func (r *KongV1Beta1UDPIngressReconciler) SetupWithManager(mgr ctrl.Manager) err // set the controller name Named("KongV1Beta1UDPIngress"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -1637,7 +1626,6 @@ func (r *KongV1Alpha1IngressClassParametersReconciler) SetupWithManager(mgr ctrl // set the controller name Named("KongV1Alpha1IngressClassParameters"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -1723,7 +1711,6 @@ func (r *IncubatorV1Alpha1KongServiceFacadeReconciler) SetupWithManager(mgr ctrl // set the controller name Named("IncubatorV1Alpha1KongServiceFacade"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, @@ -1890,7 +1877,6 @@ func (r *KongV1Alpha1KongVaultReconciler) SetupWithManager(mgr ctrl.Manager) err // set the controller name Named("KongV1Alpha1KongVault"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/crds/dynamic_controller.go b/internal/controllers/crds/dynamic_controller.go index 18d1d27958..1b87c48e5b 100644 --- a/internal/controllers/crds/dynamic_controller.go +++ b/internal/controllers/crds/dynamic_controller.go @@ -54,7 +54,6 @@ func (r *DynamicCRDController) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). Named("DynamicCRDController"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/gateway/gateway_controller.go b/internal/controllers/gateway/gateway_controller.go index 842a356bd2..e1331594c7 100644 --- a/internal/controllers/gateway/gateway_controller.go +++ b/internal/controllers/gateway/gateway_controller.go @@ -94,7 +94,6 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error { Named("gateway-controller"). // set the controller options WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/gateway/gatewayclass_controller.go b/internal/controllers/gateway/gatewayclass_controller.go index a153b9c4ea..d22d30eb40 100644 --- a/internal/controllers/gateway/gatewayclass_controller.go +++ b/internal/controllers/gateway/gatewayclass_controller.go @@ -67,7 +67,6 @@ func (r *GatewayClassReconciler) SetupWithManager(mgr ctrl.Manager) error { Named(strings.ToUpper(gatewayapi.V1GroupVersion) + "GatewayClass"). // set the controller options WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/gateway/grpcroute_controller.go b/internal/controllers/gateway/grpcroute_controller.go index 858ed3b14f..0300ba62cb 100644 --- a/internal/controllers/gateway/grpcroute_controller.go +++ b/internal/controllers/gateway/grpcroute_controller.go @@ -60,7 +60,6 @@ func (r *GRPCRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { // set the controller name Named("grpcroute-controller"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/gateway/httproute_controller.go b/internal/controllers/gateway/httproute_controller.go index 5e14ca91a5..614569ac77 100644 --- a/internal/controllers/gateway/httproute_controller.go +++ b/internal/controllers/gateway/httproute_controller.go @@ -78,7 +78,6 @@ func (r *HTTPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { // set the controller name Named("httproute-controller"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/gateway/referencegrant_controller.go b/internal/controllers/gateway/referencegrant_controller.go index 4de217287e..c7aa2e59ce 100644 --- a/internal/controllers/gateway/referencegrant_controller.go +++ b/internal/controllers/gateway/referencegrant_controller.go @@ -48,7 +48,6 @@ func (r *ReferenceGrantReconciler) SetupWithManager(mgr ctrl.Manager) error { // set the controller name Named("referencegrant-controller"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/gateway/tcproute_controller.go b/internal/controllers/gateway/tcproute_controller.go index 9fc5f6d442..1482b10ef9 100644 --- a/internal/controllers/gateway/tcproute_controller.go +++ b/internal/controllers/gateway/tcproute_controller.go @@ -56,7 +56,6 @@ func (r *TCPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { blder := ctrl.NewControllerManagedBy(mgr). Named("tcproute-controller"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/gateway/tlsroute_controller.go b/internal/controllers/gateway/tlsroute_controller.go index d97ff392f9..ed7cd93d99 100644 --- a/internal/controllers/gateway/tlsroute_controller.go +++ b/internal/controllers/gateway/tlsroute_controller.go @@ -55,7 +55,6 @@ func (r *TLSRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { blder := ctrl.NewControllerManagedBy(mgr). Named("tlsroute-controller"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, diff --git a/internal/controllers/gateway/udproute_controller.go b/internal/controllers/gateway/udproute_controller.go index 11ab0470cd..f91396000b 100644 --- a/internal/controllers/gateway/udproute_controller.go +++ b/internal/controllers/gateway/udproute_controller.go @@ -55,7 +55,6 @@ func (r *UDPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error { blder := ctrl.NewControllerManagedBy(mgr). Named("udproute-controller"). WithOptions(controller.Options{ - Reconciler: r, LogConstructor: func(_ *reconcile.Request) logr.Logger { return r.Log }, From 4255e6674fdfb2e36f17267a5232e3a06d34a799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Fri, 10 May 2024 12:30:15 +0200 Subject: [PATCH 5/5] Update internal/controllers/gateway/gateway_controller.go --- internal/controllers/gateway/gateway_controller.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/controllers/gateway/gateway_controller.go b/internal/controllers/gateway/gateway_controller.go index e1331594c7..67e54a4cf0 100644 --- a/internal/controllers/gateway/gateway_controller.go +++ b/internal/controllers/gateway/gateway_controller.go @@ -101,8 +101,9 @@ func (r *GatewayReconciler) SetupWithManager(mgr ctrl.Manager) error { }). // watch Gateway objects, filtering out any Gateways which are not configured with // a supported GatewayClass controller name. - For(&gatewayapi.Gateway{}). - WithEventFilter(predicate.NewPredicateFuncs(r.gatewayHasMatchingGatewayClass)). + For(&gatewayapi.Gateway{}, + builder.WithPredicates(predicate.NewPredicateFuncs(r.gatewayHasMatchingGatewayClass)), + ). // watch for updates to gatewayclasses, if any gateway classes change, enqueue // reconciliation for all supported gateway objects which reference it. Watches(&gatewayapi.GatewayClass{},