Fix detecting default annotation on VolumeGroupSnapshotClass

The `IsDefaultAnnotation()` function has been extended to check for the
correct default annotation, taking the Kind of the object into
consideration.
This commit is contained in:
Niels de Vos
2024-02-22 12:23:17 +01:00
parent ca0b24b661
commit aa837d1ddf
4 changed files with 107 additions and 5 deletions

View File

@@ -262,9 +262,16 @@ func GetDynamicSnapshotContentNameForSnapshot(snapshot *crdv1.VolumeSnapshot) st
// IsDefaultAnnotation returns a boolean if
// the annotation is set
func IsDefaultAnnotation(obj metav1.ObjectMeta) bool {
if obj.Annotations[IsDefaultSnapshotClassAnnotation] == "true" {
return true
func IsDefaultAnnotation(tm metav1.TypeMeta, obj metav1.ObjectMeta) bool {
switch tm.Kind {
case "VolumeSnapshotClass":
if obj.Annotations[IsDefaultSnapshotClassAnnotation] == "true" {
return true
}
case "VolumeGroupSnapshotClass":
if obj.Annotations[IsDefaultGroupSnapshotClassAnnotation] == "true" {
return true
}
}
return false