Parser errors on dockerfiles without instructions

See https://github.com/moby/moby/pull/38487 for more discussion.

Signed-off-by: Natasha Jarus <linuxmercedes@gmail.com>
(cherry picked from commit 2ec7d53b00)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
docker-18.09^2
linuxmercedes 2019-01-04 12:57:32 -06:00 committed by Sebastiaan van Stijn
parent ed4da8b4a9
commit 045e3a24dd
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
3 changed files with 8 additions and 0 deletions

View File

@ -275,6 +275,11 @@ func Parse(rwc io.Reader) (*Result, error) {
if len(warnings) > 0 {
warnings = append(warnings, "[WARNING]: Empty continuation lines will become errors in a future release.")
}
if root.StartLine < 0 {
return nil, errors.New("file with no instructions.")
}
return &Result{
AST: root,
Warnings: warnings,

View File

@ -0,0 +1,3 @@
# Hello
# These are just comments