1
0
mirror of https://github.com/moby/moby.git synced 2025-07-29 07:21:35 +03:00

Apply build labels to images with only a FROM tag.

Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
David Calavera
2016-03-30 17:26:02 -04:00
parent 8dabc0c39b
commit 1a85c8ebbe
4 changed files with 66 additions and 9 deletions

View File

@ -6680,11 +6680,9 @@ func (s *DockerSuite) TestBuildLabel(c *check.C) {
_, err := buildImage(name, `
FROM `+minimalBaseImage()+`
LABEL default foo
`, false, []string{"--label", testLabel}...)
`, false, "--label", testLabel)
if err != nil {
c.Fatal("error building image with labels", err)
}
c.Assert(err, checker.IsNil)
res := inspectFieldJSON(c, name, "Config.Labels")
@ -6699,6 +6697,28 @@ func (s *DockerSuite) TestBuildLabel(c *check.C) {
}
}
func (s *DockerSuite) TestBuildLabelOneNode(c *check.C) {
name := "testbuildlabel"
_, err := buildImage(name, "FROM busybox", false, "--label", "foo=bar")
c.Assert(err, checker.IsNil)
res, err := inspectImage(name, "json .Config.Labels")
c.Assert(err, checker.IsNil)
var labels map[string]string
if err := json.Unmarshal([]byte(res), &labels); err != nil {
c.Fatal(err)
}
v, ok := labels["foo"]
if !ok {
c.Fatal("label `foo` not found in image")
}
c.Assert(v, checker.Equals, "bar")
}
func (s *DockerSuite) TestBuildLabelCacheCommit(c *check.C) {
name := "testbuildlabelcachecommit"
testLabel := "foo"
@ -6713,11 +6733,9 @@ func (s *DockerSuite) TestBuildLabelCacheCommit(c *check.C) {
_, err := buildImage(name, `
FROM `+minimalBaseImage()+`
LABEL default foo
`, true, []string{"--label", testLabel}...)
`, true, "--label", testLabel)
if err != nil {
c.Fatal("error building image with labels", err)
}
c.Assert(err, checker.IsNil)
res := inspectFieldJSON(c, name, "Config.Labels")