From c91a7c51a21fea3da1007a95873634734556743b Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 27 Nov 2016 19:28:35 -0500 Subject: [PATCH] Print the revision, if known, separately from the version. Also, indicate whether the build is dynamic or not. --- command/server.go | 11 ++++++++--- command/version.go | 2 +- version/cgo.go | 7 +++++++ version/version.go | 12 +++++++----- 4 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 version/cgo.go diff --git a/command/server.go b/command/server.go index dbb7220ad3..50f32ead6c 100644 --- a/command/server.go +++ b/command/server.go @@ -466,10 +466,15 @@ func (c *ServerCommand) Run(args []string) int { infoKeys = append(infoKeys, "version") verInfo := version.GetVersion() - info["version"] = verInfo.FullVersionNumber() + info["version"] = verInfo.FullVersionNumber(false) if verInfo.Revision != "" { - info["version_sha"] = strings.Trim(verInfo.Revision, "'") - infoKeys = append(infoKeys, "version_sha") + info["version sha"] = strings.Trim(verInfo.Revision, "'") + infoKeys = append(infoKeys, "version sha") + } + infoKeys = append(infoKeys, "cgo") + info["cgo"] = "disabled" + if version.CgoEnabled { + info["cgo"] = "enabled" } // Server configuration output diff --git a/command/version.go b/command/version.go index 4c98b9a1bc..fd0ac49b9c 100644 --- a/command/version.go +++ b/command/version.go @@ -16,7 +16,7 @@ func (c *VersionCommand) Help() string { } func (c *VersionCommand) Run(_ []string) int { - c.Ui.Output(c.VersionInfo.FullVersionNumber()) + c.Ui.Output(c.VersionInfo.FullVersionNumber(true)) return 0 } diff --git a/version/cgo.go b/version/cgo.go new file mode 100644 index 0000000000..2ed493a1fb --- /dev/null +++ b/version/cgo.go @@ -0,0 +1,7 @@ +// +build cgo + +package version + +func init() { + CgoEnabled = true +} diff --git a/version/version.go b/version/version.go index 705039ffc6..b7985ae0f5 100644 --- a/version/version.go +++ b/version/version.go @@ -10,6 +10,9 @@ var ( GitCommit string GitDescribe string + // Whether cgo is enabled or not; set at build time + CgoEnabled bool + Version = "unknown" VersionPrerelease = "unknown" ) @@ -52,7 +55,7 @@ func (c *VersionInfo) VersionNumber() string { return version } -func (c *VersionInfo) FullVersionNumber() string { +func (c *VersionInfo) FullVersionNumber(rev bool) string { var versionString bytes.Buffer if Version == "unknown" && VersionPrerelease == "unknown" { @@ -62,10 +65,9 @@ func (c *VersionInfo) FullVersionNumber() string { fmt.Fprintf(&versionString, "Vault v%s", c.Version) if c.VersionPrerelease != "" { fmt.Fprintf(&versionString, "-%s", c.VersionPrerelease) - - if c.Revision != "" { - fmt.Fprintf(&versionString, " (%s)", c.Revision) - } + } + if rev && c.Revision != "" { + fmt.Fprintf(&versionString, " (%s)", c.Revision) } return versionString.String()