From bb131239064c60eb4a7728cb7f61c11449a5cb2e Mon Sep 17 00:00:00 2001 From: Raunak Pradip Shah Date: Thu, 31 Mar 2022 11:58:36 +0530 Subject: [PATCH] Add webhook to make SourceVolumeMode immutable --- pkg/validation-webhook/snapshot.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/validation-webhook/snapshot.go b/pkg/validation-webhook/snapshot.go index cd4eaa18..7d278fad 100644 --- a/pkg/validation-webhook/snapshot.go +++ b/pkg/validation-webhook/snapshot.go @@ -377,5 +377,9 @@ func checkSnapshotContentImmutableFieldsV1(snapcontent, oldSnapcontent *volumesn if !reflect.DeepEqual(source.SnapshotHandle, oldSource.SnapshotHandle) { return fmt.Errorf("Spec.Source.SnapshotHandle is immutable but was changed from %s to %s", strPtrDereference(oldSource.SnapshotHandle), strPtrDereference(source.SnapshotHandle)) } + if !reflect.DeepEqual(snapcontent.Spec.SourceVolumeMode, oldSnapcontent.Spec.SourceVolumeMode) { + return fmt.Errorf("Spec.SourceVolumeMode is immutable but was changed from %v to %v", *oldSnapcontent.Spec.SourceVolumeMode, *snapcontent.Spec.SourceVolumeMode) + } + return nil }