Fixes #26027
Signed-off-by: Doug Davis <dug@us.ibm.com>
... | ... |
@@ -229,7 +229,7 @@ func (b *Builder) build(stdout io.Writer, stderr io.Writer, out io.Writer) (stri |
229 | 229 |
if len(b.options.Labels) > 0 { |
230 | 230 |
line := "LABEL " |
231 | 231 |
for k, v := range b.options.Labels { |
232 |
- line += fmt.Sprintf("%q=%q ", k, v) |
|
232 |
+ line += fmt.Sprintf("%q='%s' ", k, v) |
|
233 | 233 |
} |
234 | 234 |
_, node, err := parser.ParseLine(line, &b.directive) |
235 | 235 |
if err != nil { |
... | ... |
@@ -6638,6 +6638,19 @@ func (s *DockerSuite) TestBuildLabelsOverride(c *check.C) { |
6638 | 6638 |
c.Fatalf("Labels %s, expected %s", res, expected) |
6639 | 6639 |
} |
6640 | 6640 |
|
6641 |
+ // Command line option labels with env var |
|
6642 |
+ name = "scratchz" |
|
6643 |
+ expected = `{"bar":"$PATH"}` |
|
6644 |
+ _, err = buildImage(name, |
|
6645 |
+ `FROM scratch`, |
|
6646 |
+ true, "--label", "bar=$PATH") |
|
6647 |
+ c.Assert(err, check.IsNil) |
|
6648 |
+ |
|
6649 |
+ res = inspectFieldJSON(c, name, "Config.Labels") |
|
6650 |
+ if res != expected { |
|
6651 |
+ c.Fatalf("Labels %s, expected %s", res, expected) |
|
6652 |
+ } |
|
6653 |
+ |
|
6641 | 6654 |
} |
6642 | 6655 |
|
6643 | 6656 |
// Test case for #22855 |