Skip to content

Commit

Permalink
include-dir-bins flag
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Quest <[email protected]>
  • Loading branch information
kcq committed Feb 2, 2024
1 parent bdc4002 commit 0ed83d9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 43 deletions.
1 change: 1 addition & 0 deletions pkg/app/master/command/build/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ var CLI = &cli.Command{
cflag(FlagPreservePathFile),
cflag(FlagIncludePath),
cflag(FlagIncludePathFile),
cflag(FlagIncludeDirBins),
cflag(FlagIncludeBin),
cflag(FlagIncludeBinFile),
cflag(FlagIncludeExeFile),
Expand Down
86 changes: 43 additions & 43 deletions pkg/app/sensor/artifact/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -2278,60 +2278,60 @@ addExtraBinIncludes:
}

err := filepath.Walk(inPath,
func(pth string, info os.FileInfo, err error) error {
if strings.HasPrefix(pth, "/proc/") {
log.Debugf("skipping /proc file system objects... - '%s'", pth)
return filepath.SkipDir
}
func(pth string, info os.FileInfo, err error) error {
if strings.HasPrefix(pth, "/proc/") {
log.Debugf("skipping /proc file system objects... - '%s'", pth)
return filepath.SkipDir
}

if strings.HasPrefix(pth, "/sys/") {
log.Debugf("skipping /sys file system objects... - '%s'", pth)
return filepath.SkipDir
}
if strings.HasPrefix(pth, "/sys/") {
log.Debugf("skipping /sys file system objects... - '%s'", pth)
return filepath.SkipDir
}

if strings.HasPrefix(pth, "/dev/") {
log.Debugf("skipping /dev file system objects... - '%s'", pth)
return filepath.SkipDir
}
if strings.HasPrefix(pth, "/dev/") {
log.Debugf("skipping /dev file system objects... - '%s'", pth)
return filepath.SkipDir
}

// Optimization: Exclude folders early on to prevent slow enumerat
// Can help with mounting big folders from the host.
// TODO: Combine this logic with the similar logic in findSymlinks().
for _, xpattern := range excludePatterns {
if match, _ := doublestar.Match(xpattern, pth); match {
if info.Mode().IsDir() {
return filepath.SkipDir
// Optimization: Exclude folders early on to prevent slow enumerat
// Can help with mounting big folders from the host.
// TODO: Combine this logic with the similar logic in findSymlinks().
for _, xpattern := range excludePatterns {
if match, _ := doublestar.Match(xpattern, pth); match {
if info.Mode().IsDir() {
return filepath.SkipDir
}
return nil
}
return nil
}
}

if err != nil {
log.Debugf("skipping %s with error: %v", pth, err)
return nil
}
if err != nil {
log.Debugf("skipping %s with error: %v", pth, err)
return nil
}

if !info.Mode().IsRegular() {
return nil
}
if !info.Mode().IsRegular() {
return nil
}

pth, err = filepath.Abs(pth)
if err != nil {
return nil
}
pth, err = filepath.Abs(pth)
if err != nil {
return nil
}

if strings.HasPrefix(pth, "/proc/") ||
strings.HasPrefix(pth, "/sys/") ||
strings.HasPrefix(pth, "/dev/") {
return nil
}
if strings.HasPrefix(pth, "/proc/") ||
strings.HasPrefix(pth, "/sys/") ||
strings.HasPrefix(pth, "/dev/") {
return nil
}

if binProps, _ := binfile.Detected(pth); binProps != nil && binProps.IsBin {
binPathMap[pth] = struct{}{}
}
if binProps, _ := binfile.Detected(pth); binProps != nil && binProps.IsBin {
binPathMap[pth] = struct{}{}
}

return nil
})
return nil
})

if err != nil {
log.Errorf("saveArtifacts - error enumerating includeDirBinsList dir (%s) - %v", inPath, err)
Expand Down

0 comments on commit 0ed83d9

Please sign in to comment.