File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,6 +79,9 @@ func (m *MountOpt) Set(value string) error {
7979
8080 for _ , field := range fields {
8181 key , val , ok := strings .Cut (field , "=" )
82+ if k := strings .TrimSpace (key ); k != key {
83+ return fmt .Errorf ("invalid option '%s' in '%s': option should not have whitespace" , k , field )
84+ }
8285
8386 // TODO(thaJeztah): these options should not be case-insensitive.
8487 key = strings .ToLower (key )
@@ -167,7 +170,7 @@ func (m *MountOpt) Set(value string) error {
167170 }
168171 tmpfsOptions ().Mode = os .FileMode (ui64 )
169172 default :
170- return fmt .Errorf ("unexpected key '%s' in '%s'" , key , field )
173+ return fmt .Errorf ("unknown option '%s' in '%s'" , key , field )
171174 }
172175 }
173176
Original file line number Diff line number Diff line change @@ -116,17 +116,17 @@ func TestMountOptErrors(t *testing.T) {
116116 {
117117 doc : "invalid key=value" ,
118118 value : "type=volume,target=/foo,bogus=foo" ,
119- expErr : "unexpected key 'bogus' in 'bogus=foo'" ,
119+ expErr : "unknown option 'bogus' in 'bogus=foo'" ,
120120 },
121121 {
122122 doc : "invalid key with leading whitespace" ,
123123 value : "type=volume, src=/foo,target=/foo" ,
124- expErr : "unexpected key ' src' in ' src=/foo'" ,
124+ expErr : "invalid option ' src' in ' src=/foo': option should not have whitespace " ,
125125 },
126126 {
127127 doc : "invalid key with trailing whitespace" ,
128128 value : "type=volume,src =/foo,target=/foo" ,
129- expErr : "unexpected key 'src ' in 'src =/foo'" ,
129+ expErr : "invalid option 'src' in 'src =/foo': option should not have whitespace " ,
130130 },
131131 {
132132 doc : "missing value" ,
You can’t perform that action at this time.
0 commit comments