-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build beats outside GOPATH #16329
Build beats outside GOPATH #16329
Conversation
@andrewkroh Could you please take a look at this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a few changes are needed. Here's my mental model of the algorithm:
- Traverse upward looking for the projects go.mod file. This is the
RootDir
. - Get the
SubDir
value by usingfilepath.Rel(RootDir, CWD())
. - Read the go.mod file to get the
RootImportPath
. - Get the
ImportPath
byfilepath.ToSlash(filepath.Join(RootImportPath, SubDir))
.
You'll definitely want to go through the code and check the usages of RootImportPath
and ImportPath
. Just to make sure that no assumptions about their values that will break things if the go.mod
module path differs from github.com/elastic/beats
(or in general differs from the earlier canonical go import paths).
And the check for IsElasticBeats()
should probably change to a HasPrefix type of check in case the go.mod module path grows to include versions (e.g. github.com/elastic/beats/v8).
d7c3c24
to
26f5c96
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good now 👍 . I do have some suggestions for naming and comments that will hopefully help others to understand and maintain this.
## What does this PR do? This PR adds support for building Beats outside GOPATH by separating repo information collection depending on the root path of the project. ## Why is it important? This lets users compile and package Beats if they have checked out the code to a non-GOPATH folder.
## What does this PR do? This PR adds support for building Beats outside GOPATH by separating repo information collection depending on the root path of the project. ## Why is it important? This lets users compile and package Beats if they have checked out the code to a non-GOPATH folder.
## What does this PR do? This PR adds support for building Beats outside GOPATH by separating repo information collection depending on the root path of the project. ## Why is it important? This lets users compile and package Beats if they have checked out the code to a non-GOPATH folder.
## What does this PR do? This PR adds support for building Beats outside GOPATH by separating repo information collection depending on the root path of the project. ## Why is it important? This lets users compile and package Beats if they have checked out the code to a non-GOPATH folder.
## What does this PR do? This PR adds support for building Beats outside GOPATH by separating repo information collection depending on the root path of the project. ## Why is it important? This lets users compile and package Beats if they have checked out the code to a non-GOPATH folder.
## What does this PR do? This PR adds support for building Beats outside GOPATH by separating repo information collection depending on the root path of the project. ## Why is it important? This lets users compile and package Beats if they have checked out the code to a non-GOPATH folder.
What does this PR do?
This PR adds support for building Beats outside GOPATH by separating repo information collection depending on the root path of the project.
Why is it important?
This lets users compile and package Beats if they have checked out the code to a non-GOPATH folder.
Checklist