Skip to content

Commit 7744aa7

Browse files
committed
webhook: detect errors correctly on update
Signed-off-by: Tuomas Katila <[email protected]>
1 parent 895d4a9 commit 7744aa7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/apis/deviceplugin/v1/webhook_common.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ func (r *commonDevicePluginValidator) ValidateCreate(ctx context.Context, obj ru
118118
}
119119

120120
// ValidateUpdate implements admission.CustomValidator so a webhook will be registered for the type.
121-
func (r *commonDevicePluginValidator) ValidateUpdate(ctx context.Context, oldObj runtime.Object, newObj runtime.Object) (admission.Warnings, error) {
121+
func (r *commonDevicePluginValidator) ValidateUpdate(ctx context.Context, _ runtime.Object, newObj runtime.Object) (admission.Warnings, error) {
122122
logf.FromContext(ctx).Info("validate update")
123123

124-
switch v := oldObj.(type) {
124+
switch v := newObj.(type) {
125125
case *DlbDevicePlugin:
126126
return nil, v.validatePlugin(r)
127127
case *DsaDevicePlugin:
@@ -137,7 +137,7 @@ func (r *commonDevicePluginValidator) ValidateUpdate(ctx context.Context, oldObj
137137
case *SgxDevicePlugin:
138138
return nil, v.validatePlugin(r)
139139
default:
140-
return nil, fmt.Errorf("%w: expected an xDevicePlugin object but got %T", errObjType, oldObj)
140+
return nil, fmt.Errorf("%w: expected an xDevicePlugin object but got %T", errObjType, newObj)
141141
}
142142
}
143143

0 commit comments

Comments
 (0)