1
0
mirror of https://github.com/docker/cli.git synced 2026-11-01 23:35:23 +03:00

opts: MountOpt: improve error for empty value

Before this patch:

    docker run --rm --mount "" busybox
    invalid argument "" for "--mount" flag: EOF

With this patch:

    docker run --rm --mount "" busybox
    invalid argument "" for "--mount" flag: value is empty

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2026-01-30 14:07:53 +01:00
parent 028eee55fa
commit defbe23deb
2 changed files with 9 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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",