mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
fix linting
Signed-off-by: Kudryavcev Nikolay <kydry.nikolau@gmail.com>
This commit is contained in:
parent
17a66f0186
commit
01e6de0716
@ -45,7 +45,7 @@ func ExtractGlobsFromTarToUniqueTempFile(ctx context.Context, archivePath, dir s
|
||||
return results, nil
|
||||
}
|
||||
|
||||
visitor := func(ctx context.Context, file archives.FileInfo) error {
|
||||
visitor := func(_ context.Context, file archives.FileInfo) error {
|
||||
// ignore directories
|
||||
if file.IsDir() {
|
||||
return nil
|
||||
|
||||
@ -28,7 +28,7 @@ func NewZipFileManifest(ctx context.Context, archivePath string) (ZipFileManifes
|
||||
}
|
||||
}()
|
||||
|
||||
err = archives.Zip{}.Extract(ctx, zipReader, func(ctx context.Context, file archives.FileInfo) error {
|
||||
err = archives.Zip{}.Extract(ctx, zipReader, func(_ context.Context, file archives.FileInfo) error {
|
||||
manifest.Add(file.NameInArchive, file.FileInfo)
|
||||
return nil
|
||||
})
|
||||
|
||||
@ -75,7 +75,7 @@ func ExtractFromZipToUniqueTempFile(ctx context.Context, archivePath, dir string
|
||||
return results, nil
|
||||
}
|
||||
|
||||
visitor := func(ctx context.Context, file archives.FileInfo) error {
|
||||
visitor := func(_ context.Context, file archives.FileInfo) error {
|
||||
tempfilePrefix := filepath.Base(filepath.Clean(file.NameInArchive)) + "-"
|
||||
tempFile, err := os.CreateTemp(dir, tempfilePrefix)
|
||||
if err != nil {
|
||||
@ -121,7 +121,7 @@ func ContentsFromZip(ctx context.Context, archivePath string, paths ...string) (
|
||||
return results, nil
|
||||
}
|
||||
|
||||
visitor := func(ctx context.Context, file archives.FileInfo) error {
|
||||
visitor := func(_ context.Context, file archives.FileInfo) error {
|
||||
zippedFile, err := file.Open()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to read file=%q from zip=%q: %w", file.NameInArchive, archivePath, err)
|
||||
@ -151,7 +151,7 @@ func ContentsFromZip(ctx context.Context, archivePath string, paths ...string) (
|
||||
|
||||
// UnzipToDir extracts a zip archive to a target directory.
|
||||
func UnzipToDir(ctx context.Context, archivePath, targetDir string) error {
|
||||
visitor := func(ctx context.Context, file archives.FileInfo) error {
|
||||
visitor := func(_ context.Context, file archives.FileInfo) error {
|
||||
joinedPath, err := safeJoin(targetDir, file.NameInArchive)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -251,18 +251,19 @@ func digestOfFileContents(path string) string {
|
||||
}
|
||||
|
||||
func unarchiveToTmp(path string, unarchiver archives.Extractor) (string, func() error, error) {
|
||||
var cleanupFn = func() error { return nil }
|
||||
archive, err := os.Open(path)
|
||||
if err != nil {
|
||||
fmt.Errorf("unable to open archive: %v", err)
|
||||
return "", cleanupFn, fmt.Errorf("unable to open archive: %v", err)
|
||||
}
|
||||
defer archive.Close()
|
||||
|
||||
tempDir, err := os.MkdirTemp("", "syft-archive-contents-")
|
||||
if err != nil {
|
||||
return "", func() error { return nil }, fmt.Errorf("unable to create tempdir for archive processing: %w", err)
|
||||
return "", cleanupFn, fmt.Errorf("unable to create tempdir for archive processing: %w", err)
|
||||
}
|
||||
|
||||
visitor := func(ctx context.Context, file archives.FileInfo) error {
|
||||
visitor := func(_ context.Context, file archives.FileInfo) error {
|
||||
destPath := filepath.Join(tempDir, file.NameInArchive)
|
||||
if file.IsDir() {
|
||||
return os.MkdirAll(destPath, file.Mode())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user