mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-22 10:38:44 +02:00
Skip the /kaniko directory when copying root (#2863)
This commit adds the skip option for otiai10.Copy to skip the /kaniko directory when the root is being copied. The files under /kaniko dir should be ignored and thus this shall not cause any loss of information. fixes: GoogleContainerTools#2033
This commit is contained in:
@@ -100,6 +100,7 @@ COPY --from=first copied/bam.txt output/`
|
||||
testutil.CheckDeepEqual(t, 1, len(files))
|
||||
testutil.CheckDeepEqual(t, files[0].Name(), "bam.txt")
|
||||
})
|
||||
|
||||
t.Run("copy directory across multistage into a directory", func(t *testing.T) {
|
||||
testDir, fn := setupMultistageTests(t)
|
||||
defer fn()
|
||||
@@ -135,6 +136,40 @@ COPY --from=first copied another`
|
||||
//testutil.CheckDeepEqual(t, linkName, "bam.txt")
|
||||
})
|
||||
|
||||
t.Run("copy root across multistage", func(t *testing.T) {
|
||||
testDir, fn := setupMultistageTests(t)
|
||||
defer fn()
|
||||
dockerFile := `
|
||||
FROM scratch as first
|
||||
COPY foo copied
|
||||
ENV test test
|
||||
|
||||
From scratch as second
|
||||
COPY --from=first / output/`
|
||||
ioutil.WriteFile(filepath.Join(testDir, "workspace", "Dockerfile"), []byte(dockerFile), 0755)
|
||||
opts := &config.KanikoOptions{
|
||||
DockerfilePath: filepath.Join(testDir, "workspace", "Dockerfile"),
|
||||
SrcContext: filepath.Join(testDir, "workspace"),
|
||||
SnapshotMode: constants.SnapshotModeFull,
|
||||
}
|
||||
_, err := DoBuild(opts)
|
||||
testutil.CheckNoError(t, err)
|
||||
|
||||
filesUnderRoot, err := ioutil.ReadDir(filepath.Join(testDir, "output/"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
testutil.CheckDeepEqual(t, 3, len(filesUnderRoot))
|
||||
|
||||
files, err := ioutil.ReadDir(filepath.Join(testDir, "output/workspace/foo"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
testutil.CheckDeepEqual(t, 2, len(files))
|
||||
testutil.CheckDeepEqual(t, "bam.link", files[0].Name())
|
||||
testutil.CheckDeepEqual(t, "bam.txt", files[1].Name())
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func setupMultistageTests(t *testing.T) (string, func()) {
|
||||
|
||||
Reference in New Issue
Block a user