1
0
mirror of https://github.com/openshift/source-to-image.git synced 2026-02-05 12:44:54 +01:00

Dockerfile Injection Removal

* Add script to remove secrets injected into Dockerfile builds
* Ensure dockerfile failure reason is reported in build result
This commit is contained in:
Adam Kaplan
2018-08-15 16:23:57 -04:00
parent a6f9beadd2
commit 075b8b9c36
6 changed files with 105 additions and 42 deletions

View File

@@ -751,12 +751,20 @@ func TestDockerfileBuildInjections(t *testing.T) {
if err != nil {
t.Errorf("Unable to create injection dir: %v", err)
}
_, err = ioutil.TempFile(injection1, "injectfile-1")
if err != nil {
t.Errorf("Unable to create injection file: %v", err)
}
injection2 := filepath.Join(tempdir, "injection2")
err = os.Mkdir(injection2, 0777)
if err != nil {
t.Errorf("Unable to create injection dir: %v", err)
}
_, err = ioutil.TempFile(injection2, "injectfile-2")
if err != nil {
t.Errorf("Unable to create injection file: %v", err)
}
config := &api.Config{
BuilderImage: "docker.io/centos/nodejs-8-centos7",
@@ -792,7 +800,8 @@ func TestDockerfileBuildInjections(t *testing.T) {
expected := []string{
"COPY --chown=1001:0 upload/injections" + trimmedInjection1 + " /workdir/injection1",
"COPY --chown=1001:0 upload/injections" + trimmedInjection2 + " /destination/injection2",
"rm -rf /workdir/injection1",
"COPY --chown=1001:0 upload/scripts/clear-injections /tmp/scripts/clear-injections",
"RUN /tmp/scripts/clear-injections && rm /tmp/scripts/clear-injections",
}
notExpected := []string{
"rm -rf /destination/injection2",
@@ -801,6 +810,7 @@ func TestDockerfileBuildInjections(t *testing.T) {
filepath.Join(tempdir, "upload/src/server.js"),
filepath.Join(tempdir, "upload/injections"+trimmedInjection1),
filepath.Join(tempdir, "upload/injections"+trimmedInjection2),
filepath.Join(tempdir, "upload/scripts/clear-injections"),
}
runDockerfileTest(t, config, expected, notExpected, expectedFiles)
}