mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-10-13 01:17:39 +00:00
Merge pull request #19632 from mheon/backport_18577_441rhel
Backport #18577 to v4.4.1-rhel
This commit is contained in:
commit
dd490ff943
5 changed files with 30 additions and 27 deletions
|
|
@ -220,9 +220,11 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
|
|||
var m = []string{}
|
||||
if err := json.Unmarshal([]byte(query.Dockerfile), &m); err != nil {
|
||||
// it's not json, assume just a string
|
||||
m = []string{filepath.Join(contextDirectory, query.Dockerfile)}
|
||||
m = []string{query.Dockerfile}
|
||||
}
|
||||
for _, containerfile := range m {
|
||||
containerFiles = append(containerFiles, filepath.Join(contextDirectory, filepath.Clean(filepath.FromSlash(containerfile))))
|
||||
}
|
||||
containerFiles = m
|
||||
dockerFileSet = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -637,14 +637,14 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
|
|||
defer gw.Close()
|
||||
defer tw.Close()
|
||||
seen := make(map[devino]string)
|
||||
for _, src := range sources {
|
||||
s, err := filepath.Abs(src)
|
||||
for i, src := range sources {
|
||||
source, err := filepath.Abs(src)
|
||||
if err != nil {
|
||||
logrus.Errorf("Cannot stat one of source context: %v", err)
|
||||
merr = multierror.Append(merr, err)
|
||||
return
|
||||
}
|
||||
err = filepath.WalkDir(s, func(path string, d fs.DirEntry, err error) error {
|
||||
err = filepath.WalkDir(source, func(path string, dentry fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -652,9 +652,9 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
|
|||
separator := string(filepath.Separator)
|
||||
// check if what we are given is an empty dir, if so then continue w/ it. Else return.
|
||||
// if we are given a file or a symlink, we do not want to exclude it.
|
||||
if s == path {
|
||||
if source == path {
|
||||
separator = ""
|
||||
if d.IsDir() {
|
||||
if dentry.IsDir() {
|
||||
var p *os.File
|
||||
p, err = os.Open(path)
|
||||
if err != nil {
|
||||
|
|
@ -669,8 +669,15 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
name := filepath.ToSlash(strings.TrimPrefix(path, s+separator))
|
||||
|
||||
var name string
|
||||
if i == 0 {
|
||||
name = filepath.ToSlash(strings.TrimPrefix(path, source+separator))
|
||||
} else {
|
||||
if !dentry.Type().IsRegular() {
|
||||
return fmt.Errorf("path %s must be a regular file", path)
|
||||
}
|
||||
name = filepath.ToSlash(path)
|
||||
}
|
||||
excluded, err := pm.Matches(name) //nolint:staticcheck
|
||||
if err != nil {
|
||||
return fmt.Errorf("checking if %q is excluded: %w", name, err)
|
||||
|
|
@ -682,8 +689,8 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
|
|||
return nil
|
||||
}
|
||||
switch {
|
||||
case d.Type().IsRegular(): // add file item
|
||||
info, err := d.Info()
|
||||
case dentry.Type().IsRegular(): // add file item
|
||||
info, err := dentry.Info()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -722,8 +729,8 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
|
|||
seen[di] = name
|
||||
}
|
||||
return err
|
||||
case d.IsDir(): // add folders
|
||||
info, err := d.Info()
|
||||
case dentry.IsDir(): // add folders
|
||||
info, err := dentry.Info()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -736,12 +743,12 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
|
|||
if lerr := tw.WriteHeader(hdr); lerr != nil {
|
||||
return lerr
|
||||
}
|
||||
case d.Type()&os.ModeSymlink != 0: // add symlinks as it, not content
|
||||
case dentry.Type()&os.ModeSymlink != 0: // add symlinks as it, not content
|
||||
link, err := os.Readlink(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
info, err := d.Info()
|
||||
info, err := dentry.Info()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ requests-mock~=1.9.3
|
|||
requests~=2.20.0
|
||||
setuptools~=50.3.2
|
||||
python-dateutil~=2.8.1
|
||||
PyYAML~=5.4.1
|
||||
PyYAML==6.0.1
|
||||
|
|
|
|||
|
|
@ -390,14 +390,9 @@ RUN exit 5`, ALPINE)
|
|||
if IsRemote() {
|
||||
podmanTest.StopRemoteService()
|
||||
podmanTest.StartRemoteService()
|
||||
} else {
|
||||
Skip("Only valid at remote test, case works fine for regular podman and buildah")
|
||||
}
|
||||
cwd, err := os.Getwd()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// Write target and fake files
|
||||
targetSubPath := filepath.Join(cwd, "emptydir")
|
||||
targetSubPath := filepath.Join(podmanTest.TempDir, "emptydir")
|
||||
if _, err = os.Stat(targetSubPath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
err = os.Mkdir(targetSubPath, 0755)
|
||||
|
|
@ -406,13 +401,13 @@ RUN exit 5`, ALPINE)
|
|||
}
|
||||
|
||||
containerfile := fmt.Sprintf(`FROM %s
|
||||
COPY /* /dir`, ALPINE)
|
||||
COPY /emptydir/* /dir`, ALPINE)
|
||||
|
||||
containerfilePath := filepath.Join(cwd, "ContainerfilePathToCopier")
|
||||
containerfilePath := filepath.Join(podmanTest.TempDir, "ContainerfilePathToCopier")
|
||||
err = os.WriteFile(containerfilePath, []byte(containerfile), 0644)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "-f", "ContainerfilePathToCopier", targetSubPath})
|
||||
session := podmanTest.Podman([]string{"build", "--pull-never", "-t", "test", "-f", "ContainerfilePathToCopier", podmanTest.TempDir})
|
||||
session.WaitWithDefaultTimeout()
|
||||
// NOTE: Docker and buildah both should error when `COPY /* /dir` is done on emptydir
|
||||
// as context. However buildkit simply ignores this so when buildah also starts ignoring
|
||||
|
|
@ -621,7 +616,6 @@ subdir**`
|
|||
Expect(session).To(Exit(0))
|
||||
|
||||
output := session.OutputToString()
|
||||
Expect(output).NotTo(ContainSubstring("Containerfile"))
|
||||
Expect(output).To(ContainSubstring("/testfilter/expected"))
|
||||
Expect(output).NotTo(ContainSubstring("subdir"))
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@ requests-mock~=1.9.3
|
|||
requests~=2.20.0
|
||||
setuptools~=50.3.2
|
||||
python-dateutil~=2.8.1
|
||||
PyYAML~=5.4.1
|
||||
PyYAML==6.0.1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue