From 394ccfac0782d9877b430b5c7ef75374edcb94e8 Mon Sep 17 00:00:00 2001 From: John Howard Date: Wed, 12 Aug 2015 10:00:04 -0700 Subject: [PATCH] Windows: Error on unsupported builder command Signed-off-by: John Howard --- builder/evaluator.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/builder/evaluator.go b/builder/evaluator.go index 0a59a05d4e..de0fbe5f67 100644 --- a/builder/evaluator.go +++ b/builder/evaluator.go @@ -24,6 +24,7 @@ import ( "io" "os" "path/filepath" + "runtime" "strings" "github.com/Sirupsen/logrus" @@ -281,6 +282,13 @@ func (b *builder) readDockerfile() error { // features. func (b *builder) dispatch(stepN int, ast *parser.Node) error { cmd := ast.Value + + // To ensure the user is give a decent error message if the platform + // on which the daemon is running does not support a builder command. + if err := platformSupports(strings.ToLower(cmd)); err != nil { + return err + } + attrs := ast.Attributes original := ast.Original flags := ast.Flags @@ -349,3 +357,16 @@ func (b *builder) dispatch(stepN int, ast *parser.Node) error { return fmt.Errorf("Unknown instruction: %s", strings.ToUpper(cmd)) } + +// platformSupports is a short-term function to give users a quality error +// message if a Dockerfile uses a command not supported on the platform. +func platformSupports(command string) error { + if runtime.GOOS != "windows" { + return nil + } + switch command { + case "expose", "volume", "user": + return fmt.Errorf("The daemon on this platform does not support the command '%s'", command) + } + return nil +}