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:
@ -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")
|
||||
|
||||
|
Reference in New Issue
Block a user