Skip to content

Commit

Permalink
Merge pull request moby#15531 from Microsoft/10662-buildercommands
Browse files Browse the repository at this point in the history
Windows: Error on unsupported builder command
  • Loading branch information
LK4D4 committed Aug 12, 2015
2 parents d8ff9ef + 394ccfa commit d50d56b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions builder/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"io"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/Sirupsen/logrus"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit d50d56b

Please sign in to comment.