Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"fmt" |
| 12 | 12 |
"io/ioutil" |
| 13 | 13 |
"path/filepath" |
| 14 |
+ "regexp" |
|
| 14 | 15 |
"strings" |
| 15 | 16 |
|
| 16 | 17 |
"github.com/docker/docker/nat" |
| ... | ... |
@@ -129,7 +130,7 @@ func onbuild(b *Builder, args []string, attributes map[string]bool, original str |
| 129 | 129 |
return fmt.Errorf("%s isn't allowed as an ONBUILD trigger", triggerInstruction)
|
| 130 | 130 |
} |
| 131 | 131 |
|
| 132 |
- original = strings.TrimSpace(strings.TrimLeft(original, "ONBUILD")) |
|
| 132 |
+ original = regexp.MustCompile(`(?i)^\s*ONBUILD\s*`).ReplaceAllString(original, "") |
|
| 133 | 133 |
|
| 134 | 134 |
b.Config.OnBuild = append(b.Config.OnBuild, original) |
| 135 | 135 |
return b.commit("", b.Config.Cmd, fmt.Sprintf("ONBUILD %s", original))
|
| ... | ... |
@@ -15,6 +15,41 @@ import ( |
| 15 | 15 |
"github.com/docker/docker/pkg/archive" |
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 |
+func TestBuildOnBuildLowercase(t *testing.T) {
|
|
| 19 |
+ name := "testbuildonbuildlowercase" |
|
| 20 |
+ name2 := "testbuildonbuildlowercase2" |
|
| 21 |
+ |
|
| 22 |
+ defer deleteImages(name, name2) |
|
| 23 |
+ |
|
| 24 |
+ _, err := buildImage(name, |
|
| 25 |
+ ` |
|
| 26 |
+ FROM busybox |
|
| 27 |
+ onbuild run echo quux |
|
| 28 |
+ `, true) |
|
| 29 |
+ |
|
| 30 |
+ if err != nil {
|
|
| 31 |
+ t.Fatal(err) |
|
| 32 |
+ } |
|
| 33 |
+ |
|
| 34 |
+ _, out, err := buildImageWithOut(name2, fmt.Sprintf(` |
|
| 35 |
+ FROM %s |
|
| 36 |
+ `, name), true) |
|
| 37 |
+ |
|
| 38 |
+ if err != nil {
|
|
| 39 |
+ t.Fatal(err) |
|
| 40 |
+ } |
|
| 41 |
+ |
|
| 42 |
+ if !strings.Contains(out, "quux") {
|
|
| 43 |
+ t.Fatalf("Did not receive the expected echo text, got %s", out)
|
|
| 44 |
+ } |
|
| 45 |
+ |
|
| 46 |
+ if strings.Contains(out, "ONBUILD ONBUILD") {
|
|
| 47 |
+ t.Fatalf("Got an ONBUILD ONBUILD error with no error: got %s", out)
|
|
| 48 |
+ } |
|
| 49 |
+ |
|
| 50 |
+ logDone("build - handle case-insensitive onbuild statement")
|
|
| 51 |
+} |
|
| 52 |
+ |
|
| 18 | 53 |
func TestBuildEnvEscapes(t *testing.T) {
|
| 19 | 54 |
name := "testbuildenvescapes" |
| 20 | 55 |
defer deleteAllContainers() |