Merge pull request #20582 from flouthoc/remove-symlink-from-repo

remote,test: remove `.dockerignore` which is a symlink
This commit is contained in:
openshift-ci[bot]
2023-11-03 17:17:27 +00:00
committed by GitHub
2 changed files with 13 additions and 2 deletions

View File

@ -1 +0,0 @@
/tmp/private_file

View File

@ -441,13 +441,25 @@ RUN find /test`, CITEST_IMAGE)
It("podman remote build must not allow symlink for ignore files", func() { It("podman remote build must not allow symlink for ignore files", func() {
// Create a random file where symlink must be resolved // Create a random file where symlink must be resolved
// but build should not be able to access it. // but build should not be able to access it.
f, err := os.Create(filepath.Join("/tmp", "private_file")) privateFile := filepath.Join("/tmp", "private_file")
f, err := os.Create(privateFile)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
// Mark hello to be ignored in outerfile, but it should not be ignored. // Mark hello to be ignored in outerfile, but it should not be ignored.
_, err = f.WriteString("hello\n") _, err = f.WriteString("hello\n")
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
defer f.Close() defer f.Close()
// Create .dockerignore which is a symlink to /tmp/private_file.
currentDir, err := os.Getwd()
Expect(err).ToNot(HaveOccurred())
ignoreFile := filepath.Join(currentDir, "build/containerignore-symlink/.dockerignore")
err = os.Symlink(privateFile, ignoreFile)
Expect(err).ToNot(HaveOccurred())
// Remove created .dockerignore for this test when test ends.
defer func() {
os.Remove(ignoreFile)
}()
if IsRemote() { if IsRemote() {
podmanTest.StopRemoteService() podmanTest.StopRemoteService()
podmanTest.StartRemoteService() podmanTest.StartRemoteService()