diff --git a/collector/pkg/config/config_test.go b/collector/pkg/config/config_test.go index d5af79d..f123131 100644 --- a/collector/pkg/config/config_test.go +++ b/collector/pkg/config/config_test.go @@ -36,6 +36,25 @@ func TestConfiguration_GetScanOverrides_Simple(t *testing.T) { require.Equal(t, []models.ScanOverride{{Device: "/dev/sda", DeviceType: []string{"sat"}, Ignore: false}}, scanOverrides) } +// fixes #418 +func TestConfiguration_GetScanOverrides_DeviceTypeComma(t *testing.T) { + t.Parallel() + + //setup + testConfig, _ := config.Create() + + //test + err := testConfig.ReadConfig(path.Join("testdata", "device_type_comma.yaml")) + require.NoError(t, err, "should correctly load simple device config") + scanOverrides := testConfig.GetDeviceOverrides() + + //assert + require.Equal(t, []models.ScanOverride{ + {Device: "/dev/sda", DeviceType: []string{"sat", "auto"}, Ignore: false}, + {Device: "/dev/sdb", DeviceType: []string{"sat,auto"}, Ignore: false}, + }, scanOverrides) +} + func TestConfiguration_GetScanOverrides_Ignore(t *testing.T) { t.Parallel() diff --git a/collector/pkg/config/testdata/device_type_comma.yaml b/collector/pkg/config/testdata/device_type_comma.yaml new file mode 100644 index 0000000..0009d50 --- /dev/null +++ b/collector/pkg/config/testdata/device_type_comma.yaml @@ -0,0 +1,9 @@ +version: 1 +devices: + # the scrutiny config parser will detect `sat,auto` as two separate items in a list. If you want to use `-d sat,auto` you must + # set 'sat,auto' in a list (see eg. /dev/sbd) + - device: /dev/sda + type: 'sat,auto' + - device: /dev/sdb + type: + - sat,auto diff --git a/example.collector.yaml b/example.collector.yaml index 393672b..d1fc9f1 100644 --- a/example.collector.yaml +++ b/example.collector.yaml @@ -31,6 +31,10 @@ devices: # - device: /dev/sda # type: 'sat' # +# # example for using `-d sat,auto`, notice the square brackets (workaround for #418) +# - device: /dev/sda +# type: ['sat,auto'] +# # # example to show how to ignore a specific disk/device. # - device: /dev/sda # ignore: true