-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Correct ldflags to set version, commit and build host (during offline builds)? #7471
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
Comments
Thanks for bringing that to our attention! Most of our code now resides under "v1" and the code pre-1.0 mostly just links to that. You're absolutely correct that it seems this document wasn't updated with the move, and we'll need to fix that. |
Thanks @anderseknert ! Please note that it is not only the docs. Seems like overwriting the values does not work sometimes, too. Not sure if it works when offline, i.e. no information can be fetched. Or why this is. |
That doesn't sound good at all! You're saying that repeating the same build command with identical build flags sometimes produces a binary with this information not included? Or does that only happen under some specific circumstances? It could be a bug either way, but being able to reproduce this would help a lot with both categorization, prioritization and fixing it :) |
Sorry Anders, my initial description was a little overwhelming it seems. But comparing the result of a build command when using the While in a offline build on the openSUSE build infrastructure the version is correctly set to whatever is handed over in the ldflags. I am not sure if there are other differences (between the build environments that I used) that cause this, the missing network connectivity is only the first thing that came to my mind. I will try to find some time to redo the builds to see whether I messed up somewhere. |
Sorry for the late response! Did you get any further with this? |
Hi Anders, sorry, I did not yet have time to redo the manual builds. |
Thanks Johannes! Should we close this for the time being? |
Short description
I am trying to package OPA for openSUSE. It seems that the
ldflags
that I found in the documentation are not working.https://github.com/open-policy-agent/opa/blob/main/docs/content/extensions.md?plain=1#L385
I noticed that the variables seem to be related to v1 somehow:
https://github.com/open-policy-agent/opa/blob/v1.3.0/version/version.go#L24
Indeed, using
github.com/open-policy-agent/opa/v1/version.Hostname=example.org
(with a v1) allows setting the build hostname.I have packaged dozens of go packages, but am pretty inexperienced with golang and its internals. So it might well be an error on my side.
Kind Regards,
Johannes
Steps To Reproduce
opa version
/v1
opa version
againDuring offline builds, e.g. in the openSUSE build environment, the output is even funnier when not using
v1
:Here neither commit nor timestamp nor build hostname are being respected.
With
v1
the output is kind of sensible:The text was updated successfully, but these errors were encountered: