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

builder: properly communicate onbuild trigger information during

subsequent builds.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
This commit is contained in:
Erik Hollensbe 2014-09-23 13:31:42 -07:00
parent 42ec80bec0
commit 8edacc673a
2 changed files with 24 additions and 1 deletions

View file

@ -377,7 +377,7 @@ func (b *Builder) processImageFrom(img *imagepkg.Image) error {
// FIXME rewrite this so that builder/parser is used; right now steps in
// onbuild are muted because we have no good way to represent the step
// number
for _, step := range onBuildTriggers {
for stepN, step := range onBuildTriggers {
splitStep := strings.Split(step, " ")
stepInstruction := strings.ToUpper(strings.Trim(splitStep[0], " "))
switch stepInstruction {
@ -392,6 +392,7 @@ func (b *Builder) processImageFrom(img *imagepkg.Image) error {
// longer be necessary.
if f, ok := evaluateTable[strings.ToLower(stepInstruction)]; ok {
fmt.Fprintf(b.OutStream, "Trigger %d, %s\n", stepN, step)
if err := f(b, splitStep[1:], nil); err != nil {
return err
}

View file

@ -2142,3 +2142,25 @@ func TestBuildEmptyCmd(t *testing.T) {
}
logDone("build - empty cmd")
}
func TestBuildOnBuildOutput(t *testing.T) {
name := "testbuildonbuildparent"
defer deleteImages(name)
if _, err := buildImage(name, "FROM busybox\nONBUILD RUN echo foo\n", true); err != nil {
t.Fatal(err)
}
childname := "testbuildonbuildchild"
defer deleteImages(childname)
_, out, err := buildImageWithOut(name, "FROM "+name+"\nMAINTAINER quux\n", true)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(out, "Trigger 0, run echo foo") {
t.Fatal("failed to find the ONBUILD output")
}
logDone("build - onbuild output")
}