Skip to content

Commit

Permalink
NetworkFence: correct check in validating webhook
Browse files Browse the repository at this point in the history
When a NetworkFence CR is validated, an incorrect comparison is done.
`DeepEqual()` returns `true` when the there are no changes, this is
valid and not an error. Adding `!` to inverse the check corrects the
comparison and only reports an error when the parameters are modified.

See-also: https://bugzilla.redhat.com/2182375
Signed-off-by: Niels de Vos <[email protected]>
  • Loading branch information
nixpanic authored and mergify[bot] committed Mar 28, 2023
1 parent 0c87356 commit 5da0cb8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion apis/csiaddons/v1alpha1/networkfence_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (n *NetworkFence) ValidateUpdate(old runtime.Object) error {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("driver"), n.Spec.Driver, "driver cannot be changed"))
}

if reflect.DeepEqual(n.Spec.Parameters, oldNetworkFence.Spec.Parameters) {
if !reflect.DeepEqual(n.Spec.Parameters, oldNetworkFence.Spec.Parameters) {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("parameters"), n.Spec.Parameters, "parameters cannot be changed"))
}

Expand Down

0 comments on commit 5da0cb8

Please sign in to comment.