SyncUnreadyGroupSnapshot and related functions
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
@@ -508,3 +508,14 @@ func IsVolumeGroupSnapshotRefSet(groupSnapshot *crdv1alpha1.VolumeGroupSnapshot,
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsGroupSnapshotCreated indicates that the group snapshot has been cut on a storage system
|
||||
func IsGroupSnapshotCreated(groupSnapshot *crdv1alpha1.VolumeGroupSnapshot) bool {
|
||||
return groupSnapshot.Status != nil && groupSnapshot.Status.CreationTime != nil
|
||||
}
|
||||
|
||||
// GetDynamicSnapshotContentNameFoGrouprSnapshot returns a unique content name for the
|
||||
// passed in VolumeGroupSnapshot to dynamically provision a group snapshot.
|
||||
func GetDynamicSnapshotContentNameForGroupSnapshot(groupSnapshot *crdv1alpha1.VolumeGroupSnapshot) string {
|
||||
return "groupsnapcontent-" + string(groupSnapshot.UID)
|
||||
}
|
||||
|
Reference in New Issue
Block a user