Skip to content

Commit 9811830

Browse files
authored
Re-add version code to cmd/builder (open-telemetry#11208)
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.-->
1 parent 0851867 commit 9811830

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: bug_fix
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: cmd/builder
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: re-adds function to properly set and view version number of OpenTelemetry Collector Builder (ocb) binaries
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [11208]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

cmd/builder/internal/version.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ var (
1616

1717
func init() {
1818
// the second returned value is a boolean, which is true if the binaries are built with module support.
19-
info, _ := debug.ReadBuildInfo()
20-
version = info.Main.Version
19+
if version == "" {
20+
info, _ := debug.ReadBuildInfo()
21+
version = info.Main.Version
22+
}
2123
}
2224

2325
func versionCommand() *cobra.Command {

0 commit comments

Comments
 (0)