Skip to content

Commit

Permalink
Support build of projects outside of beats directory (#36126)
Browse files Browse the repository at this point in the history
* Add project dir

* Remove comments

* Add changelog
  • Loading branch information
jeniawhite authored Jul 20, 2023
1 parent 9f28394 commit 8a9d6f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Fix recovering from invalid output configuration when running under Elastic-Agent {pull}36016[36016]
- Improve StreamBuf append to improve performance when reading long lines from files. {pull}35928[35928]
- Eliminate cloning of event in deepUpdate {pull}35945[35945]
- Support build of projects outside of beats directory {pull}36126[36126]

*Auditbeat*

Expand Down
12 changes: 12 additions & 0 deletions dev-tools/mage/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ func GolangCrossBuild(params BuildArgs) error {
return err
}

// Support projects outside of the beats directory.
repoInfo, err := GetProjectRepoInfo()
if err != nil {
return err
}

// TODO: Support custom build dir/subdir
projectMountPoint := filepath.ToSlash(filepath.Join("/go", "src", repoInfo.CanonicalRootImportPath))
if err := sh.Run("git", "config", "--global", "--add", "safe.directory", projectMountPoint); err != nil {
return err
}

return Build(params)
}

Expand Down

0 comments on commit 8a9d6f6

Please sign in to comment.