diff --git a/.gitignore b/.gitignore index 7a56d62e..1def06dc 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ module-config.yaml **/.env **/.env.dev +.env.aws diff --git a/.golangci.yaml b/.golangci.yaml index 090b5c22..7d92e801 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -108,6 +108,8 @@ linters-settings: alias: eventingtesting - pkg: sigs.k8s.io/controller-runtime alias: kctrl + - pkg: sigs.k8s.io/controller-runtime/pkg/reconcile + alias: kctrlruntimereconcile - pkg: sigs.k8s.io/controller-runtime/pkg/log alias: kctrllog - pkg: sigs.k8s.io/controller-runtime/pkg/client diff --git a/Makefile b/Makefile index 88d056ea..64f41aab 100644 --- a/Makefile +++ b/Makefile @@ -203,7 +203,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest ## Tool Versions KUSTOMIZE_VERSION ?= v5.0.0 -CONTROLLER_TOOLS_VERSION ?= v0.14.0 +CONTROLLER_TOOLS_VERSION ?= v0.16.1 GOLANG_CI_LINT_VERSION ?= v1.57 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" diff --git a/config/crd/bases/eventing.kyma-project.io_subscriptions.yaml b/config/crd/bases/eventing.kyma-project.io_subscriptions.yaml index 0c48ea2f..4f9291b7 100644 --- a/config/crd/bases/eventing.kyma-project.io_subscriptions.yaml +++ b/config/crd/bases/eventing.kyma-project.io_subscriptions.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.14.0 + controller-gen.kubebuilder.io/version: v0.16.1 name: subscriptions.eventing.kyma-project.io spec: group: eventing.kyma-project.io diff --git a/config/crd/bases/operator.kyma-project.io_eventings.yaml b/config/crd/bases/operator.kyma-project.io_eventings.yaml index 714c26fc..e8cf39c9 100644 --- a/config/crd/bases/operator.kyma-project.io_eventings.yaml +++ b/config/crd/bases/operator.kyma-project.io_eventings.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.14.0 + controller-gen.kubebuilder.io/version: v0.16.1 name: eventings.operator.kyma-project.io spec: group: operator.kyma-project.io @@ -209,11 +209,9 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. - This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. - This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry in PodSpec.ResourceClaims. @@ -224,6 +222,12 @@ spec: the Pod where this field is used. It makes that resource available inside a container. type: string + request: + description: |- + Request is the name chosen for a request in the referenced claim. + If empty, everything from the claim is made available, otherwise + only the result of this request. + type: string required: - name type: object @@ -268,16 +272,8 @@ spec: type: string conditions: items: - description: "Condition contains details for one aspect of the current - state of this API Resource.\n---\nThis struct is intended for - direct use as an array at the field path .status.conditions. For - example,\n\n\n\ttype FooStatus struct{\n\t // Represents the - observations of a foo's current state.\n\t // Known .status.conditions.type - are: \"Available\", \"Progressing\", and \"Degraded\"\n\t // - +patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t - \ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\" - patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t - \ // other fields\n\t}" + description: Condition contains details for one aspect of the current + state of this API Resource. properties: lastTransitionTime: description: |- @@ -318,12 +314,7 @@ spec: - Unknown type: string type: - description: |- - type of condition in CamelCase or in foo.example.com/CamelCase. - --- - Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be - useful (see .node.status.conditions), the ability to deconflict is important. - The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + description: type of condition in CamelCase or in foo.example.com/CamelCase. maxLength: 316 pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ type: string diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index f36694b5..41cda79d 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -8,37 +8,9 @@ rules: - "" resources: - configmaps - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch -- apiGroups: - - "" - resources: - secrets - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - "" - resources: - serviceaccounts + - services verbs: - create - delete @@ -50,30 +22,14 @@ rules: - apiGroups: - "" resources: - - services + - events verbs: - create - - delete - - get - - list - patch - - update - - watch - apiGroups: - admissionregistration.k8s.io resources: - mutatingwebhookconfigurations - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - admissionregistration.k8s.io - resources: - validatingwebhookconfigurations verbs: - create @@ -85,6 +41,7 @@ rules: - watch - apiGroups: - apiextensions.k8s.io + - security.istio.io resources: - customresourcedefinitions verbs: @@ -197,17 +154,6 @@ rules: - rbac.authorization.k8s.io resources: - clusterrolebindings - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - rbac.authorization.k8s.io - resources: - clusterroles verbs: - create @@ -217,14 +163,6 @@ rules: - patch - update - watch -- apiGroups: - - security.istio.io - resources: - - customresourcedefinitions - verbs: - - get - - list - - watch - apiGroups: - security.istio.io resources: diff --git a/go.mod b/go.mod index c76e4b66..3860d243 100644 --- a/go.mod +++ b/go.mod @@ -26,14 +26,14 @@ require ( go.uber.org/zap v1.27.0 golang.org/x/oauth2 v0.22.0 golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 - istio.io/api v1.22.3 - istio.io/client-go v1.22.3 - k8s.io/api v0.30.3 - k8s.io/apiextensions-apiserver v0.30.3 - k8s.io/apimachinery v0.30.3 - k8s.io/client-go v0.30.3 + istio.io/api v1.23.0 + istio.io/client-go v1.23.0 + k8s.io/api v0.31.0 + k8s.io/apiextensions-apiserver v0.31.0 + k8s.io/apimachinery v0.31.0 + k8s.io/client-go v0.31.0 k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 - sigs.k8s.io/controller-runtime v0.18.4 + sigs.k8s.io/controller-runtime v0.19.0 ) require ( @@ -42,9 +42,9 @@ require ( github.com/chigopher/pathlib v0.19.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch v5.7.0+incompatible // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-openapi/jsonpointer v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.22.4 // indirect @@ -78,20 +78,20 @@ require ( github.com/nats-io/nuid v1.0.1 // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/pelletier/go-toml/v2 v2.0.6 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/zerolog v1.29.0 // indirect github.com/spf13/afero v1.9.3 // indirect github.com/spf13/cast v1.6.0 // indirect - github.com/spf13/cobra v1.8.0 // indirect + github.com/spf13/cobra v1.8.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.15.0 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.4.2 // indirect + github.com/x448/float16 v0.8.4 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect @@ -104,14 +104,15 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.23.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/klog/v2 v2.120.1 // indirect + k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect diff --git a/go.sum b/go.sum index 09d818ef..42969358 100644 --- a/go.sum +++ b/go.sum @@ -61,7 +61,7 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -85,6 +85,8 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -168,8 +170,8 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -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/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2Rrd27c3VGxi6a/6HNq8QmHRKM= +github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -277,8 +279,9 @@ github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.20.1 h1:IMJXHOD6eARkQpxo8KkhgEVFlBNm+nkrFUyGlIu7Na8= github.com/prometheus/client_golang v1.20.1/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -289,8 +292,8 @@ github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65 github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= @@ -299,8 +302,8 @@ github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk= github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -328,6 +331,8 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/vektra/mockery/v2 v2.45.0 h1:TDKO9y0CPv+/gm7KVBOJfzMcBeK7Y044jvaNdgBBVik= github.com/vektra/mockery/v2 v2.45.0/go.mod h1:XNTE9RIu3deGAGQRVjP1VZxGpQNm0YedZx4oDs3prr8= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -634,8 +639,8 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= -google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -669,6 +674,8 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= +gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= @@ -692,20 +699,20 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -istio.io/api v1.22.3 h1:V59wgcCm2fK2r137QBsddCDHNg0efg/DauIWEB9DFz8= -istio.io/api v1.22.3/go.mod h1:S3l8LWqNYS9yT+d4bH+jqzH2lMencPkW7SKM1Cu9EyM= -istio.io/client-go v1.22.3 h1:4WocGQYVTASpfn7tj1yGE8f0sgxzbxOkg56HX1LJQ5U= -istio.io/client-go v1.22.3/go.mod h1:D/vNne1n5586423NgGXMnPgshE/99mQgnjnxK/Vw2yM= -k8s.io/api v0.30.3 h1:ImHwK9DCsPA9uoU3rVh4QHAHHK5dTSv1nxJUapx8hoQ= -k8s.io/api v0.30.3/go.mod h1:GPc8jlzoe5JG3pb0KJCSLX5oAFIW3/qNJITlDj8BH04= -k8s.io/apiextensions-apiserver v0.30.3 h1:oChu5li2vsZHx2IvnGP3ah8Nj3KyqG3kRSaKmijhB9U= -k8s.io/apiextensions-apiserver v0.30.3/go.mod h1:uhXxYDkMAvl6CJw4lrDN4CPbONkF3+XL9cacCT44kV4= -k8s.io/apimachinery v0.30.3 h1:q1laaWCmrszyQuSQCfNB8cFgCuDAoPszKY4ucAjDwHc= -k8s.io/apimachinery v0.30.3/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -k8s.io/client-go v0.30.3 h1:bHrJu3xQZNXIi8/MoxYtZBBWQQXwy16zqJwloXXfD3k= -k8s.io/client-go v0.30.3/go.mod h1:8d4pf8vYu665/kUbsxWAQ/JDBNWqfFeZnvFiVdmx89U= -k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= -k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +istio.io/api v1.23.0 h1:yqv3lNW6XSYS5XkbEkxsmFROXIQznp4lFWqj7xKEqCA= +istio.io/api v1.23.0/go.mod h1:QPSTGXuIQdnZFEm3myf9NZ5uBMwCdJWUvfj9ZZ+2oBM= +istio.io/client-go v1.23.0 h1://xojbifr84q29WE3eMx74p36hD4lvcejX1KxE3iJvY= +istio.io/client-go v1.23.0/go.mod h1:3qX/KBS5aR47QV4JhphcZl5ysnZ53x78TBjNQLM2TC4= +k8s.io/api v0.31.0 h1:b9LiSjR2ym/SzTOlfMHm1tr7/21aD7fSkqgD/CVJBCo= +k8s.io/api v0.31.0/go.mod h1:0YiFF+JfFxMM6+1hQei8FY8M7s1Mth+z/q7eF1aJkTE= +k8s.io/apiextensions-apiserver v0.31.0 h1:fZgCVhGwsclj3qCw1buVXCV6khjRzKC5eCFt24kyLSk= +k8s.io/apiextensions-apiserver v0.31.0/go.mod h1:b9aMDEYaEe5sdK+1T0KU78ApR/5ZVp4i56VacZYEHxk= +k8s.io/apimachinery v0.31.0 h1:m9jOiSr3FoSSL5WO9bjm1n6B9KROYYgNZOb4tyZ1lBc= +k8s.io/apimachinery v0.31.0/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= +k8s.io/client-go v0.31.0 h1:QqEJzNjbN2Yv1H79SsS+SWnXkBgVu4Pj3CJQgbx0gI8= +k8s.io/client-go v0.31.0/go.mod h1:Y9wvC76g4fLjmU0BA+rV+h2cncoadjvjjkkIGoTLcGU= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= @@ -713,8 +720,8 @@ k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/controller-runtime v0.18.4 h1:87+guW1zhvuPLh1PHybKdYFLU0YJp4FhJRmiHvm5BZw= -sigs.k8s.io/controller-runtime v0.18.4/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg= +sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q= +sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= 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.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= diff --git a/hack/ci/Makefile b/hack/ci/Makefile index fef5070e..321e97b6 100644 --- a/hack/ci/Makefile +++ b/hack/ci/Makefile @@ -56,27 +56,27 @@ apply-peerauthentication-crd: .PHONY: wait-nats-cr-ready wait-nats-cr-ready: - kubectl wait nats.operator.kyma-project.io -n kyma-system eventing-nats --timeout=300s --for=jsonpath='{.status.state}'=Ready + kubectl wait nats.operator.kyma-project.io -n kyma-system eventing-nats --timeout=600s --for=jsonpath='{.status.state}'=Ready .PHONY: wait-nats-cr-warning wait-nats-cr-warning: - kubectl wait nats.operator.kyma-project.io -n kyma-system eventing-nats --timeout=300s --for=jsonpath='{.status.state}'=Warning + kubectl wait nats.operator.kyma-project.io -n kyma-system eventing-nats --timeout=600s --for=jsonpath='{.status.state}'=Warning .PHONY: wait-eventing-cr-ready wait-eventing-cr-ready: - kubectl wait eventing.operator.kyma-project.io -n kyma-system eventing --timeout=300s --for=jsonpath='{.status.state}'=Ready + kubectl wait eventing.operator.kyma-project.io -n kyma-system eventing --timeout=600s --for=jsonpath='{.status.state}'=Ready .PHONY: wait-eventing-cr-ready-with-backend wait-eventing-cr-ready-with-backend: - kubectl wait eventing.operator.kyma-project.io -n kyma-system eventing --timeout=300s --for=jsonpath='{.status.state}'=Ready --for=jsonpath='{.status.activeBackend}'=${ACTIVE_BACKEND} + kubectl wait eventing.operator.kyma-project.io -n kyma-system eventing --timeout=600s --for=jsonpath='{.status.state}'=Ready --for=jsonpath='{.status.activeBackend}'=${ACTIVE_BACKEND} .PHONY: wait-istio-cr-ready wait-istio-cr-ready: - kubectl wait istios.operator.kyma-project.io -n kyma-system default --timeout=300s --for=jsonpath='{.status.state}'=Ready + kubectl wait istios.operator.kyma-project.io -n kyma-system default --timeout=600s --for=jsonpath='{.status.state}'=Ready .PHONY: wait-api-gateway-cr-ready wait-api-gateway-cr-ready: - kubectl wait apigateways.operator.kyma-project.io -n kyma-system default --timeout=300s --for=jsonpath='{.status.state}'=Ready + kubectl wait apigateways.operator.kyma-project.io -n kyma-system default --timeout=600s --for=jsonpath='{.status.state}'=Ready .PHONY: provision-gardener-cluster provision-gardener-cluster: diff --git a/internal/connection/nats/mocks/builder.go b/internal/connection/nats/mocks/builder.go index 8ab36d3f..28a6fa84 100644 --- a/internal/connection/nats/mocks/builder.go +++ b/internal/connection/nats/mocks/builder.go @@ -15,3 +15,7 @@ func NewBuilder(conn *Connection) *Builder { func (b *Builder) Build() natsconnection.Interface { return b.conn } + +func (b *Builder) SetConnection(conn *Connection) { + b.conn = conn +} diff --git a/internal/connection/nats/mocks/connection.go b/internal/connection/nats/mocks/connection.go index 39ba1cba..ca9010f9 100644 --- a/internal/connection/nats/mocks/connection.go +++ b/internal/connection/nats/mocks/connection.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/internal/controller/eventing/subscription/eventmesh/reconciler.go b/internal/controller/eventing/subscription/eventmesh/reconciler.go index 79231c26..4b269c4b 100644 --- a/internal/controller/eventing/subscription/eventmesh/reconciler.go +++ b/internal/controller/eventing/subscription/eventmesh/reconciler.go @@ -19,6 +19,7 @@ import ( klabels "k8s.io/apimachinery/pkg/labels" ktypes "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" + "k8s.io/utils/ptr" kctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" @@ -753,7 +754,8 @@ func (r *Reconciler) emitConditionEvent(subscription *eventingv1alpha2.Subscript // SetupUnmanaged creates a controller under the client control. func (r *Reconciler) SetupUnmanaged(ctx context.Context, mgr kctrl.Manager) error { - ctru, err := controller.NewUnmanaged(reconcilerName, mgr, controller.Options{Reconciler: r}) + opts := controller.Options{Reconciler: r, SkipNameValidation: ptr.To(true)} + ctru, err := controller.NewUnmanaged(reconcilerName, mgr, opts) if err != nil { return fmt.Errorf("failed to create unmanaged controller: %w", err) } diff --git a/internal/controller/eventing/subscription/jetstream/reconciler.go b/internal/controller/eventing/subscription/jetstream/reconciler.go index 2190bf2d..0aedf564 100644 --- a/internal/controller/eventing/subscription/jetstream/reconciler.go +++ b/internal/controller/eventing/subscription/jetstream/reconciler.go @@ -11,6 +11,7 @@ import ( "go.uber.org/zap" ktypes "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" + "k8s.io/utils/ptr" kctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" @@ -68,7 +69,8 @@ func NewReconciler(client client.Client, jsBackend jetstream.Backend, // SetupUnmanaged creates a controller under the client control. func (r *Reconciler) SetupUnmanaged(ctx context.Context, mgr kctrl.Manager) error { - ctru, err := controller.NewUnmanaged(reconcilerName, mgr, controller.Options{Reconciler: r}) + opts := controller.Options{Reconciler: r, SkipNameValidation: ptr.To(true)} + ctru, err := controller.NewUnmanaged(reconcilerName, mgr, opts) if err != nil { r.namedLogger().Errorw("Failed to create unmanaged controller", "error", err) return err diff --git a/internal/controller/eventing/subscription/validator/mocks/SubscriptionValidator.go b/internal/controller/eventing/subscription/validator/mocks/SubscriptionValidator.go index e895a12c..694be215 100644 --- a/internal/controller/eventing/subscription/validator/mocks/SubscriptionValidator.go +++ b/internal/controller/eventing/subscription/validator/mocks/SubscriptionValidator.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/internal/controller/operator/eventing/controller.go b/internal/controller/operator/eventing/controller.go index 3fc1c278..3e135be1 100644 --- a/internal/controller/operator/eventing/controller.go +++ b/internal/controller/operator/eventing/controller.go @@ -83,7 +83,7 @@ var ( // Reconciler reconciles an Eventing object // -//go:generate go run github.com/vektra/mockery/v2 --name=Controller --dir=../../../../vendor/sigs.k8s.io/controller-runtime/pkg/controller --outpkg=mocks --case=underscore +//go:generate go run github.com/vektra/mockery/v2 --name=TypedController --dir=../../../../vendor/sigs.k8s.io/controller-runtime/pkg/controller --outpkg=mocks --case=underscore //go:generate go run github.com/vektra/mockery/v2 --name=Manager --dir=../../../../vendor/sigs.k8s.io/controller-runtime/pkg/manager --outpkg=mocks --case=underscore type Reconciler struct { client.Client @@ -369,23 +369,10 @@ func (r *Reconciler) startNATSCRWatch(eventing *operatorv1alpha1.Eventing) error }, ) - typedResourceVersionChangedPredicate := predicate.TypedFuncs[client.Object]{ - UpdateFunc: func(event event.TypedUpdateEvent[client.Object]) bool { - if event.ObjectOld == nil { - return false - } - if event.ObjectNew == nil { - return false - } - - return event.ObjectNew.GetResourceVersion() != event.ObjectOld.GetResourceVersion() - }, - } - src := source.Channel[client.Object]( natsWatcher.GetEventsChannel(), resourceHandler, - source.WithPredicates[client.Object](typedResourceVersionChangedPredicate), + source.WithPredicates[client.Object, kctrl.Request](predicate.ResourceVersionChangedPredicate{}), ) if err := r.controller.Watch(src); err != nil { @@ -724,6 +711,13 @@ func (r *Reconciler) SetKubeClient(kubeClient k8s.Client) { r.kubeClient = kubeClient } +func (r *Reconciler) ResetNATSConnection() { + if r.natsConnection != nil { + r.natsConnection.Disconnect() + } + r.natsConnection = nil +} + func (r *Reconciler) namedLogger() *zap.SugaredLogger { return r.logger.WithContext().Named(ControllerName) } diff --git a/internal/controller/operator/eventing/integrationtests/natsconnection/integration_test.go b/internal/controller/operator/eventing/integrationtests/natsconnection/integration_test.go index b290587e..5ba4f2f2 100644 --- a/internal/controller/operator/eventing/integrationtests/natsconnection/integration_test.go +++ b/internal/controller/operator/eventing/integrationtests/natsconnection/integration_test.go @@ -1,6 +1,7 @@ package natsconnection import ( + "os" "testing" natstestutils "github.com/kyma-project/nats-manager/testutils" @@ -8,7 +9,6 @@ import ( gomegatypes "github.com/onsi/gomega/types" "github.com/pkg/errors" "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" kappsv1 "k8s.io/api/apps/v1" operatorv1alpha1 "github.com/kyma-project/eventing-manager/api/operator/v1alpha1" @@ -20,7 +20,41 @@ import ( testutilsintegration "github.com/kyma-project/eventing-manager/test/utils/integration" ) +const ( + projectRootDir = "../../../../../../" +) + +var testEnvironment *testutilsintegration.TestEnvironment + +// TestMain pre-hook and post-hook to run before and after all tests. +func TestMain(m *testing.M) { + // Note: The setup will provision a single K8s env and + // all the tests need to create and use a separate namespace + + // setup env test + var err error + testEnvironment, err = testutilsintegration.NewTestEnvironment(testutilsintegration.TestEnvironmentConfig{ + ProjectRootDir: projectRootDir, + NATSCRDEnabled: true, + }, nil) + if err != nil { + panic(err) + } + + // run tests + code := m.Run() + + // tear down test env + if err = testEnvironment.TearDown(); err != nil { + panic(err) + } + + os.Exit(code) +} + // Test_NATSConnection tests the Eventing CR status when connecting to NATS. +// +//nolint:tparallel // test-cases uses a shared NATSConnectionBuilder and requires different mocks. func Test_NATSConnection(t *testing.T) { t.Parallel() // given @@ -38,6 +72,7 @@ func Test_NATSConnection(t *testing.T) { conn := &natsconnectionmocks.Connection{} conn.On("Connect", mock.Anything, mock.Anything).Return(nil) conn.On("IsConnected").Return(true) + conn.On("Disconnect").Return() return conn }, wantMatches: gomega.And( @@ -53,6 +88,7 @@ func Test_NATSConnection(t *testing.T) { conn := &natsconnectionmocks.Connection{} conn.On("Connect", mock.Anything, mock.Anything).Return(natsconnectionerrors.ErrCannotConnect) conn.On("IsConnected").Return(false) + conn.On("Disconnect").Return() return conn }, wantMatches: gomega.And( @@ -70,6 +106,7 @@ func Test_NATSConnection(t *testing.T) { conn := &natsconnectionmocks.Connection{} conn.On("Connect", mock.Anything, mock.Anything).Return(ErrAny) conn.On("IsConnected").Return(false) + conn.On("Disconnect").Return() return conn }, wantMatches: gomega.And( @@ -84,21 +121,12 @@ func Test_NATSConnection(t *testing.T) { } for _, tc := range testCases { - tcc := tc - - t.Run(tcc.name, func(t *testing.T) { - t.Parallel() - + tc := tc + t.Run(tc.name, func(t *testing.T) { // setup environment - testEnvironment, err := testutilsintegration.NewTestEnvironment( - testutilsintegration.TestEnvironmentConfig{ - NATSCRDEnabled: true, - ProjectRootDir: "../../../../../../", - }, - tcc.givenNATSConnectionMock(), - ) - require.NoError(t, err) - defer func() { require.NoError(t, testEnvironment.TearDown()) }() // always cleanup + testEnvironment.Reconciler.ResetNATSConnection() + testEnvironment.NATSConnectionBuilder.SetConnection(tc.givenNATSConnectionMock()) + eventingcontroller.IsDeploymentReady = func(deployment *kappsv1.Deployment) bool { return true } // prepare resources @@ -112,7 +140,7 @@ func Test_NATSConnection(t *testing.T) { testEnvironment.EnsureK8sResourceCreated(t, eventingCR) // then - testEnvironment.GetEventingAssert(gomega.NewWithT(t), eventingCR).Should(tcc.wantMatches) + testEnvironment.GetEventingAssert(gomega.NewWithT(t), eventingCR).Should(tc.wantMatches) }) } } diff --git a/internal/controller/operator/eventing/mocks/controller.go b/internal/controller/operator/eventing/mocks/controller.go index 4ac9ec27..e42828cd 100644 --- a/internal/controller/operator/eventing/mocks/controller.go +++ b/internal/controller/operator/eventing/mocks/controller.go @@ -1,236 +1,10 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. - package mocks import ( - context "context" - - logr "github.com/go-logr/logr" - - mock "github.com/stretchr/testify/mock" - - reconcile "sigs.k8s.io/controller-runtime/pkg/reconcile" - - source "sigs.k8s.io/controller-runtime/pkg/source" + kctrlruntimereconcile "sigs.k8s.io/controller-runtime/pkg/reconcile" ) -// Controller is an autogenerated mock type for the Controller type -type Controller struct { - mock.Mock -} - -type Controller_Expecter struct { - mock *mock.Mock -} - -func (_m *Controller) EXPECT() *Controller_Expecter { - return &Controller_Expecter{mock: &_m.Mock} -} - -// GetLogger provides a mock function with given fields: -func (_m *Controller) GetLogger() logr.Logger { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetLogger") - } - - var r0 logr.Logger - if rf, ok := ret.Get(0).(func() logr.Logger); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(logr.Logger) - } - - return r0 -} - -// Controller_GetLogger_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLogger' -type Controller_GetLogger_Call struct { - *mock.Call -} - -// GetLogger is a helper method to define mock.On call -func (_e *Controller_Expecter) GetLogger() *Controller_GetLogger_Call { - return &Controller_GetLogger_Call{Call: _e.mock.On("GetLogger")} -} - -func (_c *Controller_GetLogger_Call) Run(run func()) *Controller_GetLogger_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *Controller_GetLogger_Call) Return(_a0 logr.Logger) *Controller_GetLogger_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *Controller_GetLogger_Call) RunAndReturn(run func() logr.Logger) *Controller_GetLogger_Call { - _c.Call.Return(run) - return _c -} - -// Reconcile provides a mock function with given fields: _a0, _a1 -func (_m *Controller) Reconcile(_a0 context.Context, _a1 reconcile.Request) (reconcile.Result, error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for Reconcile") - } - - var r0 reconcile.Result - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, reconcile.Request) (reconcile.Result, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, reconcile.Request) reconcile.Result); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Get(0).(reconcile.Result) - } - - if rf, ok := ret.Get(1).(func(context.Context, reconcile.Request) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Controller_Reconcile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Reconcile' -type Controller_Reconcile_Call struct { - *mock.Call -} - -// Reconcile is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 reconcile.Request -func (_e *Controller_Expecter) Reconcile(_a0 interface{}, _a1 interface{}) *Controller_Reconcile_Call { - return &Controller_Reconcile_Call{Call: _e.mock.On("Reconcile", _a0, _a1)} -} - -func (_c *Controller_Reconcile_Call) Run(run func(_a0 context.Context, _a1 reconcile.Request)) *Controller_Reconcile_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(reconcile.Request)) - }) - return _c -} - -func (_c *Controller_Reconcile_Call) Return(_a0 reconcile.Result, _a1 error) *Controller_Reconcile_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *Controller_Reconcile_Call) RunAndReturn(run func(context.Context, reconcile.Request) (reconcile.Result, error)) *Controller_Reconcile_Call { - _c.Call.Return(run) - return _c -} - -// Start provides a mock function with given fields: ctx -func (_m *Controller) Start(ctx context.Context) error { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for Start") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context) error); ok { - r0 = rf(ctx) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Controller_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' -type Controller_Start_Call struct { - *mock.Call -} - -// Start is a helper method to define mock.On call -// - ctx context.Context -func (_e *Controller_Expecter) Start(ctx interface{}) *Controller_Start_Call { - return &Controller_Start_Call{Call: _e.mock.On("Start", ctx)} -} - -func (_c *Controller_Start_Call) Run(run func(ctx context.Context)) *Controller_Start_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *Controller_Start_Call) Return(_a0 error) *Controller_Start_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *Controller_Start_Call) RunAndReturn(run func(context.Context) error) *Controller_Start_Call { - _c.Call.Return(run) - return _c -} - -// Watch provides a mock function with given fields: src -func (_m *Controller) Watch(src source.Source) error { - ret := _m.Called(src) - - if len(ret) == 0 { - panic("no return value specified for Watch") - } - - var r0 error - if rf, ok := ret.Get(0).(func(source.Source) error); ok { - r0 = rf(src) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Controller_Watch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Watch' -type Controller_Watch_Call struct { - *mock.Call -} - -// Watch is a helper method to define mock.On call -// - src source.Source -func (_e *Controller_Expecter) Watch(src interface{}) *Controller_Watch_Call { - return &Controller_Watch_Call{Call: _e.mock.On("Watch", src)} -} - -func (_c *Controller_Watch_Call) Run(run func(src source.Source)) *Controller_Watch_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(source.Source)) - }) - return _c -} - -func (_c *Controller_Watch_Call) Return(_a0 error) *Controller_Watch_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *Controller_Watch_Call) RunAndReturn(run func(source.Source) error) *Controller_Watch_Call { - _c.Call.Return(run) - return _c -} - -// NewController creates a new instance of Controller. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewController(t interface { - mock.TestingT - Cleanup(func()) -}) *Controller { - mock := &Controller{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) +// Update it when the issue: https://github.com/vektra/mockery/issues/787#issuecomment-2296180438 is fixed. - return mock -} +// Controller is an autogenerated mock type for the Controller type. +type Controller = TypedController[kctrlruntimereconcile.Request] diff --git a/internal/controller/operator/eventing/mocks/manager.go b/internal/controller/operator/eventing/mocks/manager.go index fadd52e0..5fc48c22 100644 --- a/internal/controller/operator/eventing/mocks/manager.go +++ b/internal/controller/operator/eventing/mocks/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/internal/controller/operator/eventing/mocks/nats_config_handler.go b/internal/controller/operator/eventing/mocks/nats_config_handler.go index ab74fb43..81421d69 100644 --- a/internal/controller/operator/eventing/mocks/nats_config_handler.go +++ b/internal/controller/operator/eventing/mocks/nats_config_handler.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/internal/controller/operator/eventing/mocks/typed_controller.go b/internal/controller/operator/eventing/mocks/typed_controller.go new file mode 100644 index 00000000..811b48f1 --- /dev/null +++ b/internal/controller/operator/eventing/mocks/typed_controller.go @@ -0,0 +1,236 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + logr "github.com/go-logr/logr" + + mock "github.com/stretchr/testify/mock" + + reconcile "sigs.k8s.io/controller-runtime/pkg/reconcile" + + source "sigs.k8s.io/controller-runtime/pkg/source" +) + +// TypedController is an autogenerated mock type for the TypedController type +type TypedController[request comparable] struct { + mock.Mock +} + +type TypedController_Expecter[request comparable] struct { + mock *mock.Mock +} + +func (_m *TypedController[request]) EXPECT() *TypedController_Expecter[request] { + return &TypedController_Expecter[request]{mock: &_m.Mock} +} + +// GetLogger provides a mock function with given fields: +func (_m *TypedController[request]) GetLogger() logr.Logger { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetLogger") + } + + var r0 logr.Logger + if rf, ok := ret.Get(0).(func() logr.Logger); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(logr.Logger) + } + + return r0 +} + +// TypedController_GetLogger_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLogger' +type TypedController_GetLogger_Call[request comparable] struct { + *mock.Call +} + +// GetLogger is a helper method to define mock.On call +func (_e *TypedController_Expecter[request]) GetLogger() *TypedController_GetLogger_Call[request] { + return &TypedController_GetLogger_Call[request]{Call: _e.mock.On("GetLogger")} +} + +func (_c *TypedController_GetLogger_Call[request]) Run(run func()) *TypedController_GetLogger_Call[request] { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *TypedController_GetLogger_Call[request]) Return(_a0 logr.Logger) *TypedController_GetLogger_Call[request] { + _c.Call.Return(_a0) + return _c +} + +func (_c *TypedController_GetLogger_Call[request]) RunAndReturn(run func() logr.Logger) *TypedController_GetLogger_Call[request] { + _c.Call.Return(run) + return _c +} + +// Reconcile provides a mock function with given fields: _a0, _a1 +func (_m *TypedController[request]) Reconcile(_a0 context.Context, _a1 reconcile.Request) (reconcile.Result, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for Reconcile") + } + + var r0 reconcile.Result + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, reconcile.Request) (reconcile.Result, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, reconcile.Request) reconcile.Result); ok { + r0 = rf(_a0, _a1) + } else { + r0 = ret.Get(0).(reconcile.Result) + } + + if rf, ok := ret.Get(1).(func(context.Context, reconcile.Request) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// TypedController_Reconcile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Reconcile' +type TypedController_Reconcile_Call[request comparable] struct { + *mock.Call +} + +// Reconcile is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 reconcile.Request +func (_e *TypedController_Expecter[request]) Reconcile(_a0 interface{}, _a1 interface{}) *TypedController_Reconcile_Call[request] { + return &TypedController_Reconcile_Call[request]{Call: _e.mock.On("Reconcile", _a0, _a1)} +} + +func (_c *TypedController_Reconcile_Call[request]) Run(run func(_a0 context.Context, _a1 reconcile.Request)) *TypedController_Reconcile_Call[request] { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(reconcile.Request)) + }) + return _c +} + +func (_c *TypedController_Reconcile_Call[request]) Return(_a0 reconcile.Result, _a1 error) *TypedController_Reconcile_Call[request] { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *TypedController_Reconcile_Call[request]) RunAndReturn(run func(context.Context, reconcile.Request) (reconcile.Result, error)) *TypedController_Reconcile_Call[request] { + _c.Call.Return(run) + return _c +} + +// Start provides a mock function with given fields: ctx +func (_m *TypedController[request]) Start(ctx context.Context) error { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for Start") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(ctx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// TypedController_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' +type TypedController_Start_Call[request comparable] struct { + *mock.Call +} + +// Start is a helper method to define mock.On call +// - ctx context.Context +func (_e *TypedController_Expecter[request]) Start(ctx interface{}) *TypedController_Start_Call[request] { + return &TypedController_Start_Call[request]{Call: _e.mock.On("Start", ctx)} +} + +func (_c *TypedController_Start_Call[request]) Run(run func(ctx context.Context)) *TypedController_Start_Call[request] { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *TypedController_Start_Call[request]) Return(_a0 error) *TypedController_Start_Call[request] { + _c.Call.Return(_a0) + return _c +} + +func (_c *TypedController_Start_Call[request]) RunAndReturn(run func(context.Context) error) *TypedController_Start_Call[request] { + _c.Call.Return(run) + return _c +} + +// Watch provides a mock function with given fields: src +func (_m *TypedController[request]) Watch(src source.TypedSource[reconcile.Request]) error { + ret := _m.Called(src) + + if len(ret) == 0 { + panic("no return value specified for Watch") + } + + var r0 error + if rf, ok := ret.Get(0).(func(source.TypedSource[reconcile.Request]) error); ok { + r0 = rf(src) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// TypedController_Watch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Watch' +type TypedController_Watch_Call[request comparable] struct { + *mock.Call +} + +// Watch is a helper method to define mock.On call +// - src source.TypedSource[reconcile.Request] +func (_e *TypedController_Expecter[request]) Watch(src interface{}) *TypedController_Watch_Call[request] { + return &TypedController_Watch_Call[request]{Call: _e.mock.On("Watch", src)} +} + +func (_c *TypedController_Watch_Call[request]) Run(run func(src source.TypedSource[reconcile.Request])) *TypedController_Watch_Call[request] { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(source.TypedSource[reconcile.Request])) + }) + return _c +} + +func (_c *TypedController_Watch_Call[request]) Return(_a0 error) *TypedController_Watch_Call[request] { + _c.Call.Return(_a0) + return _c +} + +func (_c *TypedController_Watch_Call[request]) RunAndReturn(run func(source.TypedSource[reconcile.Request]) error) *TypedController_Watch_Call[request] { + _c.Call.Return(run) + return _c +} + +// NewTypedController creates a new instance of TypedController. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewTypedController[request comparable](t interface { + mock.TestingT + Cleanup(func()) +}) *TypedController[request] { + mock := &TypedController[request]{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/backend/jetstream/mocks/Backend.go b/pkg/backend/jetstream/mocks/Backend.go index 0ef36654..d12389c5 100644 --- a/pkg/backend/jetstream/mocks/Backend.go +++ b/pkg/backend/jetstream/mocks/Backend.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/pkg/backend/jetstream/mocks/JetStreamContext.go b/pkg/backend/jetstream/mocks/JetStreamContext.go index fb677aba..3f833ba1 100644 --- a/pkg/backend/jetstream/mocks/JetStreamContext.go +++ b/pkg/backend/jetstream/mocks/JetStreamContext.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/pkg/ems/api/events/client/mocks/PublisherManager.go b/pkg/ems/api/events/client/mocks/PublisherManager.go index 4bdeed25..4ba90e7d 100644 --- a/pkg/ems/api/events/client/mocks/PublisherManager.go +++ b/pkg/ems/api/events/client/mocks/PublisherManager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/pkg/eventing/mocks/manager.go b/pkg/eventing/mocks/manager.go index 47a32542..5bd320d9 100644 --- a/pkg/eventing/mocks/manager.go +++ b/pkg/eventing/mocks/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/pkg/k8s/mocks/client.go b/pkg/k8s/mocks/client.go index 0f2e451e..c2334778 100644 --- a/pkg/k8s/mocks/client.go +++ b/pkg/k8s/mocks/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/pkg/subscriptionmanager/manager/mocks/manager.go b/pkg/subscriptionmanager/manager/mocks/manager.go index 4e9080b7..ba94d03c 100644 --- a/pkg/subscriptionmanager/manager/mocks/manager.go +++ b/pkg/subscriptionmanager/manager/mocks/manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/pkg/subscriptionmanager/mocks/manager_factory.go b/pkg/subscriptionmanager/mocks/manager_factory.go index 05f3fae3..7ae411f8 100644 --- a/pkg/subscriptionmanager/mocks/manager_factory.go +++ b/pkg/subscriptionmanager/mocks/manager_factory.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/pkg/watcher/mocks/watcher.go b/pkg/watcher/mocks/watcher.go index a29c8c0c..3ae1d6d2 100644 --- a/pkg/watcher/mocks/watcher.go +++ b/pkg/watcher/mocks/watcher.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks diff --git a/scripts/gardener/aws/provision.sh b/scripts/gardener/aws/provision.sh index e0433266..3489b9ae 100755 --- a/scripts/gardener/aws/provision.sh +++ b/scripts/gardener/aws/provision.sh @@ -35,7 +35,7 @@ gardener::validate_and_default() { utils::check_required_vars "${requiredVars[@]}" # validations - if [ "${CLUSTER_NAME}" -gt 9 ]; then + if [ "${#CLUSTER_NAME}" -gt 9 ]; then log::error "Provided cluster name is too long" return 1 fi diff --git a/test/utils/integration/integration.go b/test/utils/integration/integration.go index 23ad0120..44842f7f 100644 --- a/test/utils/integration/integration.go +++ b/test/utils/integration/integration.go @@ -66,16 +66,17 @@ const ( // TestEnvironment provides mocked resources for integration tests. type TestEnvironment struct { - EnvTestInstance *envtest.Environment - k8sClient client.Client - KubeClient k8s.Client - K8sDynamicClient *dynamic.DynamicClient - Reconciler *eventingcontroller.Reconciler - Logger *logger.Logger - Recorder *record.EventRecorder - TestCancelFn context.CancelFunc - SubManagerFactory subscriptionmanager.ManagerFactory - JetStreamSubManager manager.Manager + EnvTestInstance *envtest.Environment + k8sClient client.Client + KubeClient k8s.Client + K8sDynamicClient *dynamic.DynamicClient + Reconciler *eventingcontroller.Reconciler + Logger *logger.Logger + Recorder *record.EventRecorder + TestCancelFn context.CancelFunc + SubManagerFactory subscriptionmanager.ManagerFactory + JetStreamSubManager manager.Manager + NATSConnectionBuilder *natsconnectionmocks.Builder } type TestEnvironmentConfig struct { @@ -191,6 +192,7 @@ func NewTestEnvironment(config TestEnvironmentConfig, connMock *natsconnectionmo connMock.On("Disconnect").Return() } + natsConnectionBuilder := natsconnectionmocks.NewBuilder(connMock) // create a new watcher eventingReconciler := eventingcontroller.NewReconciler( k8sClient, @@ -204,7 +206,7 @@ func NewTestEnvironment(config TestEnvironmentConfig, connMock *natsconnectionmo subManagerFactoryMock, opts, config.AllowedEventingCR, - natsconnectionmocks.NewBuilder(connMock), + natsConnectionBuilder, ) if err = (eventingReconciler).SetupWithManager(ctrlMgr); err != nil { @@ -229,16 +231,17 @@ func NewTestEnvironment(config TestEnvironmentConfig, connMock *natsconnectionmo } return &TestEnvironment{ - k8sClient: k8sClient, - KubeClient: kubeClient, - K8sDynamicClient: dynamicClient, - Reconciler: eventingReconciler, - Logger: ctrLogger, - Recorder: &recorder, - EnvTestInstance: testEnv, - TestCancelFn: cancelCtx, - SubManagerFactory: subManagerFactoryMock, - JetStreamSubManager: jetStreamSubManagerMock, + k8sClient: k8sClient, + KubeClient: kubeClient, + K8sDynamicClient: dynamicClient, + Reconciler: eventingReconciler, + Logger: ctrLogger, + Recorder: &recorder, + EnvTestInstance: testEnv, + TestCancelFn: cancelCtx, + SubManagerFactory: subManagerFactoryMock, + JetStreamSubManager: jetStreamSubManagerMock, + NATSConnectionBuilder: natsConnectionBuilder, }, nil }