Skip to content

Commit f12416a

Browse files
[PLT-1525] update to be compatible with controller-runtime v0.23.3 (#636)
1 parent 79f5659 commit f12416a

3 files changed

Lines changed: 615 additions & 592 deletions

File tree

api/v1alpha1/revision_webhook.go

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,18 @@ import (
2121
"fmt"
2222

2323
apierrors "k8s.io/apimachinery/pkg/api/errors"
24-
"k8s.io/apimachinery/pkg/runtime"
2524
"k8s.io/apimachinery/pkg/runtime/schema"
2625
"k8s.io/apimachinery/pkg/util/validation/field"
2726
ctrl "sigs.k8s.io/controller-runtime"
2827
logf "sigs.k8s.io/controller-runtime/pkg/log"
29-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3028
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3129
)
3230

3331
// log is for logging in this package.
3432
var revisionlog = logf.Log.WithName("revision-resource")
3533

3634
func (r *Revision) SetupWebhookWithManager(mgr ctrl.Manager) error {
37-
return ctrl.NewWebhookManagedBy(mgr).
38-
For(r).
35+
return ctrl.NewWebhookManagedBy(mgr, r).
3936
WithDefaulter(r).
4037
WithValidator(r).
4138
Complete()
@@ -45,14 +42,10 @@ func (r *Revision) SetupWebhookWithManager(mgr ctrl.Manager) error {
4542

4643
// +kubebuilder:webhook:path=/mutate-picchu-medium-engineering-v1alpha1-revision,mutating=true,failurePolicy=fail,groups=picchu.medium.engineering,resources=revisions,verbs=create;update,versions=v1alpha1,name=mrevision.kb.io,admissionReviewVersions=v1,sideEffects=None
4744

48-
var _ webhook.CustomDefaulter = &Revision{}
45+
var _ admission.Defaulter[*Revision] = &Revision{}
4946

5047
// Default implements webhook.Defaulter so a webhook will be registered for the type
51-
func (r *Revision) Default(ctx context.Context, obj runtime.Object) error {
52-
rev, ok := obj.(*Revision)
53-
if !ok {
54-
return fmt.Errorf("expected Revision, got %T", obj)
55-
}
48+
func (r *Revision) Default(ctx context.Context, rev *Revision) error {
5649
revisionlog.Info("default", "name", rev.Name)
5750
err := rev.getPatches()
5851
// TODO(user): fill in your defaulting logic.
@@ -136,42 +129,24 @@ func (r *Revision) getIngressDefaultPortPatches() error {
136129
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
137130
// +kubebuilder:webhook:verbs=create;update,path=/validate-picchu-medium-engineering-v1alpha1-revision,mutating=false,failurePolicy=fail,groups=picchu.medium.engineering,resources=revisions,versions=v1alpha1,name=vrevision.kb.io,admissionReviewVersions=v1,sideEffects=None
138131

139-
var _ webhook.CustomValidator = &Revision{}
132+
var _ admission.Validator[*Revision] = &Revision{}
140133

141134
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
142-
func (r *Revision) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
143-
rev, ok := obj.(*Revision)
144-
if !ok {
145-
return nil, fmt.Errorf("expected Revision, got %T", obj)
146-
}
135+
func (r *Revision) ValidateCreate(ctx context.Context, rev *Revision) (admission.Warnings, error) {
147136
revisionlog.Info("validate create", "name", rev.Name)
148137
// TODO(user): fill in your validation logic upon object creation.
149138
return nil, rev.validate()
150139
}
151140

152141
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
153-
func (r *Revision) ValidateUpdate(ctx context.Context, oldObj runtime.Object, newObj runtime.Object) (admission.Warnings, error) {
154-
newRev, ok := newObj.(*Revision)
155-
if !ok {
156-
return nil, fmt.Errorf("expected Revision, got %T", newObj)
157-
}
158-
159-
_, ok = oldObj.(*Revision)
160-
if !ok {
161-
return nil, fmt.Errorf("expected Revision, got %T", oldObj)
162-
}
163-
revisionlog.Info("validate update", "name", newRev.Name)
164-
142+
func (r *Revision) ValidateUpdate(ctx context.Context, oldObj *Revision, newObj *Revision) (admission.Warnings, error) {
143+
revisionlog.Info("validate update", "name", newObj.Name)
165144
// TODO(user): fill in your validation logic upon object update.
166-
return nil, newRev.validate()
145+
return nil, newObj.validate()
167146
}
168147

169148
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
170-
func (r *Revision) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
171-
rev, ok := obj.(*Revision)
172-
if !ok {
173-
return nil, fmt.Errorf("expected Revision, got %T", obj)
174-
}
149+
func (r *Revision) ValidateDelete(ctx context.Context, rev *Revision) (admission.Warnings, error) {
175150
revisionlog.Info("validate delete", "name", rev.Name)
176151
// TODO(user): fill in your validation logic upon object deletion.
177152
return nil, nil

go.mod

Lines changed: 67 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,124 @@
11
module go.medium.engineering/picchu
22

3-
go 1.25.6
3+
go 1.26.4
44

55
require (
66
github.com/DataDog/datadog-api-client-go/v2 v2.42.0
77
github.com/DataDog/datadog-operator/api v0.0.0-20251110224013-76f698af3867
88
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883
9-
github.com/external-secrets/external-secrets/apis v0.0.0-20260203074332-a2ec42276c5e
9+
github.com/external-secrets/external-secrets/apis v0.0.0-20260626113040-e215053f3e68
1010
github.com/go-logr/logr v1.4.3
1111
github.com/go-logr/zapr v1.3.0
1212
github.com/gogo/protobuf v1.3.2
1313
github.com/golang/mock v1.6.0
1414
github.com/google/uuid v1.6.0
1515
github.com/onsi/ginkgo v1.16.5
16-
github.com/onsi/gomega v1.38.2
16+
github.com/onsi/gomega v1.41.0
1717
github.com/practo/k8s-worker-pod-autoscaler v1.6.0
1818
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.62.0
1919
github.com/prometheus/client_golang v1.23.2
20-
github.com/prometheus/common v0.66.1
21-
github.com/prometheus/prometheus v0.304.2
20+
github.com/prometheus/common v0.67.5
21+
github.com/prometheus/prometheus v0.310.0
2222
github.com/slack-go/slack v0.17.3
2323
github.com/slok/sloth v0.11.0
2424
github.com/stretchr/testify v1.11.1
2525
go.medium.engineering/kubernetes v0.1.9
2626
go.uber.org/mock v0.6.0
27-
go.uber.org/zap v1.27.1
28-
golang.org/x/sync v0.18.0
27+
go.uber.org/zap v1.28.0
28+
golang.org/x/sync v0.21.0
2929
istio.io/api v0.0.0-20220322234440-289bfe748e00
3030
istio.io/client-go v1.13.2
31-
k8s.io/api v0.34.2
32-
k8s.io/apimachinery v0.34.2
33-
k8s.io/client-go v0.34.2
34-
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
35-
sigs.k8s.io/controller-runtime v0.22.3
31+
k8s.io/api v0.36.0
32+
k8s.io/apimachinery v0.36.0
33+
k8s.io/client-go v0.36.0
34+
k8s.io/utils v0.0.0-20260319190234-28399d86e0b5
35+
sigs.k8s.io/controller-runtime v0.23.3
3636
)
3737

38-
require github.com/kedacore/keda/v2 v2.18.3
38+
require github.com/kedacore/keda/v2 v2.20.1
3939

4040
require (
41-
github.com/DataDog/zstd v1.5.6 // indirect
41+
github.com/DataDog/zstd v1.5.7 // indirect
4242
github.com/beorn7/perks v1.0.1 // indirect
4343
github.com/cespare/xxhash/v2 v2.3.0 // indirect
4444
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
4545
github.com/dennwc/varint v1.0.0 // indirect
46-
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
46+
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
4747
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
48-
github.com/expr-lang/expr v1.17.6 // indirect
49-
github.com/fsnotify/fsnotify v1.9.0 // indirect
50-
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
51-
github.com/go-openapi/jsonpointer v0.21.1 // indirect
52-
github.com/go-openapi/jsonreference v0.21.0 // indirect
53-
github.com/go-openapi/swag v0.23.1 // indirect
54-
github.com/goccy/go-json v0.10.5 // indirect
55-
github.com/golang/protobuf v1.5.4 // indirect
48+
github.com/expr-lang/expr v1.17.8 // indirect
49+
github.com/fsnotify/fsnotify v1.10.0 // indirect
50+
github.com/fxamacker/cbor/v2 v2.9.1 // indirect
51+
github.com/go-openapi/jsonpointer v0.23.1 // indirect
52+
github.com/go-openapi/jsonreference v0.21.5 // indirect
53+
github.com/go-openapi/swag v0.26.0 // indirect
54+
github.com/go-openapi/swag/cmdutils v0.26.0 // indirect
55+
github.com/go-openapi/swag/conv v0.26.0 // indirect
56+
github.com/go-openapi/swag/fileutils v0.26.0 // indirect
57+
github.com/go-openapi/swag/jsonname v0.26.0 // indirect
58+
github.com/go-openapi/swag/jsonutils v0.26.0 // indirect
59+
github.com/go-openapi/swag/loading v0.26.0 // indirect
60+
github.com/go-openapi/swag/mangling v0.26.0 // indirect
61+
github.com/go-openapi/swag/netutils v0.26.0 // indirect
62+
github.com/go-openapi/swag/stringutils v0.26.0 // indirect
63+
github.com/go-openapi/swag/typeutils v0.26.0 // indirect
64+
github.com/go-openapi/swag/yamlutils v0.26.0 // indirect
65+
github.com/goccy/go-json v0.10.6 // indirect
5666
github.com/google/btree v1.1.3 // indirect
57-
github.com/google/gnostic-models v0.7.0 // indirect
67+
github.com/google/gnostic-models v0.7.1 // indirect
5868
github.com/google/go-cmp v0.7.0 // indirect
5969
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
60-
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
61-
github.com/josharian/intern v1.0.0 // indirect
70+
github.com/grafana/regexp v0.0.0-20250905093917-f7b3be9d1853 // indirect
6271
github.com/json-iterator/go v1.1.12 // indirect
63-
github.com/mailru/easyjson v0.9.0 // indirect
6472
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
6573
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
6674
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6775
github.com/nxadm/tail v1.4.8 // indirect
68-
github.com/pkg/errors v0.9.1 // indirect
6976
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
7077
github.com/prometheus/client_model v0.6.2 // indirect
71-
github.com/prometheus/procfs v0.17.0 // indirect
78+
github.com/prometheus/procfs v0.20.1 // indirect
7279
github.com/sergi/go-diff v1.4.0 // indirect
7380
github.com/spf13/pflag v1.0.10 // indirect
7481
github.com/x448/float16 v0.8.4 // indirect
7582
go.uber.org/atomic v1.11.0 // indirect
7683
go.uber.org/multierr v1.11.0 // indirect
77-
go.yaml.in/yaml/v2 v2.4.3 // indirect
84+
go.yaml.in/yaml/v2 v2.4.4 // indirect
7885
go.yaml.in/yaml/v3 v3.0.4 // indirect
79-
golang.org/x/net v0.47.0 // indirect
80-
golang.org/x/oauth2 v0.33.0 // indirect
81-
golang.org/x/sys v0.38.0 // indirect
82-
golang.org/x/term v0.37.0 // indirect
83-
golang.org/x/text v0.31.0 // indirect
84-
golang.org/x/time v0.14.0 // indirect
86+
golang.org/x/net v0.56.0 // indirect
87+
golang.org/x/oauth2 v0.36.0 // indirect
88+
golang.org/x/sys v0.46.0 // indirect
89+
golang.org/x/term v0.44.0 // indirect
90+
golang.org/x/text v0.38.0 // indirect
91+
golang.org/x/time v0.15.0 // indirect
8592
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
86-
google.golang.org/protobuf v1.36.10 // indirect
87-
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
93+
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect
94+
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
8895
gopkg.in/inf.v0 v0.9.1 // indirect
8996
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
9097
gopkg.in/yaml.v3 v3.0.1 // indirect
9198
istio.io/gogo-genproto v0.0.0-20211208193508-5ab4acc9eb1e // indirect
92-
k8s.io/apiextensions-apiserver v0.34.2 // indirect
93-
k8s.io/klog/v2 v2.130.1 // indirect
94-
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
95-
knative.dev/pkg v0.0.0-20250326102644-9f3e60a9244c // indirect
96-
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
99+
k8s.io/apiextensions-apiserver v0.36.0 // indirect
100+
k8s.io/klog/v2 v2.140.0 // indirect
101+
k8s.io/kube-openapi v0.0.0-20260427204847-8949caaa1199 // indirect
102+
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
97103
sigs.k8s.io/randfill v1.0.0 // indirect
98-
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
104+
sigs.k8s.io/structured-merge-diff/v6 v6.4.0 // indirect
99105
sigs.k8s.io/yaml v1.6.0 // indirect
100106
)
101107

102-
replace github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.14.0
103-
104-
// replace k8s.io/api => k8s.io/api v0.29.6
105-
106-
// replace k8s.io/apimachinery => k8s.io/apimachinery v0.29.6
107-
108-
// replace k8s.io/client-go => k8s.io/client-go v0.29.6
109-
110-
// replace k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.29.6
111-
112-
// replace k8s.io/component-base => k8s.io/component-base v0.26.0
113-
114-
// replace sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.20.4
108+
replace (
109+
// copied from keda, remaove when it supports k8s.io/* 0.36.x
110+
github.com/google/cel-go => github.com/google/cel-go v0.26.0
111+
github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.23.2
112+
github.com/prometheus/client_model => github.com/prometheus/client_model v0.6.2
113+
github.com/prometheus/common => github.com/prometheus/common v0.66.1
114+
github.com/prometheus/prometheus => github.com/prometheus/prometheus v0.304.2
115+
k8s.io/api => k8s.io/api v0.35.5
116+
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.35.5
117+
k8s.io/apimachinery => k8s.io/apimachinery v0.35.5
118+
k8s.io/apiserver => k8s.io/apiserver v0.35.5
119+
k8s.io/client-go => k8s.io/client-go v0.35.5
120+
k8s.io/gengo/v2 => k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b
121+
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912
122+
k8s.io/metrics => k8s.io/metrics v0.35.5
123+
sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.23.3
124+
)

0 commit comments

Comments
 (0)