mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #8187 from erikh/builder_onbuild_output
builder: properly communicate onbuild trigger information during subsequent builds.
This commit is contained in:
commit
27567e5593
2 changed files with 24 additions and 1 deletions
|
@ -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
|
// 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
|
// onbuild are muted because we have no good way to represent the step
|
||||||
// number
|
// number
|
||||||
for _, step := range onBuildTriggers {
|
for stepN, step := range onBuildTriggers {
|
||||||
splitStep := strings.Split(step, " ")
|
splitStep := strings.Split(step, " ")
|
||||||
stepInstruction := strings.ToUpper(strings.Trim(splitStep[0], " "))
|
stepInstruction := strings.ToUpper(strings.Trim(splitStep[0], " "))
|
||||||
switch stepInstruction {
|
switch stepInstruction {
|
||||||
|
@ -392,6 +392,7 @@ func (b *Builder) processImageFrom(img *imagepkg.Image) error {
|
||||||
// longer be necessary.
|
// longer be necessary.
|
||||||
|
|
||||||
if f, ok := evaluateTable[strings.ToLower(stepInstruction)]; ok {
|
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 {
|
if err := f(b, splitStep[1:], nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2142,3 +2142,25 @@ func TestBuildEmptyCmd(t *testing.T) {
|
||||||
}
|
}
|
||||||
logDone("build - empty cmd")
|
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")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue