mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-15 19:56:06 +00:00
Add GetSnapshotClass to VolumeHelper interface
Add a GetSnapshotClass method to VolumeHelper that encapsulates the extraction of the snapshotClass parameter from volume policy actions. This avoids requiring callers to parse raw parameters from GetActionParameters. Simplify the CSI plugin to use the new method. Ref: #8807 Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
This commit is contained in:
@@ -430,6 +430,21 @@ func (v *volumeHelperImpl) GetActionParameters(obj runtime.Unstructured, groupRe
|
||||
return false, "", nil, nil
|
||||
}
|
||||
|
||||
func (v *volumeHelperImpl) GetSnapshotClass(obj runtime.Unstructured, groupResource schema.GroupResource) (string, error) {
|
||||
matched, actionType, params, err := v.GetActionParameters(obj, groupResource)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if !matched {
|
||||
return "", nil
|
||||
}
|
||||
action := &resourcepolicies.Action{
|
||||
Type: resourcepolicies.VolumeActionType(actionType),
|
||||
Parameters: params,
|
||||
}
|
||||
return action.GetSnapshotClass()
|
||||
}
|
||||
|
||||
func (v *volumeHelperImpl) shouldIncludeVolumeInBackup(vol corev1api.Volume) bool {
|
||||
includeVolumeInBackup := true
|
||||
// cannot backup hostpath volumes as they are not mounted into /var/lib/kubelet/pods
|
||||
|
||||
Reference in New Issue
Block a user