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

Add buildinfo flag #6286

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

alexbozhenko
Copy link
Contributor

@alexbozhenko alexbozhenko commented Dec 19, 2024

This information is already available through
go version -m path/to/binary
But it will be more convenient to have it available without go installed.

Test plan:

go build .
./nats-server -buildinfo
./nats-server buildinfo
./nats-server --buildinfo

All return:

go      go1.22.10
path    github.com/nats-io/nats-server/v2
mod     github.com/nats-io/nats-server/v2       (devel)
dep     github.com/klauspost/compress   v1.17.11        h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
dep     github.com/minio/highwayhash    v1.0.3  h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q=
dep     github.com/nats-io/jwt/v2       v2.7.3  h1:6bNPK+FXgBeAqdj4cYQ0F8ViHRbi7woQLq4W29nUAzE=
dep     github.com/nats-io/nkeys        v0.4.9  h1:qe9Faq2Gxwi6RZnZMXfmGMZkg3afLLOtrU+gDZJ35b0=
dep     github.com/nats-io/nuid v1.0.1  h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
dep     go.uber.org/automaxprocs        v1.6.0  h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
dep     golang.org/x/crypto     v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
dep     golang.org/x/sys        v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
dep     golang.org/x/time       v0.8.0  h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
build   -buildmode=exe
build   -compiler=gc
build   CGO_ENABLED=1
build   CGO_CFLAGS=
build   CGO_CPPFLAGS=
build   CGO_CXXFLAGS=
build   CGO_LDFLAGS=
build   GOARCH=amd64
build   GOOS=linux
build   GOAMD64=v1
build   vcs=git
build   vcs.revision=b5fe72d6c3213abf5b3822cc5141d057d6d90875
build   vcs.time=2024-12-19T23:31:08Z
build   vcs.modified=false

Signed-off-by: Alex Bozhenko alex@synadia.com

@alexbozhenko alexbozhenko requested a review from a team as a code owner December 19, 2024 23:29
Signed-off-by: Alex Bozhenko <alexbozhenko@gmail.com>
func PrintBuildinfoAndExit() {
bi, ok := debug.ReadBuildInfo()
if !ok || bi == nil {
//nolint:forbidigo
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neilalexander ok to ignore like this here?

Copy link
Member

@bruth bruth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it is a pretty niche desire for wanting to read the build info if you do not have Go installed. That said, I suppose there is no harm in adding a CLI option as long as it does not introducing breaking changes.

@@ -5676,10 +5676,11 @@ func getDefaultAuthTimeout(tls *tls.Config, tlsTimeout float64) float64 {
// specific flags. On success, an options structure is returned configured
// based on the selected flags and/or configuration file.
// The command line options take precedence to the ones in the configuration file.
func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp, printTLSHelp func()) (*Options, error) {
func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp, printBuildinfo, printTLSHelp func()) (*Options, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Embedding the NATS server is quite common and since this is a public function, this is a breaking change we don't want to do.

// ProcessCommandLineArgs takes the command line arguments
// validating and setting flags for handling in case any
// sub command was present.
func ProcessCommandLineArgs(cmd *flag.FlagSet) (showVersion bool, showHelp bool, err error) {
func ProcessCommandLineArgs(cmd *flag.FlagSet) (showVersion bool, showHelp bool, showBuildinfo bool, err error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, this is a breaking change.

@alexbozhenko alexbozhenko marked this pull request as draft December 20, 2024 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants