Skip to content

Commit

Permalink
Re-add version code to cmd/builder (#11208)
Browse files Browse the repository at this point in the history
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.

<!--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 #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.-->
  • Loading branch information
jackgopack4 authored Sep 24, 2024
1 parent 0851867 commit 9811830
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .chloggen/jackgopack4-re-add-ocb-version-number.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: cmd/builder

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: re-adds function to properly set and view version number of OpenTelemetry Collector Builder (ocb) binaries

# One or more tracking issues or pull requests related to the change
issues: [11208]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
6 changes: 4 additions & 2 deletions cmd/builder/internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ var (

func init() {
// the second returned value is a boolean, which is true if the binaries are built with module support.
info, _ := debug.ReadBuildInfo()
version = info.Main.Version
if version == "" {
info, _ := debug.ReadBuildInfo()
version = info.Main.Version
}
}

func versionCommand() *cobra.Command {
Expand Down

0 comments on commit 9811830

Please sign in to comment.