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:
Shubham Pampattiwar
2026-07-24 14:55:43 -07:00
parent 6527b1e301
commit cc91b74846
3 changed files with 21 additions and 12 deletions
@@ -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