Skip to content

Commit

Permalink
Try not mounting in the working directory
Browse files Browse the repository at this point in the history
Signed-off-by: Natalie Arellano <narellano@vmware.com>
  • Loading branch information
natalieparellano committed Sep 1, 2022
1 parent 7e6e8fe commit 53338d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
40 changes: 18 additions & 22 deletions acceptance/extender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func testExtenderFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
})

when("kaniko case", func() {
var kanikoDir, buildImageDigest, workDir string
var kanikoDir, buildImageDigest string

it.Before(func() {
var err error
Expand All @@ -90,14 +90,10 @@ func testExtenderFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
layoutPath, err := selective.Write(filepath.Join(baseCacheDir, buildImageDigest), empty.Index)
h.AssertNil(t, err)
h.AssertNil(t, layoutPath.AppendImage(remoteImage))

workDir, err = ioutil.TempDir("", "lifecycle-acceptance")
h.AssertNil(t, err)
})

it.After(func() {
_ = os.RemoveAll(kanikoDir)
_ = os.RemoveAll(workDir)
})

when("extending the build image", func() {
Expand All @@ -117,10 +113,10 @@ func testExtenderFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--volume", fmt.Sprintf("%s:/kaniko", kanikoDir),
"--volume", fmt.Sprintf("%s:/workspace", workDir),
),
h.WithArgs(extendArgs...),
)
fmt.Println("XXX", firstOutput)
h.AssertStringContains(t, firstOutput, "ca-certificates")
h.AssertStringContains(t, firstOutput, "Hello Extensions buildpack\ncurl 7.58.0") // output by buildpack, shows that curl was installed on the build image
t.Log("sets environment variables from the extended build image in the build context")
Expand All @@ -131,22 +127,22 @@ func testExtenderFunc(platformAPI string) func(t *testing.T, when spec.G, it spe
h.AssertNil(t, err)
h.AssertEq(t, len(fis), 1) // 1: /kaniko/cache

t.Log("changing the workspace doesn't break caching")
_, err = os.Create(filepath.Join(workDir, "some-file.txt"))
h.AssertNil(t, err)

t.Log("second build extends the build image by pulling from the cache directory")
secondOutput := h.DockerRun(t,
extendImage,
h.WithFlags(
"--env", "CNB_PLATFORM_API="+platformAPI,
"--volume", fmt.Sprintf("%s:/kaniko", kanikoDir),
"--volume", fmt.Sprintf("%s:/workspace", workDir),
),
h.WithArgs(extendArgs...),
)
h.AssertStringDoesNotContain(t, secondOutput, "ca-certificates")
h.AssertStringContains(t, firstOutput, "Hello Extensions buildpack\ncurl 7.58.0") // output by buildpack, shows that curl is still installed in the unpacked cached layer
//t.Log("changing the workspace doesn't break caching")
//_, err = os.Create(filepath.Join(workDir, "some-file.txt"))
//h.AssertNil(t, err)
//
//t.Log("second build extends the build image by pulling from the cache directory")
//secondOutput := h.DockerRun(t,
// extendImage,
// h.WithFlags(
// "--env", "CNB_PLATFORM_API="+platformAPI,
// "--volume", fmt.Sprintf("%s:/kaniko", kanikoDir),
// "--volume", fmt.Sprintf("%s:/workspace", workDir),
// ),
// h.WithArgs(extendArgs...),
//)
//h.AssertStringDoesNotContain(t, secondOutput, "ca-certificates")
//h.AssertStringContains(t, firstOutput, "Hello Extensions buildpack\ncurl 7.58.0") // output by buildpack, shows that curl is still installed in the unpacked cached layer
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion buildpack/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func runBuildCmd(d BpDescriptor, bpLayersDir, planPath string, inputs BuildInput
planPath,
) // #nosec G204
fmt.Println("XXX inputs.AppDir")
//cmd.Dir = inputs.AppDir
cmd.Dir = inputs.AppDir
cmd.Stdout = inputs.Out
cmd.Stderr = inputs.Err

Expand Down

0 comments on commit 53338d1

Please sign in to comment.