Skip to content

Commit 0e7818f

Browse files
committed
🌱 Bump c-r dependency, fix webhook testdata compilation
The webhook testdata referred to a very old controller-runtime version, update that. Then update the testdata examples to look like webhooks do nowadays and update the test script to check compilation to prevent future regressions.
1 parent 33e5fdc commit 0e7818f

File tree

26 files changed

+110
-1883
lines changed

26 files changed

+110
-1883
lines changed

pkg/webhook/testdata/go.mod

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
module testdata.kubebuilder.io/cronjob
22

3-
go 1.15
3+
go 1.25.0
44

55
require (
6-
k8s.io/api v0.19.2
7-
k8s.io/apimachinery v0.19.2
8-
sigs.k8s.io/controller-runtime v0.7.0
6+
k8s.io/apimachinery v0.35.0
7+
sigs.k8s.io/controller-runtime v0.23.1
8+
)
9+
10+
require (
11+
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
12+
github.com/go-logr/logr v1.4.3 // indirect
13+
github.com/json-iterator/go v1.1.12 // indirect
14+
github.com/kr/pretty v0.3.1 // indirect
15+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
16+
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
17+
github.com/x448/float16 v0.8.4 // indirect
18+
go.yaml.in/yaml/v2 v2.4.3 // indirect
19+
golang.org/x/net v0.47.0 // indirect
20+
golang.org/x/text v0.31.0 // indirect
21+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
22+
gopkg.in/inf.v0 v0.9.1 // indirect
23+
k8s.io/klog/v2 v2.130.1 // indirect
24+
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
25+
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
26+
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
27+
sigs.k8s.io/randfill v1.0.0 // indirect
28+
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 // indirect
929
)

pkg/webhook/testdata/go.sum

Lines changed: 78 additions & 705 deletions
Large diffs are not rendered by default.

pkg/webhook/testdata/invalid-admissionReviewVersionsRequired/cronjob_types.go

Lines changed: 0 additions & 71 deletions
This file was deleted.

pkg/webhook/testdata/invalid-admissionReviewVersionsRequired/webhook.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,6 @@ limitations under the License.
1515

1616
package cronjob
1717

18-
import (
19-
"k8s.io/apimachinery/pkg/runtime"
20-
ctrl "sigs.k8s.io/controller-runtime"
21-
"sigs.k8s.io/controller-runtime/pkg/webhook"
22-
)
23-
24-
func (c *CronJob) SetupWebhookWithManager(mgr ctrl.Manager) error {
25-
return ctrl.NewWebhookManagedBy(mgr).
26-
For(c).
27-
Complete()
28-
}
29-
3018
// +kubebuilder:webhook:webhookVersions=v1,verbs=create;update,path=/validate-testdata-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=testdata.kubebuilder.io,resources=cronjobs,versions=v1,name=validation.cronjob.testdata.kubebuilder.io,sideEffects=None,timeoutSeconds=10
3119
// +kubebuilder:webhook:verbs=create;update,path=/validate-testdata-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=testdata.kubebuilder.io,resources=cronjobs,versions=v1,name=validation.cronjob.testdata.kubebuilder.io,sideEffects=NoneOnDryRun,timeoutSeconds=10,admissionReviewVersions=v1;v1beta1
3220
// +kubebuilder:webhook:webhookVersions=v1,verbs=create;update,path=/mutate-testdata-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=testdata.kubebuilder.io,resources=cronjobs,versions=v1,name=default.cronjob.testdata.kubebuilder.io,sideEffects=None,timeoutSeconds=10,admissionReviewVersions=v1;v1beta1
33-
34-
var _ webhook.Defaulter = &CronJob{}
35-
var _ webhook.Validator = &CronJob{}
36-
37-
func (c *CronJob) Default() {
38-
}
39-
40-
func (c *CronJob) ValidateCreate() error {
41-
return nil
42-
}
43-
44-
func (c *CronJob) ValidateUpdate(_ runtime.Object) error {
45-
return nil
46-
}
47-
48-
func (c *CronJob) ValidateDelete() error {
49-
return nil
50-
}

pkg/webhook/testdata/invalid-multiple-webhookconfigurations/cronjob_types.go

Lines changed: 0 additions & 71 deletions
This file was deleted.

pkg/webhook/testdata/invalid-multiple-webhookconfigurations/webhook.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,8 @@ limitations under the License.
1515

1616
package cronjob
1717

18-
import (
19-
"k8s.io/apimachinery/pkg/runtime"
20-
ctrl "sigs.k8s.io/controller-runtime"
21-
"sigs.k8s.io/controller-runtime/pkg/webhook"
22-
)
23-
24-
func (c *CronJob) SetupWebhookWithManager(mgr ctrl.Manager) error {
25-
return ctrl.NewWebhookManagedBy(mgr).
26-
For(c).
27-
Complete()
28-
}
29-
3018
// +kubebuilder:webhook:webhookVersions=v1,verbs=create;update,path=/validate-testdata-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=testdata.kubebuilder.io,resources=cronjobs,versions=v1,name=validation.cronjob.testdata.kubebuilder.io,sideEffects=None,timeoutSeconds=10,admissionReviewVersions=v1;v1beta1
3119
// +kubebuilder:webhook:verbs=create;update,path=/validate-testdata-kubebuilder-io-v1-cronjob,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=testdata.kubebuilder.io,resources=cronjobs,versions=v1,name=validation.cronjob.testdata.kubebuilder.io,sideEffects=NoneOnDryRun,timeoutSeconds=10,admissionReviewVersions=v1;v1beta1
3220
// +kubebuilder:webhook:webhookVersions=v1,verbs=create;update,path=/mutate-testdata-kubebuilder-io-v1-cronjob,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=testdata.kubebuilder.io,resources=cronjobs,versions=v1,name=default.cronjob.testdata.kubebuilder.io,sideEffects=None,timeoutSeconds=10,admissionReviewVersions=v1;v1beta1,reinvocationPolicy=IfNeeded
3321
// +kubebuilder:webhookconfiguration:mutating=true,name=foo
3422
// +kubebuilder:webhookconfiguration:mutating=true,name=bar
35-
36-
var _ webhook.Defaulter = &CronJob{}
37-
var _ webhook.Validator = &CronJob{}
38-
39-
func (c *CronJob) Default() {
40-
}
41-
42-
func (c *CronJob) ValidateCreate() error {
43-
return nil
44-
}
45-
46-
func (c *CronJob) ValidateUpdate(_ runtime.Object) error {
47-
return nil
48-
}
49-
50-
func (c *CronJob) ValidateDelete() error {
51-
return nil
52-
}

pkg/webhook/testdata/invalid-path-and-url/cronjob_types.go

Lines changed: 0 additions & 71 deletions
This file was deleted.

pkg/webhook/testdata/invalid-path-and-url/webhook.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,4 @@ limitations under the License.
1515

1616
package cronjob
1717

18-
import (
19-
"k8s.io/apimachinery/pkg/runtime"
20-
ctrl "sigs.k8s.io/controller-runtime"
21-
"sigs.k8s.io/controller-runtime/pkg/webhook"
22-
)
23-
24-
func (c *CronJob) SetupWebhookWithManager(mgr ctrl.Manager) error {
25-
return ctrl.NewWebhookManagedBy(mgr).
26-
For(c).
27-
Complete()
28-
}
29-
3018
// +kubebuilder:webhook:url="https://anothersomewebhook:9443/validate-testdata-kubebuilder-io-v1-cronjob",path="/somepath",verbs=create;update,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=testdata.kubebuilder.io,resources=cronjobs,versions=v1,name=validation.cronjob.testdata.kubebuilder.io,sideEffects=NoneOnDryRun,timeoutSeconds=10,admissionReviewVersions=v1;v1beta1
31-
32-
var _ webhook.Defaulter = &CronJob{}
33-
var _ webhook.Validator = &CronJob{}
34-
35-
func (c *CronJob) Default() {
36-
}
37-
38-
func (c *CronJob) ValidateCreate() error {
39-
return nil
40-
}
41-
42-
func (c *CronJob) ValidateUpdate(_ runtime.Object) error {
43-
return nil
44-
}
45-
46-
func (c *CronJob) ValidateDelete() error {
47-
return nil
48-
}

0 commit comments

Comments
 (0)