From ad61919ab684b1a6f7805f21ed911738b84c0697 Mon Sep 17 00:00:00 2001 From: Doug Davis Date: Mon, 16 Mar 2015 22:23:40 -0700 Subject: [PATCH] Some fixed for new LABEL stuff - command.Commands was missing "Label" - used the correct error string in dispatcher when LABEL has no args, otherwise the test TestBuildMissingArgs will not work - removed the premature error msg in line_parser that was blocking the label() func in dispatcher from showing the err msg in previous bullet - since LABEL uses the env parser it needs to be added to the replaceEnvAllowed list so that proper quote processing will be done. Especially once PR #10431 is merged. Signed-off-by: Doug Davis Upstream-commit: 6784a772baaa20936f00b8adc00a4b4444356181 Component: engine --- components/engine/builder/command/command.go | 1 + components/engine/builder/dispatchers.go | 2 +- components/engine/builder/evaluator.go | 1 + components/engine/builder/parser/line_parsers.go | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/engine/builder/command/command.go b/components/engine/builder/command/command.go index dd24ee44c5..16544f0267 100644 --- a/components/engine/builder/command/command.go +++ b/components/engine/builder/command/command.go @@ -22,6 +22,7 @@ const ( // Commands is list of all Dockerfile commands var Commands = map[string]struct{}{ Env: {}, + Label: {}, Maintainer: {}, Add: {}, Copy: {}, diff --git a/components/engine/builder/dispatchers.go b/components/engine/builder/dispatchers.go index 965fd68c03..3cb3a9fb3a 100644 --- a/components/engine/builder/dispatchers.go +++ b/components/engine/builder/dispatchers.go @@ -91,7 +91,7 @@ func maintainer(b *Builder, args []string, attributes map[string]bool, original // func label(b *Builder, args []string, attributes map[string]bool, original string) error { if len(args) == 0 { - return fmt.Errorf("LABEL is missing arguments") + return fmt.Errorf("LABEL requires at least one argument") } if len(args)%2 != 0 { // should never get here, but just in case diff --git a/components/engine/builder/evaluator.go b/components/engine/builder/evaluator.go index aee60426c1..9808a3c42d 100644 --- a/components/engine/builder/evaluator.go +++ b/components/engine/builder/evaluator.go @@ -49,6 +49,7 @@ var ( // Environment variable interpolation will happen on these statements only. var replaceEnvAllowed = map[string]struct{}{ command.Env: {}, + command.Label: {}, command.Add: {}, command.Copy: {}, command.Workdir: {}, diff --git a/components/engine/builder/parser/line_parsers.go b/components/engine/builder/parser/line_parsers.go index 06115e831a..45c929ee69 100644 --- a/components/engine/builder/parser/line_parsers.go +++ b/components/engine/builder/parser/line_parsers.go @@ -137,7 +137,7 @@ func parseNameVal(rest string, key string) (*Node, map[string]bool, error) { } if len(words) == 0 { - return nil, nil, fmt.Errorf(key + " requires at least one argument") + return nil, nil, nil } // Old format (KEY name value)