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

fix: embed troubleshoot version string from module dependency #1371

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

banjoh
Copy link
Member

@banjoh banjoh commented Oct 16, 2023

Description, Motivation and Context

If troubleshoot is used as a dependency (part of your go.mod), the version information of the release would be missing at runtime i.e empty string when version.Version() is called. This is because the version string is injected to binaries at build time using linker flags (LD) passed to the compiler. Built binaries such as support-bundle and preflight will contain a version string, but projects such as KOTS that import troubleshoot as a module will not have a version string set.

This PR utilises information fetched from runtime.BuildInfo at runtime to extract the version info from the troubleshoot module in the go.mod file.

Fixes: #1372

Checklist

  • New and existing tests pass locally with introduced changes.
  • Tests for the changes have been added (for bug fixes / features)
  • The commit message(s) are informative and highlight any breaking changes
  • Any documentation required has been added/updated. For changes to https://troubleshoot.sh/ create a PR here

Does this PR introduce a breaking change?

  • Yes
  • No

@banjoh banjoh requested a review from a team as a code owner October 16, 2023 11:56
@banjoh banjoh force-pushed the em/get-version-from-runtime branch from 7ce8d62 to b221232 Compare October 16, 2023 12:21
If troubleshoot is used as a dependency in go.mod, the version
information of the release would be missing at runtime. This is
because the version string is injected to binaries at build time
using linker flags (LD) passed to the compiler (check Makefile)
@banjoh banjoh force-pushed the em/get-version-from-runtime branch from b221232 to 30374f3 Compare October 16, 2023 12:23
@banjoh banjoh merged commit 312e467 into replicatedhq:main Oct 16, 2023
23 checks passed
@banjoh banjoh deleted the em/get-version-from-runtime branch October 16, 2023 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Version information missing from troubleshoot if the project is used as a dependency
2 participants