diff --git a/opts/mount.go b/opts/mount.go index 0ac252f31187..682717f164df 100644 --- a/opts/mount.go +++ b/opts/mount.go @@ -22,6 +22,11 @@ type MountOpt struct { // //nolint:gocyclo func (m *MountOpt) Set(value string) error { + value = strings.TrimSpace(value) + if value == "" { + return errors.New("value is empty") + } + csvReader := csv.NewReader(strings.NewReader(value)) fields, err := csvReader.Read() if err != nil { diff --git a/opts/mount_test.go b/opts/mount_test.go index 05f4c7161714..96d1a7357942 100644 --- a/opts/mount_test.go +++ b/opts/mount_test.go @@ -109,6 +109,10 @@ func TestMountOptErrors(t *testing.T) { tests := []struct { doc, value, expErr string }{ + { + doc: "empty value", + expErr: "value is empty", + }, { doc: "missing tmpfs target", value: "type=tmpfs",