-
Notifications
You must be signed in to change notification settings - Fork 18.9k
[Builder] Warn on empty continuation lines #33719
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
[Builder] Warn on empty continuation lines #33719
Conversation
|
Needs a rebase. |
853d191 to
739076f
Compare
|
rebased |
|
739076f to
738d28c
Compare
|
Should we print the warnings at the end? They're currently before with the output of the build itself, possibly resulting in them being overlooked (thinking out loud here); docker build --no-cache -<<'EOF'
> FROM busybox
> RUN echo "hello" \
>
> echo "world" \
>
> echo "more"
>
> RUN echo "another" \
>
> echo "thing"
> EOF
Sending build context to Docker daemon 2.048kB
[WARNING]: Empty continuation line found in:
RUN echo "hello" echo "world" echo "more"
[WARNING]: Empty continuation line found in:
RUN echo "another" echo "thing"
[WARNING]: Empty continuation lines will become errors in a future release.Step 1/3 : FROM busybox
latest: Pulling from library/busybox
27144aa8f1b9: Pull complete
Digest: sha256:be3c11fdba7cfe299214e46edc642e09514dbb9bbefcd0d3836c05a1e0cd0642
Status: Downloaded newer image for busybox:latest
---> c30178c5239f
Step 2/3 : RUN echo "hello" echo "world" echo "more"
---> Running in d6b32caa72b0
hello echo world echo more
---> 427b597ff574
Removing intermediate container d6b32caa72b0
Step 3/3 : RUN echo "another" echo "thing"
---> Running in fce314282e52
another echo thing
---> ea484a04ae35
Removing intermediate container fce314282e52
Successfully built ea484a04ae35Also the last warning seems to be missing a newline (causing the |
builder/dockerfile/parser/parser.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a newline after
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed in PrintWarnings()
This fix is related to 29005 and 24693. Currently in `Dockerfile` empty lines will continue as long as there is line escape before. This may cause some issues. The issue in 24693 is an example. A non-empty line after an empty line might be considered to be a separate instruction by many users. However, it is actually part of the last instruction under the current `Dockerfile` parsing rule. This fix is an effort to reduce the confusion around the parsing of `Dockerfile`. Even though this fix does not change the behavior of the `Dockerfile` parsing, it tries to deprecate the empty line continuation and present a warning for the user. In this case, at least it prompt users to check for the Dockerfile and avoid the confusion if possible. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
738d28c to
f12b183
Compare
Signed-off-by: Daniel Nephin <dnephin@docker.com>
f12b183 to
b47b375
Compare
Ya, I guess so. I've moved it to right before we warn about unused build args, so warnings should be together now. It means that if the build fails they wont see the warnings, but that's probably fine. |
|
LGTM |
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
All green |
|
Is it intentional that this also warns for comment lines? e.g. This makes it so that it is not possible to add comments inside long |
Moved apt-get install ca-certificates, curl and gnupg2 (previously gnupg) to the top a la buildpack-deps style. Only reason not using buildpack-deps directly is because they currently rely on the non-slim variant of debian, and there is additional wget dependency. Also migrated nodejs/npm installation near to the top of the dockerfile so as to better sync with my beakerbrowser dockerfile. Lastly, fixed an annoying issue with "[WARNING]: Empty continuation lines will become errors in a future release." This messes with my previously neat inline comments!!! See moby/moby#33719
Moved apt-get install ca-certificates, curl and gnupg2 (previously gnupg) to the top a la buildpack-deps style. Only reason not using buildpack-deps directly is because they currently rely on the non-slim variant of debian, and there is additional wget dependency. Also migrated nodejs/npm installation near to the top of the dockerfile so as to better sync with my dat dockerfile. Note that NODE_VERSION has changed from 6 to 8. Placed npm install && npm run burnthemall together to save an additional couple of hundred MBs worth of disk space. Lastly, fixed the annoying issue with "[WARNING]: Empty continuation lines will become errors in a future release." This messes with my previously neat inline comments!!! See moby/moby#33719
|
Indeed, @JayH5 is correct -- this appears to have the same bug as the previous implementation of this (although in that case it was an error instead of a warning, so that's progress of a sort). I've also verified that this incorrect comment-line-handling behavior has persisted into the most recent 17.09 release candidate. cc @thaJeztah |
Grumble, grumble Fixes warnings based on: * moby/moby#33719 * moby/moby#35004
Carry #29161
Related issues #29005 and #24693
Add a warning that support for empty continuation lines will be removed in a future release.