diff --git a/pkg/vgmanager/filter.go b/pkg/vgmanager/filter.go index 84c7ba76c..482668806 100644 --- a/pkg/vgmanager/filter.go +++ b/pkg/vgmanager/filter.go @@ -27,6 +27,7 @@ const ( notReadOnly = "notReadOnly" notSuspended = "notSuspended" noBiosBootInPartLabel = "noBiosBootInPartLabel" + noReservedInPartLabel = "noReservedInPartLabel" noFilesystemSignature = "noFilesystemSignature" noBindMounts = "noBindMounts" noChildren = "noChildren" @@ -54,6 +55,11 @@ var FilterMap = map[string]func(internal.BlockDevice, internal.Executor) (bool, return !biosBootInPartLabel, nil }, + noReservedInPartLabel: func(dev internal.BlockDevice, _ internal.Executor) (bool, error) { + reservedInPartLabel := strings.Contains(strings.ToLower(dev.PartLabel), "reserved") + return !reservedInPartLabel, nil + }, + noFilesystemSignature: func(dev internal.BlockDevice, _ internal.Executor) (bool, error) { matched := dev.FSType == "" return matched, nil diff --git a/pkg/vgmanager/filter_test.go b/pkg/vgmanager/filter_test.go index 8f7538783..df6d10553 100644 --- a/pkg/vgmanager/filter_test.go +++ b/pkg/vgmanager/filter_test.go @@ -119,3 +119,18 @@ func TestNoBiosBootInPartLabel(t *testing.T) { } } } + +func TestNoReservedInPartLabel(t *testing.T) { + testcases := []filterTestCase{ + {label: "tc 1", device: internal.BlockDevice{Name: "dev1", PartLabel: ""}, expected: true}, + {label: "tc 2", device: internal.BlockDevice{Name: "dev2", PartLabel: "abc"}, expected: true}, + {label: "tc 3", device: internal.BlockDevice{Name: "dev3", PartLabel: "reserved"}, expected: false}, + {label: "tc 4", device: internal.BlockDevice{Name: "dev4", PartLabel: "RESERVED"}, expected: false}, + {label: "tc 5", device: internal.BlockDevice{Name: "dev5", PartLabel: "Reserved"}, expected: false}, + } + for _, tc := range testcases { + result, err := FilterMap[noReservedInPartLabel](tc.device, nil) + assert.NoError(t, err) + assert.Equal(t, tc.expected, result) + } +}