1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Don't env-var evaluate labels from docker build cmd line

Fixes #26027

Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
Doug Davis 2016-10-05 18:15:46 -07:00
parent e097c2a938
commit 28a9a7deb0
2 changed files with 14 additions and 1 deletions

View file

@ -229,7 +229,7 @@ func (b *Builder) build(stdout io.Writer, stderr io.Writer, out io.Writer) (stri
if len(b.options.Labels) > 0 {
line := "LABEL "
for k, v := range b.options.Labels {
line += fmt.Sprintf("%q=%q ", k, v)
line += fmt.Sprintf("%q='%s' ", k, v)
}
_, node, err := parser.ParseLine(line, &b.directive)
if err != nil {

View file

@ -6638,6 +6638,19 @@ func (s *DockerSuite) TestBuildLabelsOverride(c *check.C) {
c.Fatalf("Labels %s, expected %s", res, expected)
}
// Command line option labels with env var
name = "scratchz"
expected = `{"bar":"$PATH"}`
_, err = buildImage(name,
`FROM scratch`,
true, "--label", "bar=$PATH")
c.Assert(err, check.IsNil)
res = inspectFieldJSON(c, name, "Config.Labels")
if res != expected {
c.Fatalf("Labels %s, expected %s", res, expected)
}
}
// Test case for #22855