summaryrefslogtreecommitdiff
path: root/pkg/bindings/images
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-03-28 15:14:19 +0200
committerGitHub <noreply@github.com>2022-03-28 15:14:19 +0200
commite1699d8591ab87717ae018583c896561c43efb29 (patch)
treef9ce0e691659969510b13714b047c3af49a5ed80 /pkg/bindings/images
parentaeae59804990e98fea6cd64388c99a1d863a7cb5 (diff)
parentd106b294b428fbb10f59d4cafe72c3dcaa4e73bb (diff)
downloadpodman-e1699d8591ab87717ae018583c896561c43efb29.tar.gz
podman-e1699d8591ab87717ae018583c896561c43efb29.tar.bz2
podman-e1699d8591ab87717ae018583c896561c43efb29.zip
Merge pull request #13668 from rhatdan/walk
Switch all calls to filepath.Walk to filepath.WalkDir
Diffstat (limited to 'pkg/bindings/images')
-rw-r--r--pkg/bindings/images/build.go23
1 files changed, 18 insertions, 5 deletions
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go
index e1b427742..f6739b7ca 100644
--- a/pkg/bindings/images/build.go
+++ b/pkg/bindings/images/build.go
@@ -7,6 +7,7 @@ import (
"encoding/json"
"fmt"
"io"
+ "io/fs"
"io/ioutil"
"net/http"
"net/url"
@@ -557,14 +558,14 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
merr = multierror.Append(merr, err)
return
}
- err = filepath.Walk(s, func(path string, info os.FileInfo, err error) error {
+ err = filepath.WalkDir(s, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
// 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 info.IsDir() && s == path {
+ if d.IsDir() && s == path {
var p *os.File
p, err = os.Open(path)
if err != nil {
@@ -588,7 +589,11 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
return nil
}
- if info.Mode().IsRegular() { // add file item
+ if d.Type().IsRegular() { // add file item
+ info, err := d.Info()
+ if err != nil {
+ return err
+ }
di, isHardLink := checkHardLink(info)
if err != nil {
return err
@@ -624,7 +629,11 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
seen[di] = name
}
return err
- } else if info.Mode().IsDir() { // add folders
+ } else if d.IsDir() { // add folders
+ info, err := d.Info()
+ if err != nil {
+ return err
+ }
hdr, lerr := tar.FileInfoHeader(info, name)
if lerr != nil {
return lerr
@@ -634,11 +643,15 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
if lerr := tw.WriteHeader(hdr); lerr != nil {
return lerr
}
- } else if info.Mode()&os.ModeSymlink != 0 { // add symlinks as it, not content
+ } else if d.Type()&os.ModeSymlink != 0 { // add symlinks as it, not content
link, err := os.Readlink(path)
if err != nil {
return err
}
+ info, err := d.Info()
+ if err != nil {
+ return err
+ }
hdr, lerr := tar.FileInfoHeader(info, link)
if lerr != nil {
return lerr