ignore invalid Dockerfile instructions and do not consider "docker-version" a Dockerfile instruction

Signed-off-by: Tibor Vass <teabee89@gmail.com>
This commit is contained in:
Tibor Vass 2014-10-06 23:24:43 -04:00
parent 9fe1dd3103
commit 0a2c481c7f
4 changed files with 36 additions and 38 deletions

View File

@ -52,7 +52,6 @@ func init() {
"from": from,
"onbuild": onbuild,
"workdir": workdir,
"docker-version": nullDispatch, // we don't care about docker-version
"run": run,
"cmd": cmd,
"entrypoint": entrypoint,

View File

@ -48,7 +48,6 @@ func init() {
"workdir": parseString,
"env": parseEnv,
"maintainer": parseString,
"docker-version": parseString,
"from": parseString,
"add": parseStringsWhitespaceDelimited,
"copy": parseStringsWhitespaceDelimited,

View File

@ -1,4 +1,4 @@
(docker-version "0.6.1")
(docker-version)
(from "ubuntu:14.04")
(maintainer "Tianon Gravi <admwiggin@gmail.com> (@tianon)")
(run "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq apt-utils aufs-tools automake btrfs-tools build-essential curl dpkg-sig git iptables libapparmor-dev libcap-dev libsqlite3-dev lxc=1.0* mercurial pandoc parallel reprepro ruby1.9.1 ruby1.9.1-dev s3cmd=1.1.0* --no-install-recommends")

View File

@ -1,9 +1,6 @@
package parser
import (
"fmt"
"strings"
)
import "strings"
// QuoteString walks characters (after trimming), escapes any quotes and
// escapes, then wraps the whole thing in quotes. Very useful for generating
@ -52,11 +49,14 @@ func (node *Node) Dump() string {
// performs the dispatch based on the two primal strings, cmd and args. Please
// look at the dispatch table in parser.go to see how these dispatchers work.
func fullDispatch(cmd, args string) (*Node, map[string]bool, error) {
if _, ok := dispatch[cmd]; !ok {
return nil, nil, fmt.Errorf("'%s' is not a valid dockerfile command", cmd)
fn := dispatch[cmd]
// Ignore invalid Dockerfile instructions
if fn == nil {
fn = parseIgnore
}
sexp, attrs, err := dispatch[cmd](args)
sexp, attrs, err := fn(args)
if err != nil {
return nil, nil, err
}