Skip to content

Commit 577f496

Browse files
committed
migrate to flux factories
1 parent cb9e8c7 commit 577f496

12 files changed

+693
-626
lines changed

src/go/k8s/api/vectorized/v1alpha1/cluster_webhook.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
ctrl "sigs.k8s.io/controller-runtime"
3232
"sigs.k8s.io/controller-runtime/pkg/client"
3333
"sigs.k8s.io/controller-runtime/pkg/webhook"
34+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3435

3536
"github.com/redpanda-data/redpanda/src/go/k8s/pkg/resources/featuregates"
3637
"github.com/redpanda-data/redpanda/src/go/k8s/pkg/utils"
@@ -197,23 +198,23 @@ func (r *Cluster) setDefaultAdditionalConfiguration() {
197198
var _ webhook.Validator = &Cluster{}
198199

199200
// 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) {
201202
log := ctrl.Log.WithName("Cluster.ValidateCreate").WithValues("namespace", r.Namespace, "name", r.Name)
202203
log.Info("validating create")
203204

204205
allErrs := r.validateCommon(log)
205206

206207
if len(allErrs) == 0 {
207-
return nil
208+
return nil, nil
208209
}
209210

210-
return apierrors.NewInvalid(
211+
return nil, apierrors.NewInvalid(
211212
r.GroupVersionKind().GroupKind(),
212213
r.Name, allErrs)
213214
}
214215

215216
// 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) {
217218
log := ctrl.Log.WithName("Cluster.ValidateUpdate").WithValues("namespace", r.Namespace, "name", r.Name)
218219
log.Info("validating update")
219220

@@ -223,7 +224,7 @@ func (r *Cluster) ValidateUpdate(old runtime.Object) error {
223224
// the clientCACertRef can fail with secret not found if the referenced secret
224225
// has already been deleted as part of the cluster deletion.
225226
if !r.GetDeletionTimestamp().IsZero() {
226-
return nil
227+
return nil, nil
227228
}
228229

229230
oldCluster := old.(*Cluster)
@@ -236,10 +237,10 @@ func (r *Cluster) ValidateUpdate(old runtime.Object) error {
236237
allErrs = append(allErrs, r.validateLicense(oldCluster)...)
237238

238239
if len(allErrs) == 0 {
239-
return nil
240+
return nil, nil
240241
}
241242

242-
return apierrors.NewInvalid(
243+
return nil, apierrors.NewInvalid(
243244
r.GroupVersionKind().GroupKind(),
244245
r.Name, allErrs)
245246
}
@@ -1098,9 +1099,9 @@ func (r *Cluster) validateAdditionalConfiguration() field.ErrorList {
10981099
}
10991100

11001101
// 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) {
11021103
// this is a stub to implement the interface. We do not validate on delete.
1103-
return nil
1104+
return nil, nil
11041105
}
11051106

11061107
type listenersPorts struct {

0 commit comments

Comments
 (0)