-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Re-add version code to cmd/builder #11208
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11208 +/- ##
=======================================
Coverage ? 91.42%
=======================================
Files ? 424
Lines ? 20188
Branches ? 0
=======================================
Hits ? 18456
Misses ? 1348
Partials ? 384 ☔ View full report in Codecov by Sentry. |
@jackgopack4 who is writing the version though? Am I missing something here? |
after this code was removed, passing the build flag for version does not properly set the version when someone wants to run as I understand it, this function is called by the cobra cli interface when someone runs ocb on the command line. |
cmd/builder/internal/version.go
Outdated
version, err = fn(debug.ReadBuildInfo) | ||
if err != nil { | ||
return err | ||
} |
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.
Is the difference just that the debug.ReadBuildInfo()
is executed in the Run? If that is the case, can we do just that?
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.
no, that's not enough to make a difference. running CGO_ENABLED=0 go build -trimpath -ldflags='-s -w -X go.opentelemetry.io/collector/cmd/builder/internal.version=v0.110.0'
with this code passes a version number but just moving the debug.ReadBuildInfo into the RunE command does not fix it.
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.
need to have a check to see if version is still blank; the init function is overwriting version with debug.ReadBuildInfo
otherwise
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.
simply adding an if version == ""
check to the init()
function originally on line 17 would also solve it, it seems
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.
ok @bogdandrutu I made the PR much smaller and still fixed the issue
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.
running CGO_ENABLED=0 go build -trimpath -ldflags='-s -w -X go.opentelemetry.io/collector/cmd/builder/internal.version=v0.110.0'
Where do we do this?
Revert "[chore] delete code to set a version and date, as it it not used (open-telemetry#10715)" Remove date string but re-add functions that check for version number This (mostly) reverts commit b53f57d. <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This re-enables the functionality to set a version number for ocb binary (cmd/builder). It was erroneously removed. It also adds unit tests for this functionality, as a warning is given on CI with no code coverage. <!-- Issue number if applicable --> #### Link to tracking issue Relates to open-telemetry/opentelemetry-collector-releases#664. Closes open-telemetry#11220 along with open-telemetry/opentelemetry-collector-releases#665 <!--Describe what testing was performed and which tests were added.--> #### Testing ran build and release cycles inside personal fork repositories (jackgopack4/opentelemetry-collector and jackgopack4/opentelemetry-collector-releases) <!--Describe the documentation added.--> #### Documentation .chloggen file <!--Please delete paragraphs that you did not use before submitting.-->
Revert "[chore] delete code to set a version and date, as it it not used (#10715)"
Remove date string but re-add functions that check for version number
This (mostly) reverts commit b53f57d.
Description
This re-enables the functionality to set a version number for ocb binary (cmd/builder). It was erroneously removed. It also adds unit tests for this functionality, as a warning is given on CI with no code coverage.
Link to tracking issue
Relates to open-telemetry/opentelemetry-collector-releases#664.
Closes #11220 along with open-telemetry/opentelemetry-collector-releases#665
Testing
ran build and release cycles inside personal fork repositories (jackgopack4/opentelemetry-collector and jackgopack4/opentelemetry-collector-releases)
Documentation
.chloggen file