Labels set on the command line always override labels in Dockerfile
This fix tries to address the inconsistency in #22036 where labels set on the command line will not override labels specified in Dockerfile, but will override labels inherited from `FROM` images. The fix add a LABEL with command line options at the end of the processed Dockerfile so that command line options labels always override the LABEL in Dockerfiles (or through `FROM`). An integration test has been added for test cases specified in #22036. This fix fixes #22036. NOTE: Some changes are from #22266 (@tiborvass). Signed-off-by: Yong Tang <yong.tang.github@outlook.com> Upstream-commit: 5844736c14b29860ea03b040e9a052e59ad75bfc Component: engine
This commit is contained in:
@ -34,7 +34,7 @@ func parseSubCommand(rest string) (*Node, map[string]bool, error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
_, child, err := parseLine(rest)
|
||||
_, child, err := ParseLine(rest)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@ -68,8 +68,8 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// parse a line and return the remainder.
|
||||
func parseLine(line string) (string, *Node, error) {
|
||||
// ParseLine parse a line and return the remainder.
|
||||
func ParseLine(line string) (string, *Node, error) {
|
||||
if line = stripComments(line); line == "" {
|
||||
return "", nil, nil
|
||||
}
|
||||
@ -111,7 +111,7 @@ func Parse(rwc io.Reader) (*Node, error) {
|
||||
for scanner.Scan() {
|
||||
scannedLine := strings.TrimLeftFunc(scanner.Text(), unicode.IsSpace)
|
||||
currentLine++
|
||||
line, child, err := parseLine(scannedLine)
|
||||
line, child, err := ParseLine(scannedLine)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -126,7 +126,7 @@ func Parse(rwc io.Reader) (*Node, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
line, child, err = parseLine(line + newline)
|
||||
line, child, err = ParseLine(line + newline)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -136,7 +136,7 @@ func Parse(rwc io.Reader) (*Node, error) {
|
||||
}
|
||||
}
|
||||
if child == nil && line != "" {
|
||||
_, child, err = parseLine(line)
|
||||
_, child, err = ParseLine(line)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user