-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
frontend/dockerfile/dockerignore: assorted cleanups #4062
Conversation
1d86d22
to
971814f
Compare
Could we do the other way around and first have the implementation forked in |
My intent was to "mostly" keep the files the same. Then, when we (if we) vendor it from moby/patternmatcher, the PR should just show a "rename" of the files, with no changes (other than package name) |
- don't use a temp-file for the test as all we need is a reader - use a const and string-literal for the test-content, which makes it slightly more readable - don't use hard-coded tests for each line, but use an "expected" slice - don't fail early if line-numbers don't match Signed-off-by: Sebastiaan van Stijn <[email protected]>
Use "doc links" where possible, and better describe the function. Signed-off-by: Sebastiaan van Stijn <[email protected]>
While this function would usually be used for read a `.dockerignore` file, it accepts a Reader and can also be used to handle ignore patterns from other files (e.g. `Dockerfile.dockerignore`) or other sources. The error was also wrapped multiple times in some code-paths, which could lead to an error being formatted as: failed to parse dockerignore: error reading .dockerignore: <some error> Let's remove mention of the `.dockerignore` filename from the error, and leave it to the caller to include the filename. This patch also brings the MainContext dockerignore error inline with the NamedContext dockerignore error, now printing the exact name of the file. Co-authored-by: Justin Chadwell <[email protected]> Signed-off-by: Sebastiaan van Stijn <[email protected]>
d0ce775
to
7eb2cea
Compare
Updated with @jedevc's patch (I squashed it into the last commit, but added you as co-author; also updated both errors to be "failed parsing ..") |
I'm considering moving this package to https://github.com/moby/patternmatcher (but no final "decision" yet). At least let's clean up this package a bit in case.
frontend/dockerfile/dockerignore: cleanup unit test
slightly more readable
frontend/dockerfile/dockerignore: touch-up godoc and code
Use "doc links" where possible, and better describe the function.
Before:
After:
frontend/dockerfile/dockerignore: remove hard-coded filename from error
While this function would usually be used for read a
.dockerignore
file,it accepts a Reader and can also be used to handle ignore patterns from
other files (e.g.
Dockerfile.dockerignore
) or other sources. The errorwas also wrapped multiple times in some code-paths, which could lead to
an error being formatted as:
Let's remove mention of the
.dockerignore
filename from the error, andleave it to the caller to include the filename.