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

minor: built k0sctl via 'go install', 'k0sctl version' reports 0.0.0 #479

Closed
draeath opened this issue May 15, 2023 · 1 comment · Fixed by #508
Closed

minor: built k0sctl via 'go install', 'k0sctl version' reports 0.0.0 #479

draeath opened this issue May 15, 2023 · 1 comment · Fixed by #508
Labels
enhancement New feature or request

Comments

@draeath
Copy link

draeath commented May 15, 2023

Minor issue:

If you build k0sctl as instructed (tested @latest and @v0.15.0) your binary believes it's version number to be 0.0.0:

draeath@redacted:~> k0sctl version
version: 0.0.0
commit: HEAD

I don't know how one would solve this problem correctly, but an old google drive go client had an additional command you had to run to 'add' the version information to the built binary. Might be worth looking into. Here's the PR where the author implemented that for their project.

@kke kke added the enhancement New feature or request label May 15, 2023
@kke
Copy link
Contributor

kke commented May 15, 2023

It should be possible to figure out the absolute path of the source file with something like:

import (
	"runtime"
)

func main() {
	_, filename, _, ok := runtime.Caller(0)
}

I think that would be something like $GOPATH/foofoo/k0sctl@v0.15.0 if you installed via @v0.15.0 and maybe something like @v0.15.0-0.202312312123-3233443134413341134 if via @latest.

Maybe k0sctl could resort to doing that in case the version number buildflag was not given.

This would require changing any usages of version.Version to version.GetVersion() which would be something like:

if Version != "" {
  return Version
} else {
  return versionFromPath()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants