Bladeren bron

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 10 jaren geleden
bovenliggende
commit
6784a772ba
4 gewijzigde bestanden met toevoegingen van 4 en 2 verwijderingen
  1. 1 0
      builder/command/command.go
  2. 1 1
      builder/dispatchers.go
  3. 1 0
      builder/evaluator.go
  4. 1 1
      builder/parser/line_parsers.go

+ 1 - 0
builder/command/command.go

@@ -22,6 +22,7 @@ const (
 // Commands is list of all Dockerfile commands
 // Commands is list of all Dockerfile commands
 var Commands = map[string]struct{}{
 var Commands = map[string]struct{}{
 	Env:        {},
 	Env:        {},
+	Label:      {},
 	Maintainer: {},
 	Maintainer: {},
 	Add:        {},
 	Add:        {},
 	Copy:       {},
 	Copy:       {},

+ 1 - 1
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 {
 func label(b *Builder, args []string, attributes map[string]bool, original string) error {
 	if len(args) == 0 {
 	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 {
 	if len(args)%2 != 0 {
 		// should never get here, but just in case
 		// should never get here, but just in case

+ 1 - 0
builder/evaluator.go

@@ -49,6 +49,7 @@ var (
 // Environment variable interpolation will happen on these statements only.
 // Environment variable interpolation will happen on these statements only.
 var replaceEnvAllowed = map[string]struct{}{
 var replaceEnvAllowed = map[string]struct{}{
 	command.Env:     {},
 	command.Env:     {},
+	command.Label:   {},
 	command.Add:     {},
 	command.Add:     {},
 	command.Copy:    {},
 	command.Copy:    {},
 	command.Workdir: {},
 	command.Workdir: {},

+ 1 - 1
builder/parser/line_parsers.go

@@ -137,7 +137,7 @@ func parseNameVal(rest string, key string) (*Node, map[string]bool, error) {
 	}
 	}
 
 
 	if len(words) == 0 {
 	if len(words) == 0 {
-		return nil, nil, fmt.Errorf(key + " requires at least one argument")
+		return nil, nil, nil
 	}
 	}
 
 
 	// Old format (KEY name value)
 	// Old format (KEY name value)