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

Report correct version #66

Closed
radeksimko opened this issue Jun 30, 2022 · 5 comments · Fixed by #97
Closed

Report correct version #66

radeksimko opened this issue Jun 30, 2022 · 5 comments · Fixed by #97
Assignees
Labels
bug Something isn't working
Milestone

Comments

@radeksimko
Copy link
Member

Currently we report old version in both the CLI and User-Agent as it's hard-coded here:

package version
const version = "0.1.0"
// ModuleVersion returns the current version of the github.com/hashicorp/hc-install Go module.
// This is a function to allow for future possible enhancement using debug.BuildInfo.
func ModuleVersion() string {
return version
}

We can explore https://pkg.go.dev/debug/buildinfo or ldflags for the CLI.

@radeksimko radeksimko added the bug Something isn't working label Jun 30, 2022
@kmoe
Copy link
Member

kmoe commented Jul 5, 2022

Thanks for this. In the meantime we could use a similar approach to tfexec: the version.go file is modified during release (https://github.com/hashicorp/terraform-exec/blob/main/scripts/release/release.sh#L60).

@radeksimko
Copy link
Member Author

For the debug/buildinfo approach - it looks like this may work for a library or a binary which gets installed via go install. So if we decide this is the only way people should install the hc-install CLI, then we can leverage it! 😃

If we decide to distribute our own binaries then we'd still have to use the approach you mentioned, or ldflags.

I personally like the idea of dependency/wrapper-free build process, so I'd be leaning more towards the go install & debug/buildinfo approach, especially since hc-install is primarily a library anyway.

Here's a full context helpfully explained by Martin in another PR as he ran into the exact same problem I did

I was anticipating that golang/go#37475 would cause the Go toolchain to make that information available in a different way after Go 1.18. However, in subsequent testing I learned that it currently stamps only the commit ID and not any module version information for the main package. golang/go#50603 is an open request tracking the behavior I had hoped for, but it remains unimplemented at the time I'm writing this and there are some doubts about what exactly it would do if it were implemented.

@radeksimko
Copy link
Member Author

btw. we don't even need the vcs revision which was added in Go 1.18.

We can just use the Module.Version which is available since Go 1.12 apparently.

@kmoe
Copy link
Member

kmoe commented Jul 11, 2022

Same issue for terraform-exec (opened while we were still building tfinstall binaries): hashicorp/terraform-exec#22

Another problem with debug.BuildInfo is golang/go#33976.

@radeksimko
Copy link
Member Author

Another problem with debug.BuildInfo is golang/go#33976.

That seems annoying. I missed that one entirely - good catch!

@tgross also mentioned that Nomad would welcome if installing hc-install CLI doesn't require Go, so it seems we should build binaries anyway. We also discussed the question of integrity checks for hc-install itself - these could be provided by go install, or the underlying distribution channel, specifically the OS packaging ecosystem (such as APT).

In other words, we should make sure that these binaries we build are also distributed as Linux packages and via our Homebrew tap too, so that users don't end up re-implementing the integrity checking in shell or avoid checking altogether.

@radeksimko radeksimko added this to the v1.0.0 milestone Dec 1, 2022
@radeksimko radeksimko self-assigned this Jan 17, 2023
This was referenced Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants