From 662010292619c33db7f144890abfdd9a99b423e0 Mon Sep 17 00:00:00 2001 From: John Howard Date: Wed, 26 Aug 2015 19:45:18 -0700 Subject: [PATCH] Fix trigger count and output Signed-off-by: John Howard --- builder/internals.go | 10 ++++++---- integration-cli/docker_cli_build_test.go | 5 ++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/builder/internals.go b/builder/internals.go index 28f1b0ac7e..e5d68e2dd8 100644 --- a/builder/internals.go +++ b/builder/internals.go @@ -531,7 +531,11 @@ func (b *builder) processImageFrom(img *image.Image) error { // Process ONBUILD triggers if they exist if nTriggers := len(b.Config.OnBuild); nTriggers != 0 { - fmt.Fprintf(b.ErrStream, "# Executing %d build triggers\n", nTriggers) + word := "trigger" + if nTriggers > 1 { + word = "triggers" + } + fmt.Fprintf(b.ErrStream, "# Executing %d build %s...\n", nTriggers, word) } // Copy the ONBUILD triggers, and remove them from the config, since the config will be committed. @@ -539,7 +543,7 @@ func (b *builder) processImageFrom(img *image.Image) error { b.Config.OnBuild = []string{} // parse the ONBUILD triggers by invoking the parser - for stepN, step := range onBuildTriggers { + for _, step := range onBuildTriggers { ast, err := parser.Parse(strings.NewReader(step)) if err != nil { return err @@ -553,8 +557,6 @@ func (b *builder) processImageFrom(img *image.Image) error { return fmt.Errorf("%s isn't allowed as an ONBUILD trigger", n.Value) } - fmt.Fprintf(b.OutStream, "Trigger %d, %s\n", stepN, step) - if err := b.dispatch(i, n); err != nil { return err } diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index e2294f969b..917d495ee8 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -4255,10 +4255,9 @@ func (s *DockerSuite) TestBuildOnBuildOutput(c *check.C) { c.Fatal(err) } - if !strings.Contains(out, "Trigger 0, RUN echo foo") { - c.Fatal("failed to find the ONBUILD output", out) + if !strings.Contains(out, "# Executing 1 build trigger") { + c.Fatal("failed to find the build trigger output", out) } - } func (s *DockerSuite) TestBuildInvalidTag(c *check.C) {