Skip to content
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

Merged
merged 4 commits into from
Feb 20, 2020
Merged

Conversation

kvch
Copy link
Contributor

@kvch kvch commented Feb 14, 2020

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

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made the corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works

@kvch kvch added [zube]: In Review Team:Services (Deprecated) Label for the former Integrations-Services team labels Feb 14, 2020
@kvch kvch requested a review from andrewkroh February 14, 2020 13:40
@kvch
Copy link
Contributor Author

kvch commented Feb 14, 2020

@andrewkroh Could you please take a look at this PR?

@kvch kvch mentioned this pull request Feb 14, 2020
18 tasks
Copy link
Member

@andrewkroh andrewkroh left a 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:

  1. Traverse upward looking for the projects go.mod file. This is the RootDir.
  2. Get the SubDir value by using filepath.Rel(RootDir, CWD()).
  3. Read the go.mod file to get the RootImportPath.
  4. Get the ImportPath by filepath.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).

dev-tools/mage/settings.go Outdated Show resolved Hide resolved
dev-tools/mage/settings.go Outdated Show resolved Hide resolved
dev-tools/mage/settings.go Outdated Show resolved Hide resolved
dev-tools/mage/settings.go Outdated Show resolved Hide resolved
dev-tools/mage/settings.go Outdated Show resolved Hide resolved
dev-tools/mage/settings.go Outdated Show resolved Hide resolved
dev-tools/mage/settings.go Outdated Show resolved Hide resolved
@kvch kvch force-pushed the build-beats-outside-gopath branch from d7c3c24 to 26f5c96 Compare February 19, 2020 10:52
@kvch kvch mentioned this pull request Feb 19, 2020
5 tasks
Copy link
Member

@andrewkroh andrewkroh left a 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.

dev-tools/mage/settings.go Outdated Show resolved Hide resolved
dev-tools/mage/settings.go Outdated Show resolved Hide resolved
@kvch kvch merged commit 6e1b802 into elastic:go-modules Feb 20, 2020
kvch added a commit that referenced this pull request Feb 26, 2020
## 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.
kvch added a commit that referenced this pull request Feb 27, 2020
## 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.
kvch added a commit that referenced this pull request Feb 28, 2020
## 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.
kvch added a commit that referenced this pull request Mar 2, 2020
## 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.
kvch added a commit that referenced this pull request Mar 3, 2020
## 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.
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
## 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Services (Deprecated) Label for the former Integrations-Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants