Skip to content

Commit bf5fa88

Browse files
authored
bump to go 1.22 and k8s 0.30.0 (#176)
Signed-off-by: everettraven <[email protected]>
1 parent b394e34 commit bf5fa88

File tree

12 files changed

+131
-119
lines changed

12 files changed

+131
-119
lines changed

go.mod

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
module github.com/operator-framework/operator-lib
22

3-
go 1.21
3+
go 1.22.0
44

55
require (
66
github.com/go-logr/logr v1.4.1
77
github.com/onsi/ginkgo/v2 v2.17.1
88
github.com/onsi/gomega v1.32.0
9-
github.com/operator-framework/api v0.23.0
9+
github.com/operator-framework/api v0.24.0
1010
github.com/prometheus/client_golang v1.19.0
1111
github.com/prometheus/client_model v0.6.1
12-
k8s.io/api v0.29.2
13-
k8s.io/apimachinery v0.29.2
14-
k8s.io/client-go v0.29.2
15-
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
16-
sigs.k8s.io/controller-runtime v0.17.2
12+
k8s.io/api v0.30.0
13+
k8s.io/apimachinery v0.30.0
14+
k8s.io/client-go v0.30.0
15+
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
16+
sigs.k8s.io/controller-runtime v0.18.2
1717
)
1818

1919
require (
@@ -22,15 +22,15 @@ require (
2222
github.com/davecgh/go-spew v1.1.1 // indirect
2323
github.com/emicklei/go-restful/v3 v3.11.2 // indirect
2424
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
25-
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
25+
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
2626
github.com/fsnotify/fsnotify v1.7.0 // indirect
2727
github.com/go-openapi/jsonpointer v0.20.2 // indirect
2828
github.com/go-openapi/jsonreference v0.20.4 // indirect
2929
github.com/go-openapi/swag v0.22.9 // indirect
3030
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
3131
github.com/gogo/protobuf v1.3.2 // indirect
3232
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
33-
github.com/golang/protobuf v1.5.3 // indirect
33+
github.com/golang/protobuf v1.5.4 // indirect
3434
github.com/google/gnostic-models v0.6.8 // indirect
3535
github.com/google/go-cmp v0.6.0 // indirect
3636
github.com/google/gofuzz v1.2.0 // indirect
@@ -48,10 +48,10 @@ require (
4848
github.com/prometheus/procfs v0.12.0 // indirect
4949
github.com/spf13/pflag v1.0.5 // indirect
5050
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect
51-
golang.org/x/net v0.21.0 // indirect
51+
golang.org/x/net v0.23.0 // indirect
5252
golang.org/x/oauth2 v0.17.0 // indirect
53-
golang.org/x/sys v0.17.0 // indirect
54-
golang.org/x/term v0.17.0 // indirect
53+
golang.org/x/sys v0.18.0 // indirect
54+
golang.org/x/term v0.18.0 // indirect
5555
golang.org/x/text v0.14.0 // indirect
5656
golang.org/x/time v0.5.0 // indirect
5757
golang.org/x/tools v0.18.0 // indirect
@@ -61,10 +61,9 @@ require (
6161
gopkg.in/inf.v0 v0.9.1 // indirect
6262
gopkg.in/yaml.v2 v2.4.0 // indirect
6363
gopkg.in/yaml.v3 v3.0.1 // indirect
64-
k8s.io/apiextensions-apiserver v0.29.2 // indirect
65-
k8s.io/component-base v0.29.2 // indirect
64+
k8s.io/apiextensions-apiserver v0.30.0 // indirect
6665
k8s.io/klog/v2 v2.120.1 // indirect
67-
k8s.io/kube-openapi v0.0.0-20240221221325-2ac9dc51f3f1 // indirect
66+
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
6867
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
6968
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
7069
sigs.k8s.io/yaml v1.4.0 // indirect

go.sum

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/emicklei/go-restful/v3 v3.11.2 h1:1onLa9DcsMYO9P+CXaL0dStDqQ2EHHXLiz+
99
github.com/emicklei/go-restful/v3 v3.11.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
1010
github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U=
1111
github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
12-
github.com/evanphx/json-patch/v5 v5.8.0 h1:lRj6N9Nci7MvzrXuX6HFzU8XjmhPiXPlsKEy1u0KQro=
13-
github.com/evanphx/json-patch/v5 v5.8.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
12+
github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg=
13+
github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
1414
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
1515
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
1616
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
@@ -31,8 +31,8 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l
3131
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
3232
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
3333
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
34-
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
35-
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
34+
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
35+
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
3636
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
3737
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
3838
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
@@ -71,8 +71,8 @@ github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8
7171
github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
7272
github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk=
7373
github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg=
74-
github.com/operator-framework/api v0.23.0 h1:kHymOwcHBpBVujT49SKOCd4EVG7Odwj4wl3NbOR2LLA=
75-
github.com/operator-framework/api v0.23.0/go.mod h1:oKcFOz+Xc1UhMi2Pzcp6qsO7wjS4r+yP7EQprQBXrfM=
74+
github.com/operator-framework/api v0.24.0 h1:fHynWEzuY/YhUTlsK9hd+QQ0bZcFakxCTdaZbFaVXbc=
75+
github.com/operator-framework/api v0.24.0/go.mod h1:EXKrka63NyQDDpWZ+DGTDEliNV0xRq6UMZRoUPhilVM=
7676
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
7777
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
7878
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -118,8 +118,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
118118
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
119119
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
120120
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
121-
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
122-
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
121+
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
122+
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
123123
golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ=
124124
golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA=
125125
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -133,12 +133,12 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
133133
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
134134
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
135135
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
136-
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
137-
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
136+
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
137+
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
138138
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
139139
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
140-
golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U=
141-
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
140+
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
141+
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
142142
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
143143
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
144144
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
@@ -177,24 +177,22 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
177177
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
178178
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
179179
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
180-
k8s.io/api v0.29.2 h1:hBC7B9+MU+ptchxEqTNW2DkUosJpp1P+Wn6YncZ474A=
181-
k8s.io/api v0.29.2/go.mod h1:sdIaaKuU7P44aoyyLlikSLayT6Vb7bvJNCX105xZXY0=
182-
k8s.io/apiextensions-apiserver v0.29.2 h1:UK3xB5lOWSnhaCk0RFZ0LUacPZz9RY4wi/yt2Iu+btg=
183-
k8s.io/apiextensions-apiserver v0.29.2/go.mod h1:aLfYjpA5p3OwtqNXQFkhJ56TB+spV8Gc4wfMhUA3/b8=
184-
k8s.io/apimachinery v0.29.2 h1:EWGpfJ856oj11C52NRCHuU7rFDwxev48z+6DSlGNsV8=
185-
k8s.io/apimachinery v0.29.2/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU=
186-
k8s.io/client-go v0.29.2 h1:FEg85el1TeZp+/vYJM7hkDlSTFZ+c5nnK44DJ4FyoRg=
187-
k8s.io/client-go v0.29.2/go.mod h1:knlvFZE58VpqbQpJNbCbctTVXcd35mMyAAwBdpt4jrA=
188-
k8s.io/component-base v0.29.2 h1:lpiLyuvPA9yV1aQwGLENYyK7n/8t6l3nn3zAtFTJYe8=
189-
k8s.io/component-base v0.29.2/go.mod h1:BfB3SLrefbZXiBfbM+2H1dlat21Uewg/5qtKOl8degM=
180+
k8s.io/api v0.30.0 h1:siWhRq7cNjy2iHssOB9SCGNCl2spiF1dO3dABqZ8niA=
181+
k8s.io/api v0.30.0/go.mod h1:OPlaYhoHs8EQ1ql0R/TsUgaRPhpKNxIMrKQfWUp8QSE=
182+
k8s.io/apiextensions-apiserver v0.30.0 h1:jcZFKMqnICJfRxTgnC4E+Hpcq8UEhT8B2lhBcQ+6uAs=
183+
k8s.io/apiextensions-apiserver v0.30.0/go.mod h1:N9ogQFGcrbWqAY9p2mUAL5mGxsLqwgtUce127VtRX5Y=
184+
k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA=
185+
k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc=
186+
k8s.io/client-go v0.30.0 h1:sB1AGGlhY/o7KCyCEQ0bPWzYDL0pwOZO4vAtTSh/gJQ=
187+
k8s.io/client-go v0.30.0/go.mod h1:g7li5O5256qe6TYdAMyX/otJqMhIiGgTapdLchhmOaY=
190188
k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
191189
k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
192-
k8s.io/kube-openapi v0.0.0-20240221221325-2ac9dc51f3f1 h1:rtdnaWfP40MTKv7izH81gkWpZB45pZrwIxyZdPSn1mI=
193-
k8s.io/kube-openapi v0.0.0-20240221221325-2ac9dc51f3f1/go.mod h1:Pa1PvrP7ACSkuX6I7KYomY6cmMA0Tx86waBhDUgoKPw=
194-
k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ=
195-
k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
196-
sigs.k8s.io/controller-runtime v0.17.2 h1:FwHwD1CTUemg0pW2otk7/U5/i5m2ymzvOXdbeGOUvw0=
197-
sigs.k8s.io/controller-runtime v0.17.2/go.mod h1:+MngTvIQQQhfXtwfdGw/UOQ/aIaqsYywfCINOtwMO/s=
190+
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag=
191+
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98=
192+
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 h1:jgGTlFYnhF1PM1Ax/lAlxUPE+KfCIXHaathvJg1C3ak=
193+
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
194+
sigs.k8s.io/controller-runtime v0.18.2 h1:RqVW6Kpeaji67CY5nPEfRz6ZfFMk0lWQlNrLqlNpx+Q=
195+
sigs.k8s.io/controller-runtime v0.18.2/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw=
198196
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
199197
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
200198
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=

handler/enqueue_annotation.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,21 @@ const (
8181
// if a parent creates a child resource across scopes not supported by owner references, it becomes the
8282
// responsibility of the reconciler to clean up the child resource. Hence, the resource utilizing this handler
8383
// SHOULD ALWAYS BE IMPLEMENTED WITH A FINALIZER.
84-
type EnqueueRequestForAnnotation struct {
84+
type EnqueueRequestForAnnotation[T client.Object] struct {
8585
Type schema.GroupKind
8686
}
8787

88-
var _ crtHandler.EventHandler = &EnqueueRequestForAnnotation{}
88+
var _ crtHandler.EventHandler = &EnqueueRequestForAnnotation[client.Object]{}
8989

9090
// Create implements EventHandler
91-
func (e *EnqueueRequestForAnnotation) Create(_ context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) {
91+
func (e *EnqueueRequestForAnnotation[T]) Create(_ context.Context, evt event.TypedCreateEvent[T], q workqueue.RateLimitingInterface) {
9292
if ok, req := e.getAnnotationRequests(evt.Object); ok {
9393
q.Add(req)
9494
}
9595
}
9696

9797
// Update implements EventHandler
98-
func (e *EnqueueRequestForAnnotation) Update(_ context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) {
98+
func (e *EnqueueRequestForAnnotation[T]) Update(_ context.Context, evt event.TypedUpdateEvent[T], q workqueue.RateLimitingInterface) {
9999
if ok, req := e.getAnnotationRequests(evt.ObjectOld); ok {
100100
q.Add(req)
101101
}
@@ -105,21 +105,21 @@ func (e *EnqueueRequestForAnnotation) Update(_ context.Context, evt event.Update
105105
}
106106

107107
// Delete implements EventHandler
108-
func (e *EnqueueRequestForAnnotation) Delete(_ context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) {
108+
func (e *EnqueueRequestForAnnotation[T]) Delete(_ context.Context, evt event.TypedDeleteEvent[T], q workqueue.RateLimitingInterface) {
109109
if ok, req := e.getAnnotationRequests(evt.Object); ok {
110110
q.Add(req)
111111
}
112112
}
113113

114114
// Generic implements EventHandler
115-
func (e *EnqueueRequestForAnnotation) Generic(_ context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) {
115+
func (e *EnqueueRequestForAnnotation[T]) Generic(_ context.Context, evt event.TypedGenericEvent[T], q workqueue.RateLimitingInterface) {
116116
if ok, req := e.getAnnotationRequests(evt.Object); ok {
117117
q.Add(req)
118118
}
119119
}
120120

121121
// getAnnotationRequests checks if the provided object has the annotations so as to enqueue the reconcile request.
122-
func (e *EnqueueRequestForAnnotation) getAnnotationRequests(object metav1.Object) (bool, reconcile.Request) {
122+
func (e *EnqueueRequestForAnnotation[T]) getAnnotationRequests(object metav1.Object) (bool, reconcile.Request) {
123123
if len(object.GetAnnotations()) == 0 {
124124
return false, reconcile.Request{}
125125
}

handler/enqueue_annotation_test.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2525
"k8s.io/apimachinery/pkg/runtime/schema"
2626
"k8s.io/apimachinery/pkg/types"
27+
"sigs.k8s.io/controller-runtime/pkg/client"
2728
"sigs.k8s.io/controller-runtime/pkg/controller/controllertest"
2829
"sigs.k8s.io/controller-runtime/pkg/event"
2930
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -32,10 +33,10 @@ import (
3233
)
3334

3435
var _ = Describe("EnqueueRequestForAnnotation", func() {
35-
var ctx = context.TODO()
36+
ctx := context.TODO()
3637

3738
var q workqueue.RateLimitingInterface
38-
var instance EnqueueRequestForAnnotation
39+
var instance EnqueueRequestForAnnotation[client.Object]
3940
var pod *corev1.Pod
4041
var podOwner *corev1.Pod
4142

@@ -57,11 +58,12 @@ var _ = Describe("EnqueueRequestForAnnotation", func() {
5758
podOwner.SetGroupVersionKind(schema.GroupVersionKind{Group: "", Kind: "Pod"})
5859

5960
Expect(SetOwnerAnnotations(podOwner, pod)).To(Succeed())
60-
instance = EnqueueRequestForAnnotation{
61+
instance = EnqueueRequestForAnnotation[client.Object]{
6162
Type: schema.GroupKind{
6263
Group: "",
6364
Kind: "Pod",
64-
}}
65+
},
66+
}
6567
})
6668

6769
Describe("Create", func() {
@@ -181,7 +183,8 @@ var _ = Describe("EnqueueRequestForAnnotation", func() {
181183

182184
i, _ := q.Get()
183185
Expect(i).To(Equal(reconcile.Request{
184-
NamespacedName: types.NamespacedName{Namespace: "", Name: "AppService"}}))
186+
NamespacedName: types.NamespacedName{Namespace: "", Name: "AppService"},
187+
}))
185188
})
186189
It("should enqueue a Request for an object that is cluster scoped which has the annotations", func() {
187190
nd := &corev1.Node{
@@ -194,7 +197,7 @@ var _ = Describe("EnqueueRequestForAnnotation", func() {
194197
},
195198
}
196199

197-
instance = EnqueueRequestForAnnotation{Type: schema.GroupKind{Group: "apps", Kind: "ReplicaSet"}}
200+
instance = EnqueueRequestForAnnotation[client.Object]{Type: schema.GroupKind{Group: "apps", Kind: "ReplicaSet"}}
198201

199202
evt := event.CreateEvent{
200203
Object: nd,
@@ -205,14 +208,15 @@ var _ = Describe("EnqueueRequestForAnnotation", func() {
205208

206209
i, _ := q.Get()
207210
Expect(i).To(Equal(reconcile.Request{
208-
NamespacedName: types.NamespacedName{Namespace: "", Name: "myapp"}}))
211+
NamespacedName: types.NamespacedName{Namespace: "", Name: "myapp"},
212+
}))
209213
})
210214
It("should not enqueue a Request for an object that is cluster scoped which does not have annotations", func() {
211215
nd := &corev1.Node{
212216
ObjectMeta: metav1.ObjectMeta{Name: "node-1"},
213217
}
214218

215-
instance = EnqueueRequestForAnnotation{Type: nd.GetObjectKind().GroupVersionKind().GroupKind()}
219+
instance = EnqueueRequestForAnnotation[client.Object]{Type: nd.GetObjectKind().GroupVersionKind().GroupKind()}
216220
evt := event.CreateEvent{
217221
Object: nd,
218222
}
@@ -293,7 +297,7 @@ var _ = Describe("EnqueueRequestForAnnotation", func() {
293297
Name: "faz",
294298
},
295299
}
296-
instance = EnqueueRequestForAnnotation{Type: schema.GroupKind{Group: "apps", Kind: "ReplicaSet"}}
300+
instance = EnqueueRequestForAnnotation[client.Object]{Type: schema.GroupKind{Group: "apps", Kind: "ReplicaSet"}}
297301

298302
evt := event.CreateEvent{
299303
Object: repl,
@@ -311,7 +315,7 @@ var _ = Describe("EnqueueRequestForAnnotation", func() {
311315
NamespacedNameAnnotation: "foo/faz",
312316
}
313317

314-
instance2 := EnqueueRequestForAnnotation{Type: schema.GroupKind{Group: "apps", Kind: "ReplicaSet"}}
318+
instance2 := EnqueueRequestForAnnotation[client.Object]{Type: schema.GroupKind{Group: "apps", Kind: "ReplicaSet"}}
315319

316320
evt2 := event.UpdateEvent{
317321
ObjectOld: repl,
@@ -336,7 +340,7 @@ var _ = Describe("EnqueueRequestForAnnotation", func() {
336340

337341
Expect(SetOwnerAnnotations(podOwner, pod)).To(Succeed())
338342

339-
var podOwner2 = &corev1.Pod{
343+
podOwner2 := &corev1.Pod{
340344
ObjectMeta: metav1.ObjectMeta{
341345
Namespace: "podOwnerNsTest",
342346
Name: "podOwnerNameTest",

handler/example_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ func ExampleNewPause() {
5151
}
5252

5353
// Filter out Pods with the "my.app/paused: true" annotation.
54-
pause, err := handler.NewPause("my.app/paused")
54+
pause, err := handler.NewPause[*corev1.Pod]("my.app/paused")
5555
if err != nil {
5656
os.Exit(1)
5757
}
58-
if err := c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), pause); err != nil {
58+
if err := c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}, pause)); err != nil {
5959
os.Exit(1)
6060
}
6161

0 commit comments

Comments
 (0)