Skip to content

Commit 8dfb0ca

Browse files
fix(deps): update module sigs.k8s.io/controller-runtime to v0.23.1 (release-1.25) (cloudnative-pg#9844)
Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
1 parent 6da8002 commit 8dfb0ca

14 files changed

Lines changed: 53 additions & 151 deletions

File tree

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ require (
4747
k8s.io/cli-runtime v0.35.0
4848
k8s.io/client-go v0.35.0
4949
k8s.io/utils v0.0.0-20260108192941-914a6e750570
50-
sigs.k8s.io/controller-runtime v0.22.4
50+
sigs.k8s.io/controller-runtime v0.23.1
5151
sigs.k8s.io/yaml v1.6.0
5252
)
5353

@@ -127,5 +127,5 @@ require (
127127
sigs.k8s.io/kustomize/api v0.20.1 // indirect
128128
sigs.k8s.io/kustomize/kyaml v0.20.1 // indirect
129129
sigs.k8s.io/randfill v1.0.0 // indirect
130-
sigs.k8s.io/structured-merge-diff/v6 v6.3.1 // indirect
130+
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 // indirect
131131
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ k8s.io/kube-openapi v0.0.0-20251125145642-4e65d59e963e h1:iW9ChlU0cU16w8MpVYjXk1
318318
k8s.io/kube-openapi v0.0.0-20251125145642-4e65d59e963e/go.mod h1:kdmbQkyfwUagLfXIad1y2TdrjPFWp2Q89B3qkRwf/pQ=
319319
k8s.io/utils v0.0.0-20260108192941-914a6e750570 h1:JT4W8lsdrGENg9W+YwwdLJxklIuKWdRm+BC+xt33FOY=
320320
k8s.io/utils v0.0.0-20260108192941-914a6e750570/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk=
321-
sigs.k8s.io/controller-runtime v0.22.4 h1:GEjV7KV3TY8e+tJ2LCTxUTanW4z/FmNB7l327UfMq9A=
322-
sigs.k8s.io/controller-runtime v0.22.4/go.mod h1:+QX1XUpTXN4mLoblf4tqr5CQcyHPAki2HLXqQMY6vh8=
321+
sigs.k8s.io/controller-runtime v0.23.1 h1:TjJSM80Nf43Mg21+RCy3J70aj/W6KyvDtOlpKf+PupE=
322+
sigs.k8s.io/controller-runtime v0.23.1/go.mod h1:B6COOxKptp+YaUT5q4l6LqUJTRpizbgf9KSRNdQGns0=
323323
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
324324
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
325325
sigs.k8s.io/kustomize/api v0.20.1 h1:iWP1Ydh3/lmldBnH/S5RXgT98vWYMaTUL1ADcr+Sv7I=
@@ -328,7 +328,7 @@ sigs.k8s.io/kustomize/kyaml v0.20.1 h1:PCMnA2mrVbRP3NIB6v9kYCAc38uvFLVs8j/CD567A
328328
sigs.k8s.io/kustomize/kyaml v0.20.1/go.mod h1:0EmkQHRUsJxY8Ug9Niig1pUMSCGHxQ5RklbpV/Ri6po=
329329
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
330330
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
331-
sigs.k8s.io/structured-merge-diff/v6 v6.3.1 h1:JrhdFMqOd/+3ByqlP2I45kTOZmTRLBUm5pvRjeheg7E=
332-
sigs.k8s.io/structured-merge-diff/v6 v6.3.1/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE=
331+
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 h1:2WOzJpHUBVrrkDjU4KBT8n5LDcj824eX0I5UKcgeRUs=
332+
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE=
333333
sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs=
334334
sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4=

internal/cmd/manager/controller/controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func RunController(
249249
if err = (&controller.ScheduledBackupReconciler{
250250
Client: mgr.GetClient(),
251251
Scheme: mgr.GetScheme(),
252-
Recorder: mgr.GetEventRecorderFor("cloudnative-pg-scheduledbackup"),
252+
Recorder: mgr.GetEventRecorderFor("cloudnative-pg-scheduledbackup"), //nolint:staticcheck
253253
}).SetupWithManager(ctx, mgr, maxConcurrentReconciles); err != nil {
254254
setupLog.Error(err, "unable to create controller", "controller", "ScheduledBackup")
255255
return err
@@ -259,7 +259,7 @@ func RunController(
259259
Client: mgr.GetClient(),
260260
DiscoveryClient: discoveryClient,
261261
Scheme: mgr.GetScheme(),
262-
Recorder: mgr.GetEventRecorderFor("cloudnative-pg-pooler"),
262+
Recorder: mgr.GetEventRecorderFor("cloudnative-pg-pooler"), //nolint:staticcheck
263263
}).SetupWithManager(mgr, maxConcurrentReconciles); err != nil {
264264
setupLog.Error(err, "unable to create controller", "controller", "Pooler")
265265
return err

internal/cmd/manager/instance/restore/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func NewCmd() *cobra.Command {
7272
localSrv, err := webserver.NewLocalWebServer(
7373
postgres.NewInstance().WithClusterName(clusterName).WithNamespace(namespace),
7474
mgr.GetClient(),
75-
mgr.GetEventRecorderFor("local-webserver"),
75+
mgr.GetEventRecorderFor("local-webserver"), //nolint:staticcheck
7676
)
7777
if err != nil {
7878
return err

internal/cmd/manager/instance/restoresnapshot/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func NewCmd() *cobra.Command {
7676
localSrv, err := webserver.NewLocalWebServer(
7777
postgres.NewInstance().WithClusterName(clusterName).WithNamespace(namespace),
7878
mgr.GetClient(),
79-
mgr.GetEventRecorderFor("local-webserver"),
79+
mgr.GetEventRecorderFor("local-webserver"), //nolint:staticcheck
8080
)
8181
if err != nil {
8282
return err

internal/cmd/manager/instance/run/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ func runSubCommand( //nolint:gocognit,gocyclo
347347
localSrv, err := webserver.NewLocalWebServer(
348348
instance,
349349
mgr.GetClient(),
350-
mgr.GetEventRecorderFor("local-webserver"),
350+
mgr.GetEventRecorderFor("local-webserver"), //nolint:staticcheck
351351
)
352352
if err != nil {
353353
contextLogger.Error(err, "unable to create local webserver runnable")

internal/controller/backup_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func NewBackupReconciler(
9898
Client: mgr.GetClient(),
9999
DiscoveryClient: discoveryClient,
100100
Scheme: mgr.GetScheme(),
101-
Recorder: mgr.GetEventRecorderFor("cloudnative-pg-backup"),
101+
Recorder: mgr.GetEventRecorderFor("cloudnative-pg-backup"), //nolint:staticcheck
102102
instanceStatusClient: remote.NewClient().Instance(),
103103
Plugins: plugins,
104104
}

internal/controller/cluster_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func NewClusterReconciler(
104104
DiscoveryClient: discoveryClient,
105105
Client: operatorclient.NewExtendedClient(mgr.GetClient()),
106106
Scheme: mgr.GetScheme(),
107-
Recorder: mgr.GetEventRecorderFor("cloudnative-pg"),
107+
Recorder: mgr.GetEventRecorderFor("cloudnative-pg"), //nolint:staticcheck
108108
Plugins: plugins,
109109
rolloutManager: rolloutManager.New(
110110
configuration.Current.GetClustersRolloutDelay(),

internal/webhook/v1/backup_webhook.go

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ package v1
2121

2222
import (
2323
"context"
24-
"fmt"
2524
"strconv"
2625

2726
"github.com/cloudnative-pg/machinery/pkg/log"
2827
apierrors "k8s.io/apimachinery/pkg/api/errors"
29-
"k8s.io/apimachinery/pkg/runtime"
3028
"k8s.io/apimachinery/pkg/runtime/schema"
3129
"k8s.io/apimachinery/pkg/util/validation/field"
3230
ctrl "sigs.k8s.io/controller-runtime"
33-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3431
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3532

3633
apiv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
@@ -42,8 +39,8 @@ var backupLog = log.WithName("backup-resource").WithValues("version", "v1")
4239

4340
// SetupBackupWebhookWithManager registers the webhook for Backup in the manager.
4441
func SetupBackupWebhookWithManager(mgr ctrl.Manager) error {
45-
return ctrl.NewWebhookManagedBy(mgr).For(&apiv1.Backup{}).
46-
WithValidator(newBypassableValidator(&BackupCustomValidator{})).
42+
return ctrl.NewWebhookManagedBy(mgr, &apiv1.Backup{}).
43+
WithValidator(newBypassableValidator[*apiv1.Backup](&BackupCustomValidator{})).
4744
WithDefaulter(&BackupCustomDefaulter{}).
4845
Complete()
4946
}
@@ -56,14 +53,8 @@ func SetupBackupWebhookWithManager(mgr ctrl.Manager) error {
5653
// Kind Backup when those are created or updated.
5754
type BackupCustomDefaulter struct{}
5855

59-
var _ webhook.CustomDefaulter = &BackupCustomDefaulter{}
60-
6156
// Default implements webhook.CustomDefaulter so a webhook will be registered for the Kind Backup.
62-
func (d *BackupCustomDefaulter) Default(_ context.Context, obj runtime.Object) error {
63-
backup, ok := obj.(*apiv1.Backup)
64-
if !ok {
65-
return fmt.Errorf("expected an Backup object but got %T", obj)
66-
}
57+
func (d *BackupCustomDefaulter) Default(_ context.Context, backup *apiv1.Backup) error {
6758
backupLog.Info("Defaulting for Backup", "name", backup.GetName(), "namespace", backup.GetNamespace())
6859

6960
// TODO(user): fill in your defaulting logic.
@@ -80,14 +71,8 @@ func (d *BackupCustomDefaulter) Default(_ context.Context, obj runtime.Object) e
8071
// when it is created, updated, or deleted.
8172
type BackupCustomValidator struct{}
8273

83-
var _ webhook.CustomValidator = &BackupCustomValidator{}
84-
8574
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type Backup.
86-
func (v *BackupCustomValidator) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
87-
backup, ok := obj.(*apiv1.Backup)
88-
if !ok {
89-
return nil, fmt.Errorf("expected a Backup object but got %T", obj)
90-
}
75+
func (v *BackupCustomValidator) ValidateCreate(_ context.Context, backup *apiv1.Backup) (admission.Warnings, error) {
9176
backupLog.Info("Validation for Backup upon creation", "name", backup.GetName(), "namespace", backup.GetNamespace())
9277

9378
allErrs := v.validate(backup)
@@ -103,12 +88,8 @@ func (v *BackupCustomValidator) ValidateCreate(_ context.Context, obj runtime.Ob
10388
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type Backup.
10489
func (v *BackupCustomValidator) ValidateUpdate(
10590
_ context.Context,
106-
_, newObj runtime.Object,
91+
_ *apiv1.Backup, backup *apiv1.Backup,
10792
) (admission.Warnings, error) {
108-
backup, ok := newObj.(*apiv1.Backup)
109-
if !ok {
110-
return nil, fmt.Errorf("expected a Backup object for the newObj but got %T", newObj)
111-
}
11293
backupLog.Info("Validation for Backup upon update", "name", backup.GetName(), "namespace", backup.GetNamespace())
11394

11495
allErrs := v.validate(backup)
@@ -122,11 +103,7 @@ func (v *BackupCustomValidator) ValidateUpdate(
122103
}
123104

124105
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type Backup.
125-
func (v *BackupCustomValidator) ValidateDelete(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
126-
backup, ok := obj.(*apiv1.Backup)
127-
if !ok {
128-
return nil, fmt.Errorf("expected a Backup object but got %T", obj)
129-
}
106+
func (v *BackupCustomValidator) ValidateDelete(_ context.Context, backup *apiv1.Backup) (admission.Warnings, error) {
130107
backupLog.Info("Validation for Backup upon deletion", "name", backup.GetName(), "namespace", backup.GetNamespace())
131108

132109
// TODO(user): fill in your validation logic upon object deletion.

internal/webhook/v1/cluster_webhook.go

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ import (
3838
apierrors "k8s.io/apimachinery/pkg/api/errors"
3939
"k8s.io/apimachinery/pkg/api/resource"
4040
"k8s.io/apimachinery/pkg/apis/meta/v1/validation"
41-
"k8s.io/apimachinery/pkg/runtime"
4241
"k8s.io/apimachinery/pkg/runtime/schema"
4342
validationutil "k8s.io/apimachinery/pkg/util/validation"
4443
"k8s.io/apimachinery/pkg/util/validation/field"
4544
"k8s.io/utils/ptr"
4645
ctrl "sigs.k8s.io/controller-runtime"
47-
"sigs.k8s.io/controller-runtime/pkg/webhook"
4846
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
4947

5048
apiv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
@@ -59,8 +57,8 @@ var clusterLog = log.WithName("cluster-resource").WithValues("version", "v1")
5957

6058
// SetupClusterWebhookWithManager registers the webhook for Cluster in the manager.
6159
func SetupClusterWebhookWithManager(mgr ctrl.Manager) error {
62-
return ctrl.NewWebhookManagedBy(mgr).For(&apiv1.Cluster{}).
63-
WithValidator(newBypassableValidator(&ClusterCustomValidator{})).
60+
return ctrl.NewWebhookManagedBy(mgr, &apiv1.Cluster{}).
61+
WithValidator(newBypassableValidator[*apiv1.Cluster](&ClusterCustomValidator{})).
6462
WithDefaulter(&ClusterCustomDefaulter{}).
6563
Complete()
6664
}
@@ -73,14 +71,8 @@ func SetupClusterWebhookWithManager(mgr ctrl.Manager) error {
7371
// Kind Cluster when those are created or updated.
7472
type ClusterCustomDefaulter struct{}
7573

76-
var _ webhook.CustomDefaulter = &ClusterCustomDefaulter{}
77-
7874
// Default implements webhook.CustomDefaulter so a webhook will be registered for the Kind Cluster.
79-
func (d *ClusterCustomDefaulter) Default(_ context.Context, obj runtime.Object) error {
80-
cluster, ok := obj.(*apiv1.Cluster)
81-
if !ok {
82-
return fmt.Errorf("expected a Cluster object but got %T", obj)
83-
}
75+
func (d *ClusterCustomDefaulter) Default(_ context.Context, cluster *apiv1.Cluster) error {
8476
clusterLog.Info("Defaulting for Cluster", "name", cluster.GetName(), "namespace", cluster.GetNamespace())
8577

8678
cluster.Default()
@@ -97,14 +89,8 @@ func (d *ClusterCustomDefaulter) Default(_ context.Context, obj runtime.Object)
9789
// when it is created, updated, or deleted.
9890
type ClusterCustomValidator struct{}
9991

100-
var _ webhook.CustomValidator = &ClusterCustomValidator{}
101-
10292
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type Cluster.
103-
func (v *ClusterCustomValidator) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
104-
cluster, ok := obj.(*apiv1.Cluster)
105-
if !ok {
106-
return nil, fmt.Errorf("expected a Cluster object but got %T", obj)
107-
}
93+
func (v *ClusterCustomValidator) ValidateCreate(_ context.Context, cluster *apiv1.Cluster) (admission.Warnings, error) {
10894
clusterLog.Info("Validation for Cluster upon creation", "name", cluster.GetName(), "namespace",
10995
cluster.GetNamespace())
11096

@@ -123,18 +109,8 @@ func (v *ClusterCustomValidator) ValidateCreate(_ context.Context, obj runtime.O
123109
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type Cluster.
124110
func (v *ClusterCustomValidator) ValidateUpdate(
125111
_ context.Context,
126-
oldObj, newObj runtime.Object,
112+
oldCluster *apiv1.Cluster, cluster *apiv1.Cluster,
127113
) (admission.Warnings, error) {
128-
cluster, ok := newObj.(*apiv1.Cluster)
129-
if !ok {
130-
return nil, fmt.Errorf("expected a Cluster object for the newObj but got %T", newObj)
131-
}
132-
133-
oldCluster, ok := oldObj.(*apiv1.Cluster)
134-
if !ok {
135-
return nil, fmt.Errorf("expected a Cluster object for the oldObj but got %T", oldObj)
136-
}
137-
138114
clusterLog.Info("Validation for Cluster upon update", "name", cluster.GetName(), "namespace",
139115
cluster.GetNamespace())
140116

@@ -157,11 +133,7 @@ func (v *ClusterCustomValidator) ValidateUpdate(
157133
}
158134

159135
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type Cluster.
160-
func (v *ClusterCustomValidator) ValidateDelete(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
161-
cluster, ok := obj.(*apiv1.Cluster)
162-
if !ok {
163-
return nil, fmt.Errorf("expected a Cluster object but got %T", obj)
164-
}
136+
func (v *ClusterCustomValidator) ValidateDelete(_ context.Context, cluster *apiv1.Cluster) (admission.Warnings, error) {
165137
clusterLog.Info("Validation for Cluster upon deletion", "name", cluster.GetName(), "namespace",
166138
cluster.GetNamespace())
167139

0 commit comments

Comments
 (0)