Print the revision, if known, separately from the version.

Also, indicate whether the build is dynamic or not.
This commit is contained in:
Jeff Mitchell
2016-11-27 19:28:35 -05:00
parent 2b5fb353f3
commit c91a7c51a2
4 changed files with 23 additions and 9 deletions

View File

@@ -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

View File

@@ -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
}

7
version/cgo.go Normal file
View File

@@ -0,0 +1,7 @@
// +build cgo
package version
func init() {
CgoEnabled = true
}

View File

@@ -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()