update API names in group snapshot content to be consistent with volume snapshots

This commit is contained in:
Raunak Pradip Shah
2024-01-05 11:29:03 -08:00
parent bffa5ae25f
commit 0bd355cf29
14 changed files with 169 additions and 126 deletions

View File

@@ -233,11 +233,11 @@ func checkGroupSnapshotContentImmutableFieldsV1Alpha1(groupSnapcontent, oldGroup
source := groupSnapcontent.Spec.Source
oldSource := oldGroupSnapcontent.Spec.Source
if !reflect.DeepEqual(source.VolumeGroupSnapshotHandle, oldSource.VolumeGroupSnapshotHandle) {
return fmt.Errorf("Spec.Source.VolumeGroupSnapshotHandle is immutable but was changed from %s to %s", strPtrDereference(oldSource.VolumeGroupSnapshotHandle), strPtrDereference(source.VolumeGroupSnapshotHandle))
if !reflect.DeepEqual(source.GroupSnapshotHandles, oldSource.GroupSnapshotHandles) {
return fmt.Errorf("Spec.Source.GroupSnapshotHandles is immutable but was changed from %s to %s", oldSource.GroupSnapshotHandles, source.GroupSnapshotHandles)
}
if !reflect.DeepEqual(source.PersistentVolumeNames, oldSource.PersistentVolumeNames) {
return fmt.Errorf("Spec.Source.PersistentVolumeNames is immutable but was changed from %v to %v", oldSource.PersistentVolumeNames, source.PersistentVolumeNames)
if !reflect.DeepEqual(source.VolumeHandles, oldSource.VolumeHandles) {
return fmt.Errorf("Spec.Source.VolumeHandles is immutable but was changed from %v to %v", oldSource.VolumeHandles, source.VolumeHandles)
}
ref := groupSnapcontent.Spec.VolumeGroupSnapshotRef

View File

@@ -250,11 +250,15 @@ func TestAdmitVolumeGroupSnapshotContentV1Alpha1(t *testing.T) {
volumeHandle := "volumeHandle1"
modifiedField := "modified-field"
groupSnapshotHandle := "groupsnapshotHandle1"
groupSnapshotHandles := &volumegroupsnapshotv1alpha1.GroupSnapshotHandles{
VolumeGroupSnapshotHandle: "volumeGroupSnapshotHandle1",
VolumeSnapshotHandles: []string{"volumeSnapshotHandle1", "volumeSnapshotHandle2"},
}
volumeGroupSnapshotClassName := "volume-snapshot-class-1"
validContent := &volumegroupsnapshotv1alpha1.VolumeGroupSnapshotContent{
Spec: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotContentSpec{
Source: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotContentSource{
VolumeGroupSnapshotHandle: &groupSnapshotHandle,
GroupSnapshotHandles: groupSnapshotHandles,
},
VolumeGroupSnapshotRef: core_v1.ObjectReference{
Name: "group-snapshot-ref",
@@ -266,8 +270,8 @@ func TestAdmitVolumeGroupSnapshotContentV1Alpha1(t *testing.T) {
invalidContent := &volumegroupsnapshotv1alpha1.VolumeGroupSnapshotContent{
Spec: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotContentSpec{
Source: volumegroupsnapshotv1alpha1.VolumeGroupSnapshotContentSource{
VolumeGroupSnapshotHandle: &groupSnapshotHandle,
PersistentVolumeNames: []string{volumeHandle},
GroupSnapshotHandles: groupSnapshotHandles,
VolumeHandles: []string{volumeHandle},
},
VolumeGroupSnapshotRef: core_v1.ObjectReference{
Name: "",
@@ -303,7 +307,7 @@ func TestAdmitVolumeGroupSnapshotContentV1Alpha1(t *testing.T) {
oldGroupSnapContent: validContent,
shouldAdmit: false,
operation: v1.Update,
msg: fmt.Sprintf("Spec.Source.PersistentVolumeNames is immutable but was changed from %s to %s", []string{}, []string{volumeHandle}),
msg: fmt.Sprintf("Spec.Source.VolumeHandles is immutable but was changed from %s to %s", []string{}, []string{volumeHandle}),
},
{
name: "Update: old is valid and new is valid",
@@ -355,7 +359,7 @@ func TestAdmitVolumeGroupSnapshotContentV1Alpha1(t *testing.T) {
oldGroupSnapContent: invalidContent,
shouldAdmit: false,
operation: v1.Update,
msg: fmt.Sprintf("Spec.Source.PersistentVolumeNames is immutable but was changed from %s to %s", []string{volumeHandle}, []string{}),
msg: fmt.Sprintf("Spec.Source.VolumeHandles is immutable but was changed from %s to %s", []string{volumeHandle}, []string{}),
},
{
name: "Update: old is invalid and new is invalid",