Skip to content

Commit a1f949b

Browse files
committed
Remove deprecated webhook.Defaulter/Validator interface assertions
These compile-time assertions reference webhook.Defaulter and webhook.Validator interfaces that are removed in controller-runtime v0.21 (OCP 4.20). The assertions are dead code — webhook registration already uses CustomDefaulter/CustomValidator in internal/webhook/. Removing them makes the API module forward-compatible with CR v0.21 so that consumers (like openstack-operator) can bump controller-runtime without needing replace directives for this operator. Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
1 parent 8920bcd commit a1f949b

9 files changed

Lines changed: 0 additions & 29 deletions

api/nova/v1beta1/nova_webhook.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
"k8s.io/apimachinery/pkg/util/validation/field"
3737
"k8s.io/utils/ptr"
3838
logf "sigs.k8s.io/controller-runtime/pkg/log"
39-
"sigs.k8s.io/controller-runtime/pkg/webhook"
4039
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
4140
)
4241

@@ -59,7 +58,6 @@ func SetupNovaDefaults(defaults NovaDefaults) {
5958
novalog.Info("Nova defaults initialized", "defaults", defaults)
6059
}
6160

62-
var _ webhook.Defaulter = &Nova{}
6361

6462
// Default implements webhook.Defaulter so a webhook will be registered for the type
6563
func (r *Nova) Default() {
@@ -130,7 +128,6 @@ func (spec *NovaSpecCore) Default() {
130128
}
131129
}
132130

133-
var _ webhook.Validator = &Nova{}
134131

135132
// ValidateCellTemplates validates cell templates configuration
136133
func (spec *NovaSpecCore) ValidateCellTemplates(basePath *field.Path, namespace string) field.ErrorList {

api/nova/v1beta1/novaapi_webhook.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"k8s.io/apimachinery/pkg/runtime/schema"
3232
"k8s.io/apimachinery/pkg/util/validation/field"
3333
logf "sigs.k8s.io/controller-runtime/pkg/log"
34-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3534
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3635

3736
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
@@ -54,7 +53,6 @@ func SetupNovaAPIDefaults(defaults NovaAPIDefaults) {
5453
novaapilog.Info("NovaAPI defaults initialized", "defaults", defaults)
5554
}
5655

57-
var _ webhook.Defaulter = &NovaAPI{}
5856

5957
// Default implements webhook.Defaulter so a webhook will be registered for the type
6058
func (r *NovaAPI) Default() {
@@ -70,7 +68,6 @@ func (spec *NovaAPISpec) Default() {
7068
}
7169
}
7270

73-
var _ webhook.Validator = &NovaAPI{}
7471

7572
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
7673
func (r *NovaAPI) ValidateCreate() (admission.Warnings, error) {

api/nova/v1beta1/novacell_webhook.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"k8s.io/apimachinery/pkg/util/validation/field"
3434
"k8s.io/utils/ptr"
3535
logf "sigs.k8s.io/controller-runtime/pkg/log"
36-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3736
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3837
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
3938
)
@@ -60,7 +59,6 @@ func SetupNovaCellDefaults(defaults NovaCellDefaults) {
6059
novacelllog.Info("NovaCell defaults initialized", "defaults", defaults)
6160
}
6261

63-
var _ webhook.Defaulter = &NovaCell{}
6462

6563
// Default implements webhook.Defaulter so a webhook will be registered for the type
6664
func (r *NovaCell) Default() {
@@ -90,7 +88,6 @@ func (spec *NovaCellSpec) Default() {
9088
}
9189
}
9290

93-
var _ webhook.Validator = &NovaCell{}
9491

9592
func (spec *NovaCellSpec) validate(basePath *field.Path, namespace string) field.ErrorList {
9693
var errors field.ErrorList

api/nova/v1beta1/novacompute_webhook.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"k8s.io/apimachinery/pkg/runtime/schema"
3333
"k8s.io/apimachinery/pkg/util/validation/field"
3434
logf "sigs.k8s.io/controller-runtime/pkg/log"
35-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3635
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3736
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
3837
)
@@ -53,7 +52,6 @@ func SetupNovaComputeDefaults(defaults NovaComputeDefaults) {
5352
novacomputelog.Info("NovaCompute defaults initialized", "defaults", defaults)
5453
}
5554

56-
var _ webhook.Defaulter = &NovaCompute{}
5755

5856
// Default implements webhook.Defaulter so a webhook will be registered for the type
5957
func (r *NovaCompute) Default() {
@@ -69,7 +67,6 @@ func (spec *NovaComputeSpec) Default() {
6967
}
7068
}
7169

72-
var _ webhook.Validator = &NovaCompute{}
7370

7471
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
7572
func (r *NovaCompute) ValidateCreate() (admission.Warnings, error) {

api/nova/v1beta1/novaconductor_webhook.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"k8s.io/apimachinery/pkg/runtime/schema"
3232
"k8s.io/apimachinery/pkg/util/validation/field"
3333
logf "sigs.k8s.io/controller-runtime/pkg/log"
34-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3534
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3635
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
3736
)
@@ -52,7 +51,6 @@ func SetupNovaConductorDefaults(defaults NovaConductorDefaults) {
5251
novaconductorlog.Info("NovaConductor defaults initialized", "defaults", defaults)
5352
}
5453

55-
var _ webhook.Defaulter = &NovaConductor{}
5654

5755
// Default implements webhook.Defaulter so a webhook will be registered for the type
5856
func (r *NovaConductor) Default() {
@@ -68,7 +66,6 @@ func (spec *NovaConductorSpec) Default() {
6866
}
6967
}
7068

71-
var _ webhook.Validator = &NovaConductor{}
7269

7370
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
7471
func (r *NovaConductor) ValidateCreate() (admission.Warnings, error) {

api/nova/v1beta1/novametadata_webhook.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"k8s.io/apimachinery/pkg/runtime/schema"
3232
"k8s.io/apimachinery/pkg/util/validation/field"
3333
logf "sigs.k8s.io/controller-runtime/pkg/log"
34-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3534
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3635
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
3736
)
@@ -52,7 +51,6 @@ func SetupNovaMetadataDefaults(defaults NovaMetadataDefaults) {
5251
novametadatalog.Info("NovaMetadata defaults initialized", "defaults", defaults)
5352
}
5453

55-
var _ webhook.Defaulter = &NovaMetadata{}
5654

5755
// Default implements webhook.Defaulter so a webhook will be registered for the type
5856
func (r *NovaMetadata) Default() {
@@ -68,7 +66,6 @@ func (spec *NovaMetadataSpec) Default() {
6866
}
6967
}
7068

71-
var _ webhook.Validator = &NovaMetadata{}
7269

7370
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
7471
func (r *NovaMetadata) ValidateCreate() (admission.Warnings, error) {

api/nova/v1beta1/novanovncproxy_webhook.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"k8s.io/apimachinery/pkg/runtime"
3131
"k8s.io/apimachinery/pkg/util/validation/field"
3232
logf "sigs.k8s.io/controller-runtime/pkg/log"
33-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3433
"k8s.io/apimachinery/pkg/runtime/schema"
3534
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3635
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
@@ -52,7 +51,6 @@ func SetupNovaNoVNCProxyDefaults(defaults NovaNoVNCProxyDefaults) {
5251
novanovncproxylog.Info("NovaNoVNCProxy defaults initialized", "defaults", defaults)
5352
}
5453

55-
var _ webhook.Defaulter = &NovaNoVNCProxy{}
5654

5755
// Default implements webhook.Defaulter so a webhook will be registered for the type
5856
func (r *NovaNoVNCProxy) Default() {
@@ -68,7 +66,6 @@ func (spec *NovaNoVNCProxySpec) Default() {
6866
}
6967
}
7068

71-
var _ webhook.Validator = &NovaNoVNCProxy{}
7269

7370
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
7471
func (r *NovaNoVNCProxy) ValidateCreate() (admission.Warnings, error) {

api/nova/v1beta1/novascheduler_webhook.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
apierrors "k8s.io/apimachinery/pkg/api/errors"
3030
"k8s.io/apimachinery/pkg/runtime"
3131
logf "sigs.k8s.io/controller-runtime/pkg/log"
32-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3332
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3433
"k8s.io/apimachinery/pkg/util/validation/field"
3534
topologyv1 "github.com/openstack-k8s-operators/infra-operator/apis/topology/v1beta1"
@@ -52,7 +51,6 @@ func SetupNovaSchedulerDefaults(defaults NovaSchedulerDefaults) {
5251
novaschedulerlog.Info("NovaScheduler defaults initialized", "defaults", defaults)
5352
}
5453

55-
var _ webhook.Defaulter = &NovaScheduler{}
5654

5755
// Default implements webhook.Defaulter so a webhook will be registered for the type
5856
func (r *NovaScheduler) Default() {
@@ -68,7 +66,6 @@ func (spec *NovaSchedulerSpec) Default() {
6866
}
6967
}
7068

71-
var _ webhook.Validator = &NovaScheduler{}
7269

7370
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
7471
func (r *NovaScheduler) ValidateCreate() (admission.Warnings, error) {

api/placement/v1beta1/api_webhook.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"k8s.io/apimachinery/pkg/runtime/schema"
3131
"k8s.io/apimachinery/pkg/util/validation/field"
3232
logf "sigs.k8s.io/controller-runtime/pkg/log"
33-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3433
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3534
)
3635

@@ -51,8 +50,6 @@ func SetupPlacementAPIDefaults(defaults PlacementAPIDefaults) {
5150
placementapilog.Info("PlacementAPI defaults initialized", "defaults", defaults)
5251
}
5352

54-
var _ webhook.Defaulter = &PlacementAPI{}
55-
5653
// Default implements webhook.Defaulter so a webhook will be registered for the type
5754
func (r *PlacementAPI) Default() {
5855
placementapilog.Info("default", "name", r.Name)
@@ -75,8 +72,6 @@ func (spec *PlacementAPISpecCore) Default() {
7572
// nothing here yet
7673
}
7774

78-
var _ webhook.Validator = &PlacementAPI{}
79-
8075
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
8176
func (r *PlacementAPI) ValidateCreate() (admission.Warnings, error) {
8277
placementapilog.Info("validate create", "name", r.Name)

0 commit comments

Comments
 (0)