Skip to content

Commit

Permalink
See if symlinking helps for interactive test
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Nov 13, 2023
1 parent b0be4f1 commit 2cdcbfd
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions pkg/osquery/interactive/interactive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,12 @@ func downloadOsquery(dir string) error {
return fmt.Errorf("error parsing platform: %w, %s", err, runtime.GOOS)
}

// Binary is already downloaded to osquerydCacheDir -- create a symlink at outputFile,
// rather than copying the file, to maybe avoid https://github.com/golang/go/issues/22315
outputFile := filepath.Join(dir, "osqueryd")

path, err := packaging.FetchBinary(context.TODO(), osquerydCacheDir, "osqueryd", target.PlatformBinaryName("osqueryd"), "stable", target)
if err != nil {
return fmt.Errorf("error fetching binary osqueryd binary: %w", err)
}

if err := fsutil.CopyFile(path, outputFile); err != nil {
return fmt.Errorf("error copying binary osqueryd binary: %w", err)
sourceFile := filepath.Join(osquerydCacheDir, fmt.Sprintf("osqueryd-%s-stable", runtime.GOOS), "osqueryd")
if err := os.Symlink(sourceFile, outputFile); err != nil {
return fmt.Errorf("creating symlink from %s to %s: %w", sourceFile, outputFile, err)
}

return nil
Expand Down

0 comments on commit 2cdcbfd

Please sign in to comment.