@@ -31,6 +31,7 @@ import (
31
31
ctrl "sigs.k8s.io/controller-runtime"
32
32
"sigs.k8s.io/controller-runtime/pkg/client"
33
33
"sigs.k8s.io/controller-runtime/pkg/webhook"
34
+ "sigs.k8s.io/controller-runtime/pkg/webhook/admission"
34
35
35
36
"github.com/redpanda-data/redpanda/src/go/k8s/pkg/resources/featuregates"
36
37
"github.com/redpanda-data/redpanda/src/go/k8s/pkg/utils"
@@ -197,23 +198,23 @@ func (r *Cluster) setDefaultAdditionalConfiguration() {
197
198
var _ webhook.Validator = & Cluster {}
198
199
199
200
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
200
- func (r * Cluster ) ValidateCreate () error {
201
+ func (r * Cluster ) ValidateCreate () (admission. Warnings , error ) {
201
202
log := ctrl .Log .WithName ("Cluster.ValidateCreate" ).WithValues ("namespace" , r .Namespace , "name" , r .Name )
202
203
log .Info ("validating create" )
203
204
204
205
allErrs := r .validateCommon (log )
205
206
206
207
if len (allErrs ) == 0 {
207
- return nil
208
+ return nil , nil
208
209
}
209
210
210
- return apierrors .NewInvalid (
211
+ return nil , apierrors .NewInvalid (
211
212
r .GroupVersionKind ().GroupKind (),
212
213
r .Name , allErrs )
213
214
}
214
215
215
216
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
216
- func (r * Cluster ) ValidateUpdate (old runtime.Object ) error {
217
+ func (r * Cluster ) ValidateUpdate (old runtime.Object ) (admission. Warnings , error ) {
217
218
log := ctrl .Log .WithName ("Cluster.ValidateUpdate" ).WithValues ("namespace" , r .Namespace , "name" , r .Name )
218
219
log .Info ("validating update" )
219
220
@@ -223,7 +224,7 @@ func (r *Cluster) ValidateUpdate(old runtime.Object) error {
223
224
// the clientCACertRef can fail with secret not found if the referenced secret
224
225
// has already been deleted as part of the cluster deletion.
225
226
if ! r .GetDeletionTimestamp ().IsZero () {
226
- return nil
227
+ return nil , nil
227
228
}
228
229
229
230
oldCluster := old .(* Cluster )
@@ -236,10 +237,10 @@ func (r *Cluster) ValidateUpdate(old runtime.Object) error {
236
237
allErrs = append (allErrs , r .validateLicense (oldCluster )... )
237
238
238
239
if len (allErrs ) == 0 {
239
- return nil
240
+ return nil , nil
240
241
}
241
242
242
- return apierrors .NewInvalid (
243
+ return nil , apierrors .NewInvalid (
243
244
r .GroupVersionKind ().GroupKind (),
244
245
r .Name , allErrs )
245
246
}
@@ -1098,9 +1099,9 @@ func (r *Cluster) validateAdditionalConfiguration() field.ErrorList {
1098
1099
}
1099
1100
1100
1101
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
1101
- func (r * Cluster ) ValidateDelete () error {
1102
+ func (r * Cluster ) ValidateDelete () (admission. Warnings , error ) {
1102
1103
// this is a stub to implement the interface. We do not validate on delete.
1103
- return nil
1104
+ return nil , nil
1104
1105
}
1105
1106
1106
1107
type listenersPorts struct {
0 commit comments