mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #8684 from erikh/onbuild_case_insensitive
builder: handle cases where onbuild is not uppercase.
This commit is contained in:
commit
a07ee0db62
2 changed files with 37 additions and 1 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/nat"
|
||||
|
@ -129,7 +130,7 @@ func onbuild(b *Builder, args []string, attributes map[string]bool, original str
|
|||
return fmt.Errorf("%s isn't allowed as an ONBUILD trigger", triggerInstruction)
|
||||
}
|
||||
|
||||
original = strings.TrimSpace(strings.TrimLeft(original, "ONBUILD"))
|
||||
original = regexp.MustCompile(`(?i)^\s*ONBUILD\s*`).ReplaceAllString(original, "")
|
||||
|
||||
b.Config.OnBuild = append(b.Config.OnBuild, original)
|
||||
return b.commit("", b.Config.Cmd, fmt.Sprintf("ONBUILD %s", original))
|
||||
|
|
|
@ -15,6 +15,41 @@ import (
|
|||
"github.com/docker/docker/pkg/archive"
|
||||
)
|
||||
|
||||
func TestBuildOnBuildLowercase(t *testing.T) {
|
||||
name := "testbuildonbuildlowercase"
|
||||
name2 := "testbuildonbuildlowercase2"
|
||||
|
||||
defer deleteImages(name, name2)
|
||||
|
||||
_, err := buildImage(name,
|
||||
`
|
||||
FROM busybox
|
||||
onbuild run echo quux
|
||||
`, true)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
_, out, err := buildImageWithOut(name2, fmt.Sprintf(`
|
||||
FROM %s
|
||||
`, name), true)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !strings.Contains(out, "quux") {
|
||||
t.Fatalf("Did not receive the expected echo text, got %s", out)
|
||||
}
|
||||
|
||||
if strings.Contains(out, "ONBUILD ONBUILD") {
|
||||
t.Fatalf("Got an ONBUILD ONBUILD error with no error: got %s", out)
|
||||
}
|
||||
|
||||
logDone("build - handle case-insensitive onbuild statement")
|
||||
}
|
||||
|
||||
func TestBuildEnvEscapes(t *testing.T) {
|
||||
name := "testbuildenvescapes"
|
||||
defer deleteAllContainers()
|
||||
|
|
Loading…
Reference in a new issue