From 9bf7307a285e6b579077ff38893dad6494fc1c98 Mon Sep 17 00:00:00 2001 From: Friedrich Date: Fri, 20 Oct 2023 14:19:00 +0200 Subject: [PATCH] Bump dependencies (#173) * bump all dependencies * replace depretaced pointer with ptr pointer is deprecated: https://pkg.go.dev/k8s.io/utils/pointer * remove deprecated funcs from controller-runtime here is an overview of all deprecated and removed functions and structs: https://github.com/kubernetes-sigs/controller-runtime/pull/2422/files --- cmd/main.go | 20 +++++--- go.mod | 13 ++--- go.sum | 12 +++++ .../testenvironment/test_environment.go | 6 +-- .../subscription/eventmesh/test/utils.go | 23 +++++---- .../eventmesh/testwebhookauth/utils.go | 17 ++++--- .../eventmesh/testwithory/utils.go | 15 ++++-- .../subscription/jetstream/test_utils_test.go | 15 ++++-- pkg/eventing/manager_test.go | 10 ++-- pkg/k8s/client.go | 4 +- pkg/object/equality_test.go | 50 +++++++++---------- test/utils/integration/integration.go | 8 +-- 12 files changed, 117 insertions(+), 76 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index c58a8ca5..2d3acd81 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -28,35 +28,40 @@ import ( "github.com/go-logr/zapr" - "github.com/kyma-project/eventing-manager/pkg/env" subscriptionv1alpha1 "github.com/kyma-project/kyma/components/eventing-controller/api/v1alpha1" subscriptionv1alpha2 "github.com/kyma-project/kyma/components/eventing-controller/api/v1alpha2" + "github.com/kyma-project/eventing-manager/pkg/env" + "github.com/kyma-project/eventing-manager/pkg/subscriptionmanager/jetstream" "github.com/kyma-project/eventing-manager/pkg/eventing" "github.com/kyma-project/eventing-manager/pkg/k8s" + apiclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" + eventingcontroller "github.com/kyma-project/eventing-manager/internal/controller/eventing" "github.com/kyma-project/eventing-manager/options" backendmetrics "github.com/kyma-project/eventing-manager/pkg/backend/metrics" "github.com/kyma-project/eventing-manager/pkg/logger" - apiclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them. "k8s.io/client-go/dynamic" _ "k8s.io/client-go/plugin/pkg/client/auth" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/healthz" - - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" + "sigs.k8s.io/controller-runtime/pkg/webhook" apigatewayv1beta1 "github.com/kyma-incubator/api-gateway/api/v1beta1" + eventingv1alpha1 "github.com/kyma-project/eventing-manager/api/v1alpha1" //+kubebuilder:scaffold:imports ) @@ -113,14 +118,15 @@ func main() { //nolint:funlen // main function needs to initialize many object // setup ctrl manager k8sRestCfg := ctrl.GetConfigOrDie() + mgr, err := ctrl.NewManager(k8sRestCfg, ctrl.Options{ Scheme: scheme, - MetricsBindAddress: opts.MetricsAddr, - Port: 9443, HealthProbeBindAddress: opts.ProbeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: leaderElectionID, - SyncPeriod: &opts.ReconcilePeriod, + WebhookServer: webhook.NewServer(webhook.Options{Port: 9443}), + Cache: cache.Options{SyncPeriod: &opts.ReconcilePeriod}, + Metrics: server.Options{BindAddress: opts.MetricsAddr}, }) if err != nil { setupLog.Error(err, "unable to start manager") diff --git a/go.mod b/go.mod index d89120b0..0f1c03e6 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/google/uuid v1.3.1 github.com/kelseyhightower/envconfig v1.4.0 github.com/kyma-incubator/api-gateway v0.0.0-20220819093753-296e6704d413 - github.com/kyma-project/kyma/common/logging v0.0.0-20230616102347-ad6927dc28d5 - github.com/kyma-project/kyma/components/eventing-controller v0.0.0-20231006112231-696ba866d5ec + github.com/kyma-project/kyma/common/logging v0.0.0-20231020092259-d58329d50da1 + github.com/kyma-project/kyma/components/eventing-controller v0.0.0-20231020092259-d58329d50da1 github.com/kyma-project/nats-manager v1.0.2 github.com/mitchellh/hashstructure/v2 v2.0.2 github.com/nats-io/nats-server/v2 v2.10.3 @@ -25,20 +25,20 @@ require ( go.uber.org/atomic v1.11.0 go.uber.org/zap v1.26.0 golang.org/x/oauth2 v0.13.0 - golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 + golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 k8s.io/api v0.28.3 k8s.io/apiextensions-apiserver v0.28.3 k8s.io/apimachinery v0.28.3 k8s.io/client-go v0.28.3 - k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 - sigs.k8s.io/controller-runtime v0.15.2 + k8s.io/utils v0.0.0-20230726121419-3b25d923346b + sigs.k8s.io/controller-runtime v0.16.3 ) require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/emicklei/go-restful/v3 v3.10.1 // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect @@ -74,6 +74,7 @@ require ( github.com/stretchr/objx v0.5.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.14.0 // indirect + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/term v0.13.0 // indirect diff --git a/go.sum b/go.sum index f9ece66d..3ca4a7bc 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= @@ -95,10 +97,14 @@ github.com/kyma-project/api-gateway v0.0.0-20220819093753-296e6704d413 h1:fkGKNO github.com/kyma-project/api-gateway v0.0.0-20220819093753-296e6704d413/go.mod h1:5kBV6C2JEaapjTAn10Mo81Te4e6LN3epexUCSLXgQLI= github.com/kyma-project/kyma/common/logging v0.0.0-20230616102347-ad6927dc28d5 h1:Uey3jJWq9eyXiepEvqQjBIWwPGM8nMIylBpcTc9FuDM= github.com/kyma-project/kyma/common/logging v0.0.0-20230616102347-ad6927dc28d5/go.mod h1:JGb5RBi8Uz+RZ/jf54+qA+RqY6uPQBJ8pO1w3KSwm1Q= +github.com/kyma-project/kyma/common/logging v0.0.0-20231020092259-d58329d50da1 h1:Lur/R654ghUmsZiNrSrQBDjxCAvkb/7CueB0X/VQbKg= +github.com/kyma-project/kyma/common/logging v0.0.0-20231020092259-d58329d50da1/go.mod h1:JGb5RBi8Uz+RZ/jf54+qA+RqY6uPQBJ8pO1w3KSwm1Q= github.com/kyma-project/kyma/components/application-operator v0.0.0-20230127165033-ec8e43477eca h1:7UpCIk6+sMCOhPfolAlppRugSln5M4T8/dHJm8x0erc= github.com/kyma-project/kyma/components/application-operator v0.0.0-20230127165033-ec8e43477eca/go.mod h1:Tog02gZ1VT7yvFmhSqmiuGZpDYt18zTF4kr6E0N9ttk= github.com/kyma-project/kyma/components/eventing-controller v0.0.0-20231006112231-696ba866d5ec h1:P+V9r14NJKUFbIZIEMrjInABT+qN/ySLqWQ01aeq068= github.com/kyma-project/kyma/components/eventing-controller v0.0.0-20231006112231-696ba866d5ec/go.mod h1:Ht1hT95iSKe5md3QhIZQrq3j9WXkiWe/qdDMaDrmdyI= +github.com/kyma-project/kyma/components/eventing-controller v0.0.0-20231020092259-d58329d50da1 h1:DeK2GvRpL2YPPkCguEN376Lj6dlKkjwn1Z4Df1LHatg= +github.com/kyma-project/kyma/components/eventing-controller v0.0.0-20231020092259-d58329d50da1/go.mod h1:llsnpySZ+YAB6WrWplNWbGdnYYPmMlUMXEhFl0sXtsE= github.com/kyma-project/nats-manager v1.0.2 h1:uJiVrLFFqnOsnz1IGNn76fm5cQoK+4L8GxP829mX2C8= github.com/kyma-project/nats-manager v1.0.2/go.mod h1:gC0W/C2NgpmVnG/5v5f76ijNw5aloQLEkSuVOElB9gk= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -256,6 +262,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= @@ -304,8 +312,12 @@ k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5Ohx k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/controller-runtime v0.15.2 h1:9V7b7SDQSJ08IIsJ6CY1CE85Okhp87dyTMNDG0FS7f4= sigs.k8s.io/controller-runtime v0.15.2/go.mod h1:7ngYvp1MLT+9GeZ+6lH3LOlcHkp/+tzA/fmHa4iq9kk= +sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4= +sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= diff --git a/hack/e2e/common/testenvironment/test_environment.go b/hack/e2e/common/testenvironment/test_environment.go index 2e665f20..317ad9e6 100644 --- a/hack/e2e/common/testenvironment/test_environment.go +++ b/hack/e2e/common/testenvironment/test_environment.go @@ -21,7 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" k8stypes "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kyma-project/eventing-manager/hack/e2e/common" @@ -264,7 +264,7 @@ func (te *TestEnvironment) CreateSinkDeployment(name, namespace, image string) e return te.K8sClient.Patch(te.Context, fixtures.NewSinkDeployment(name, namespace, image), client.Apply, &client.PatchOptions{ - Force: pointer.Bool(true), + Force: ptr.To(true), FieldManager: fixtures.FieldManager, }) }) @@ -275,7 +275,7 @@ func (te *TestEnvironment) CreateSinkService(name, namespace string) error { return te.K8sClient.Patch(te.Context, fixtures.NewSinkService(name, namespace), client.Apply, &client.PatchOptions{ - Force: pointer.Bool(true), + Force: ptr.To(true), FieldManager: fixtures.FieldManager, }) }) diff --git a/internal/controller/subscription/eventmesh/test/utils.go b/internal/controller/subscription/eventmesh/test/utils.go index 2fd3c9f7..3921f6fc 100644 --- a/internal/controller/subscription/eventmesh/test/utils.go +++ b/internal/controller/subscription/eventmesh/test/utils.go @@ -15,6 +15,8 @@ import ( "github.com/avast/retry-go/v3" "github.com/go-logr/zapr" + apigatewayv1beta1 "github.com/kyma-incubator/api-gateway/api/v1beta1" + kymalogger "github.com/kyma-project/kyma/common/logging/logger" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" @@ -25,13 +27,15 @@ import ( "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" + "sigs.k8s.io/controller-runtime/pkg/webhook" - apigatewayv1beta1 "github.com/kyma-incubator/api-gateway/api/v1beta1" - kymalogger "github.com/kyma-project/kyma/common/logging/logger" + eventingv1alpha2 "github.com/kyma-project/kyma/components/eventing-controller/api/v1alpha2" eventmeshreconciler "github.com/kyma-project/eventing-manager/internal/controller/subscription/eventmesh" "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" @@ -47,7 +51,6 @@ import ( "github.com/kyma-project/eventing-manager/pkg/utils" testutils "github.com/kyma-project/eventing-manager/test/utils" reconcilertesting "github.com/kyma-project/eventing-manager/testing" - eventingv1alpha2 "github.com/kyma-project/kyma/components/eventing-controller/api/v1alpha2" ) type eventMeshTestEnsemble struct { @@ -117,13 +120,15 @@ func setupSuite() error { syncPeriod := syncPeriodSeconds * time.Second webhookInstallOptions := &emTestEnsemble.testEnv.WebhookInstallOptions k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme.Scheme, - SyncPeriod: &syncPeriod, - Host: webhookInstallOptions.LocalServingHost, - Port: webhookInstallOptions.LocalServingPort, - CertDir: webhookInstallOptions.LocalServingCertDir, - MetricsBindAddress: "0", // disable + Cache: cache.Options{SyncPeriod: &syncPeriod}, HealthProbeBindAddress: "0", // disable + Scheme: scheme.Scheme, + Metrics: server.Options{BindAddress: "0"}, // disable + WebhookServer: webhook.NewServer(webhook.Options{ + Port: webhookInstallOptions.LocalServingPort, + Host: webhookInstallOptions.LocalServingHost, + CertDir: webhookInstallOptions.LocalServingCertDir, + }), }) if err != nil { return err diff --git a/internal/controller/subscription/eventmesh/testwebhookauth/utils.go b/internal/controller/subscription/eventmesh/testwebhookauth/utils.go index 487e4493..18c734bb 100644 --- a/internal/controller/subscription/eventmesh/testwebhookauth/utils.go +++ b/internal/controller/subscription/eventmesh/testwebhookauth/utils.go @@ -21,10 +21,13 @@ import ( "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" + "sigs.k8s.io/controller-runtime/pkg/webhook" apigatewayv1beta1 "github.com/kyma-incubator/api-gateway/api/v1beta1" kymalogger "github.com/kyma-project/kyma/common/logging/logger" @@ -119,12 +122,14 @@ func setupSuite() error { webhookInstallOptions := &emTestEnsemble.testEnv.WebhookInstallOptions k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{ Scheme: scheme.Scheme, - SyncPeriod: &syncPeriod, - Host: webhookInstallOptions.LocalServingHost, - Port: webhookInstallOptions.LocalServingPort, - CertDir: webhookInstallOptions.LocalServingCertDir, - MetricsBindAddress: "0", // disable - HealthProbeBindAddress: "0", // disable + Cache: cache.Options{SyncPeriod: &syncPeriod}, + Metrics: server.Options{BindAddress: "0"}, // disable + HealthProbeBindAddress: "0", // disable + WebhookServer: webhook.NewServer(webhook.Options{ + Host: webhookInstallOptions.LocalServingHost, + Port: webhookInstallOptions.LocalServingPort, + CertDir: webhookInstallOptions.LocalServingCertDir, + }), }) if err != nil { return err diff --git a/internal/controller/subscription/eventmesh/testwithory/utils.go b/internal/controller/subscription/eventmesh/testwithory/utils.go index d98fe366..af798ed5 100644 --- a/internal/controller/subscription/eventmesh/testwithory/utils.go +++ b/internal/controller/subscription/eventmesh/testwithory/utils.go @@ -25,10 +25,13 @@ import ( "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" + "sigs.k8s.io/controller-runtime/pkg/webhook" apigatewayv1beta1 "github.com/kyma-incubator/api-gateway/api/v1beta1" kymalogger "github.com/kyma-project/kyma/common/logging/logger" @@ -118,12 +121,14 @@ func setupSuite() error { webhookInstallOptions := &emTestEnsemble.testEnv.WebhookInstallOptions k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{ Scheme: scheme.Scheme, - SyncPeriod: &syncPeriod, - Host: webhookInstallOptions.LocalServingHost, - Port: webhookInstallOptions.LocalServingPort, - CertDir: webhookInstallOptions.LocalServingCertDir, - MetricsBindAddress: "0", // disable HealthProbeBindAddress: "0", // disable + Cache: cache.Options{SyncPeriod: &syncPeriod}, + Metrics: server.Options{BindAddress: "0"}, //disable + WebhookServer: webhook.NewServer(webhook.Options{ + Host: webhookInstallOptions.LocalServingHost, + Port: webhookInstallOptions.LocalServingPort, + CertDir: webhookInstallOptions.LocalServingCertDir, + }), }) if err != nil { return err diff --git a/internal/controller/subscription/jetstream/test_utils_test.go b/internal/controller/subscription/jetstream/test_utils_test.go index f61004f0..371ce64c 100644 --- a/internal/controller/subscription/jetstream/test_utils_test.go +++ b/internal/controller/subscription/jetstream/test_utils_test.go @@ -25,8 +25,11 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/client-go/rest" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" + "sigs.k8s.io/controller-runtime/pkg/webhook" cleanerv1alpha2 "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" "github.com/kyma-project/eventing-manager/pkg/backend/jetstream" @@ -150,12 +153,14 @@ func startReconciler() error { webhookInstallOptions := &jsTestEnsemble.TestEnv.WebhookInstallOptions k8sManager, err := ctrl.NewManager(jsTestEnsemble.Cfg, ctrl.Options{ Scheme: scheme.Scheme, - SyncPeriod: &syncPeriod, - Host: webhookInstallOptions.LocalServingHost, - Port: webhookInstallOptions.LocalServingPort, - CertDir: webhookInstallOptions.LocalServingCertDir, - MetricsBindAddress: "0", // disable HealthProbeBindAddress: "0", // disable + Cache: cache.Options{SyncPeriod: &syncPeriod}, + Metrics: server.Options{BindAddress: "0"}, // disable + WebhookServer: webhook.NewServer(webhook.Options{ + Host: webhookInstallOptions.LocalServingHost, + Port: webhookInstallOptions.LocalServingPort, + CertDir: webhookInstallOptions.LocalServingCertDir, + }), }) if err != nil { return err diff --git a/pkg/eventing/manager_test.go b/pkg/eventing/manager_test.go index fc177939..abc31636 100644 --- a/pkg/eventing/manager_test.go +++ b/pkg/eventing/manager_test.go @@ -10,7 +10,7 @@ import ( "github.com/kyma-project/eventing-manager/test" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" @@ -163,8 +163,8 @@ func Test_migratePublisherDeploymentFromEC(t *testing.T) { Kind: "Deployment", Name: "eventing-controller", UID: "a3cdcc7b-6853-4772-99cc-fc1511399d63", - Controller: pointer.Bool(true), - BlockOwnerDeletion: pointer.Bool(true), + Controller: ptr.To(true), + BlockOwnerDeletion: ptr.To(true), }} return oldPublisher }, @@ -191,8 +191,8 @@ func Test_migratePublisherDeploymentFromEC(t *testing.T) { Kind: "Deployment", Name: "eventing-manager", UID: "a3cdcc7b-6853-4772-99cc-fc1511399d63", - Controller: pointer.Bool(true), - BlockOwnerDeletion: pointer.Bool(true), + Controller: ptr.To(true), + BlockOwnerDeletion: ptr.To(true), }} return oldPublisher }, diff --git a/pkg/k8s/client.go b/pkg/k8s/client.go index 7e6d567d..4b3a5f08 100644 --- a/pkg/k8s/client.go +++ b/pkg/k8s/client.go @@ -20,7 +20,7 @@ import ( apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" k8sclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -147,7 +147,7 @@ func (c *KubeClient) GetNATSResources(ctx context.Context, namespace string) (*n // The object must define `GVK` (i.e. object.TypeMeta). func (c *KubeClient) PatchApply(ctx context.Context, object client.Object) error { return c.client.Patch(ctx, object, client.Apply, &client.PatchOptions{ - Force: pointer.Bool(true), + Force: ptr.To(true), FieldManager: c.fieldManager, }) } diff --git a/pkg/object/equality_test.go b/pkg/object/equality_test.go index 47188ddc..47e3f6d2 100644 --- a/pkg/object/equality_test.go +++ b/pkg/object/equality_test.go @@ -9,7 +9,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" apigatewayv1beta1 "github.com/kyma-incubator/api-gateway/api/v1beta1" "github.com/kyma-project/eventing-manager/pkg/utils" @@ -638,88 +638,88 @@ func Test_ownerReferencesDeepEqual(t *testing.T) { { name: "same OwnerReferences and same order", givenOwnerReferences1: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), - ownerReference("v-1", "k-1", "n-1", "u-1", pointer.Bool(false), pointer.Bool(false)), - ownerReference("v-2", "k-2", "n-2", "u-2", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)), + ownerReference("v-1", "k-1", "n-1", "u-1", ptr.To(false), ptr.To(false)), + ownerReference("v-2", "k-2", "n-2", "u-2", ptr.To(false), ptr.To(false)), }, givenOwnerReferences2: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), - ownerReference("v-1", "k-1", "n-1", "u-1", pointer.Bool(false), pointer.Bool(false)), - ownerReference("v-2", "k-2", "n-2", "u-2", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)), + ownerReference("v-1", "k-1", "n-1", "u-1", ptr.To(false), ptr.To(false)), + ownerReference("v-2", "k-2", "n-2", "u-2", ptr.To(false), ptr.To(false)), }, wantEqual: true, }, { name: "same OwnerReferences but different order", givenOwnerReferences1: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), - ownerReference("v-1", "k-1", "n-1", "u-1", pointer.Bool(false), pointer.Bool(false)), - ownerReference("v-2", "k-2", "n-2", "u-2", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)), + ownerReference("v-1", "k-1", "n-1", "u-1", ptr.To(false), ptr.To(false)), + ownerReference("v-2", "k-2", "n-2", "u-2", ptr.To(false), ptr.To(false)), }, givenOwnerReferences2: []metav1.OwnerReference{ - ownerReference("v-2", "k-2", "n-2", "u-2", pointer.Bool(false), pointer.Bool(false)), - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), - ownerReference("v-1", "k-1", "n-1", "u-1", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-2", "k-2", "n-2", "u-2", ptr.To(false), ptr.To(false)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)), + ownerReference("v-1", "k-1", "n-1", "u-1", ptr.To(false), ptr.To(false)), }, wantEqual: true, }, { name: "different OwnerReference APIVersion", givenOwnerReferences1: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)), }, givenOwnerReferences2: []metav1.OwnerReference{ - ownerReference("v-1", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-1", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)), }, wantEqual: false, }, { name: "different OwnerReference Kind", givenOwnerReferences1: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)), }, givenOwnerReferences2: []metav1.OwnerReference{ - ownerReference("v-0", "k-1", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-1", "n-0", "u-0", ptr.To(false), ptr.To(false)), }, wantEqual: false, }, { name: "different OwnerReference Name", givenOwnerReferences1: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)), }, givenOwnerReferences2: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-1", "u-0", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-1", "u-0", ptr.To(false), ptr.To(false)), }, wantEqual: false, }, { name: "different OwnerReference UID", givenOwnerReferences1: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)), }, givenOwnerReferences2: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-1", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-0", "u-1", ptr.To(false), ptr.To(false)), }, wantEqual: false, }, { name: "different OwnerReference Controller", givenOwnerReferences1: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)), }, givenOwnerReferences2: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(true), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(true), ptr.To(false)), }, wantEqual: false, }, { name: "different OwnerReference BlockOwnerDeletion", givenOwnerReferences1: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(false)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(false)), }, givenOwnerReferences2: []metav1.OwnerReference{ - ownerReference("v-0", "k-0", "n-0", "u-0", pointer.Bool(false), pointer.Bool(true)), + ownerReference("v-0", "k-0", "n-0", "u-0", ptr.To(false), ptr.To(true)), }, wantEqual: false, }, diff --git a/test/utils/integration/integration.go b/test/utils/integration/integration.go index 2fc92e56..5eca36d7 100644 --- a/test/utils/integration/integration.go +++ b/test/utils/integration/integration.go @@ -37,6 +37,8 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" + "sigs.k8s.io/controller-runtime/pkg/metrics/server" + "sigs.k8s.io/controller-runtime/pkg/webhook" "github.com/kyma-project/eventing-manager/api/v1alpha1" eventingctrl "github.com/kyma-project/eventing-manager/internal/controller/eventing" @@ -145,9 +147,9 @@ func NewTestEnvironment(projectRootDir string, celValidationEnabled bool, ctrlMgr, err := ctrl.NewManager(envTestKubeCfg, ctrl.Options{ Scheme: scheme.Scheme, - Port: metricsPort, - MetricsBindAddress: "0", // disable - HealthProbeBindAddress: "0", // disable + HealthProbeBindAddress: "0", // disable + Metrics: server.Options{BindAddress: "0"}, // disable + WebhookServer: webhook.NewServer(webhook.Options{Port: metricsPort}), }) if err != nil { return nil, err