-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[builder] Add --go-build-flags cli flag #12589
base: main
Are you sure you want to change the base?
Conversation
This PR adds the `--go-build-flags` cli flag which will allow the user to pass additional flags for the `go build` command used to compile the collector.
@@ -113,6 +113,7 @@ var replaceModules = []string{ | |||
func newTestConfig(tb testing.TB) *Config { | |||
cfg, err := NewDefaultConfig() | |||
require.NoError(tb, err) | |||
cfg.Distribution.Name = "test_distribution" |
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.
Currently, the integration tests are running with a blank name field, which means the args end up being build -o 'ldflags=-s -w' ...
. So it's building a binary with the name 'ldflags=-s -w' instead of applying the ldflags. It didn't break any tests but is probably not intentional.
I had removed these because I didn't understand what they did at first, and forgot to add them back once I realized why they were there.
Codecov ReportAttention: Patch coverage is
❌ Your patch check has failed because the patch coverage (92.30%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #12589 +/- ##
==========================================
+ Coverage 92.18% 92.21% +0.02%
==========================================
Files 469 469
Lines 25394 25408 +14
==========================================
+ Hits 23409 23429 +20
+ Misses 1574 1570 -4
+ Partials 411 409 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7525fca
to
9d8ea38
Compare
gcflags := "" | ||
executableName := c.Distribution.Name | ||
if runtime.GOOS == "windows" { | ||
executableName += ".exe" |
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.
Codecov seems to think these aren't covered, but I think they are covered by TestGetGoBuildArgs
.
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.
the reason you're getting this warning is because the body of the if statement isn't being run in codecov because it's not running in windows. I think this finding should probably be ignored because the test TestGetGoBuildArgs explicitly tests correctly on windows systems
gcflags := "" | ||
executableName := c.Distribution.Name | ||
if runtime.GOOS == "windows" { | ||
executableName += ".exe" |
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.
the reason you're getting this warning is because the body of the if statement isn't being run in codecov because it's not running in windows. I think this finding should probably be ignored because the test TestGetGoBuildArgs explicitly tests correctly on windows systems
Description
This PR adds the
--go-build-flags
cli flag which will allow the user to pass additional flags for thego build
command used to compile the collector.While doing the refactor, I also made it so that the default binary name now adds the
.exe
extension when building for Windows.Link to tracking issue
Fixes #12588
Fixes #12591
Testing
New unit tests were added to verify the build command args based on the config. A new CompileAndGenerate test case was added as well.
Documentation
A section has been added to the README.