Keep original FileInfo persisted on file.Metadata structs (#1794)

* pull in fileinfo changes from stereoscope #172

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* fix CLI test assumption about the docker daemon

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

---------

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: <>
This commit is contained in:
Alex Goodman
2023-05-19 14:21:10 +00:00
committed by GitHub
parent f1b6f38ea8
commit 334a775cb9
20 changed files with 152 additions and 59 deletions
+1 -1
View File
@@ -307,7 +307,7 @@ func (r *directoryIndexer) disallowRevisitingVisitor(path string, _ os.FileInfo,
// - link destinations twice, once for the real file and another through the virtual path
// - infinite link cycles
if indexed, metadata := r.hasBeenIndexed(path); indexed {
if metadata.IsDir {
if metadata.IsDir() {
// signal to walk() that we should skip this directory entirely
return fs.SkipDir
}
+2 -2
View File
@@ -196,7 +196,7 @@ func (r directoryResolver) FilesByPath(userPaths ...string) ([]Location, error)
}
// don't consider directories
if entry.Metadata.IsDir {
if entry.Metadata.IsDir() {
continue
}
@@ -238,7 +238,7 @@ func (r directoryResolver) FilesByGlob(patterns ...string) ([]Location, error) {
}
// don't consider directories
if entry.Metadata.IsDir {
if entry.Metadata.IsDir() {
continue
}
+1 -1
View File
@@ -949,7 +949,7 @@ func TestDirectoryResolver_FilesContents_errorOnDirRequest(t *testing.T) {
for loc := range resolver.AllLocations() {
entry, err := resolver.index.Get(loc.ref)
require.NoError(t, err)
if entry.Metadata.IsDir {
if entry.Metadata.IsDir() {
dirLoc = &loc
break
}
+2 -2
View File
@@ -100,7 +100,7 @@ func (r *imageAllLayersResolver) FilesByPath(paths ...string) ([]Location, error
if err != nil {
return nil, fmt.Errorf("unable to get file metadata for path=%q: %w", ref.RealPath, err)
}
if metadata.Metadata.IsDir {
if metadata.Metadata.IsDir() {
continue
}
}
@@ -143,7 +143,7 @@ func (r *imageAllLayersResolver) FilesByGlob(patterns ...string) ([]Location, er
return nil, fmt.Errorf("unable to get file metadata for path=%q: %w", result.RequestPath, err)
}
// don't consider directories
if metadata.Metadata.IsDir {
if metadata.Metadata.IsDir() {
continue
}
}
@@ -370,7 +370,7 @@ func TestAllLayersImageResolver_FilesContents_errorOnDirRequest(t *testing.T) {
for loc := range resolver.AllLocations() {
entry, err := resolver.img.FileCatalog.Get(loc.ref)
require.NoError(t, err)
if entry.Metadata.IsDir {
if entry.Metadata.IsDir() {
dirLoc = &loc
break
}
+2 -2
View File
@@ -56,7 +56,7 @@ func (r *imageSquashResolver) FilesByPath(paths ...string) ([]Location, error) {
return nil, fmt.Errorf("unable to get file metadata for path=%q: %w", ref.RealPath, err)
}
// don't consider directories
if metadata.Metadata.IsDir {
if metadata.Metadata.IsDir() {
continue
}
}
@@ -103,7 +103,7 @@ func (r *imageSquashResolver) FilesByGlob(patterns ...string) ([]Location, error
return nil, fmt.Errorf("unable to get file metadata for path=%q: %w", result.RequestPath, err)
}
// don't consider directories
if metadata.Metadata.IsDir {
if metadata.Metadata.IsDir() {
continue
}
}
+1 -1
View File
@@ -354,7 +354,7 @@ func TestSquashImageResolver_FilesContents_errorOnDirRequest(t *testing.T) {
for loc := range resolver.AllLocations() {
entry, err := resolver.img.FileCatalog.Get(loc.ref)
require.NoError(t, err)
if entry.Metadata.IsDir {
if entry.Metadata.IsDir() {
dirLoc = &loc
break
}
+4 -5
View File
@@ -168,11 +168,10 @@ func (r MockResolver) FileMetadataByLocation(l Location) (FileMetadata, error) {
}
return FileMetadata{
Mode: info.Mode(),
Type: ty,
UserID: 0, // not supported
GroupID: 0, // not supported
Size: info.Size(),
FileInfo: info,
Type: ty,
UserID: 0, // not supported
GroupID: 0, // not supported
}, nil
}