mirror of
https://github.com/docker/cli.git
synced 2026-11-01 23:35:23 +03:00
Merge pull request #6770 from thaJeztah/validate_empty
opts: MountOpt: improve error for empty value
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user