1
0
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:
Paweł Gronowski
2026-02-02 13:13:28 +00:00
committed by GitHub
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",