Browse code

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 <dug@us.ibm.com>

Doug Davis authored on 2015/03/17 14:23:40
Showing 4 changed files
... ...
@@ -22,6 +22,7 @@ const (
22 22
 // Commands is list of all Dockerfile commands
23 23
 var Commands = map[string]struct{}{
24 24
 	Env:        {},
25
+	Label:      {},
25 26
 	Maintainer: {},
26 27
 	Add:        {},
27 28
 	Copy:       {},
... ...
@@ -91,7 +91,7 @@ func maintainer(b *Builder, args []string, attributes map[string]bool, original
91 91
 //
92 92
 func label(b *Builder, args []string, attributes map[string]bool, original string) error {
93 93
 	if len(args) == 0 {
94
-		return fmt.Errorf("LABEL is missing arguments")
94
+		return fmt.Errorf("LABEL requires at least one argument")
95 95
 	}
96 96
 	if len(args)%2 != 0 {
97 97
 		// should never get here, but just in case
... ...
@@ -49,6 +49,7 @@ var (
49 49
 // Environment variable interpolation will happen on these statements only.
50 50
 var replaceEnvAllowed = map[string]struct{}{
51 51
 	command.Env:     {},
52
+	command.Label:   {},
52 53
 	command.Add:     {},
53 54
 	command.Copy:    {},
54 55
 	command.Workdir: {},
... ...
@@ -137,7 +137,7 @@ func parseNameVal(rest string, key string) (*Node, map[string]bool, error) {
137 137
 	}
138 138
 
139 139
 	if len(words) == 0 {
140
-		return nil, nil, fmt.Errorf(key + " requires at least one argument")
140
+		return nil, nil, nil
141 141
 	}
142 142
 
143 143
 	// Old format (KEY name value)