SyncUnreadyGroupSnapshot and related functions

This commit is contained in:
Raunak Pradip Shah
2023-03-13 12:38:15 +05:30
parent a574b8780c
commit 3c32e81fe0
3 changed files with 487 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ package utils
import (
"context"
"encoding/json"
crdv1alpha1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumegroupsnapshot/v1alpha1"
crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
clientset "github.com/kubernetes-csi/external-snapshotter/client/v6/clientset/versioned"
@@ -56,3 +57,23 @@ func PatchVolumeSnapshot(
return newSnapshot, nil
}
// PatchVolumeGroupSnapshotContent patches a volume group snapshot content object
func PatchVolumeGroupSnapshotContent(
existingGroupSnapshotContent *crdv1alpha1.VolumeGroupSnapshotContent,
patch []PatchOp,
client clientset.Interface,
subresources ...string,
) (*crdv1alpha1.VolumeGroupSnapshotContent, error) {
data, err := json.Marshal(patch)
if nil != err {
return existingGroupSnapshotContent, err
}
newGroupSnapshotContent, err := client.GroupsnapshotV1alpha1().VolumeGroupSnapshotContents().Patch(context.TODO(), existingGroupSnapshotContent.Name, types.JSONPatchType, data, metav1.PatchOptions{}, subresources...)
if err != nil {
return existingGroupSnapshotContent, err
}
return newGroupSnapshotContent, nil
}