volume/mounts: pre-compile regular expressions#42673
volume/mounts: pre-compile regular expressions#42673AkihiroSuda merged 5 commits intomoby:masterfrom
Conversation
|
Opening as draft; only the last four commits are new |
6491bc3 to
4913fd2
Compare
Compile the regular expression, instead of 'ad-hoc'. For this to work, I moved the splitting was moved out of parseMountRaw() into ParseMountRaw(), and the former was renamed to parseMount(). This function still receives the 'raw' string, as it's used to include the "raw" spec for inclusion in error messages. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
It has the windowsParser/lcowParser as receiver, so no need to repeat that it's for Windows. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This way, there's no need to pass down the regular expression, and the validation is "just another" validator (which we already pass). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
4913fd2 to
71b0e47
Compare
This utility was just a shallow wrapper around executing the regular expression, and in some cases, we didn't even use the error it returned, so better to inline the code instead of abstracting it away. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
|
@tianon ptal (probably easiest to review commits individually) |
|
I'm a little confused about still having all the strings around ("This function still receives the 'raw' string, as it's used to include the "raw" spec for inclusion in error messages.") -- if it's just used for error messages, |
|
@tianon had to read back what I wrote there, but that's about this function: It receives both
Last one is used because for some errors, it uses the original (pre-split) volume-spec to generate an error; moby/volume/mounts/windows_parser.go Line 321 in 9674540 And (of course) I thought: that's easy, I just remove the m, err := p.parseMount(arr, raw, volumeDriver, mountDestinationRegexp, true, windowsSpecificValidators)
if err != nil {
return nil, errInvalidSpec(raw)
}But then found that
|
|
Ah, I guess I was hoping there'd be a cleaner way to avoid keeping all the So I guess I'm more neutral on whether #42667 is worth solving by itself, but I think doing |
|
Yeah, doing it once is probably still a good thing to do https://twitter.com/kolyshkin/status/1419025281780654081?s=20, that is, if it's ok to allocate a couple of kilobytes (saw @kolyshkin tweet about this recently 😂) |
|
@tianon were there things left to address, or all good? 🤗 |

follow-up to #42520
closes #42667
Compile the regular expression, instead of 'ad-hoc'. For this to work, I moved
the splitting was moved out of parseMountRaw() into ParseMountRaw(), and the
former was renamed to parseMount(). This function still receives the 'raw' string,
as it's used to include the "raw" spec for inclusion in error messages.
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)