Update version/version.go to match enterprise

Signed-off-by: Mark Anderson <manderson@hashicorp.com>
This commit is contained in:
Mark Anderson 2022-05-05 20:41:18 -07:00
parent 4364e440db
commit 83ccdcd66d
1 changed files with 10 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package version package version
import ( import (
"fmt"
"strings" "strings"
) )
@ -15,6 +16,9 @@ var (
// for tests to work. // for tests to work.
Version = "1.12.0" Version = "1.12.0"
// https://semver.org/#spec-item-10
VersionMetadata = ""
// A pre-release marker for the version. If this is "" (empty string) // A pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release // then it means that it is a final release. Otherwise, this is a pre-release
// such as "dev" (in development), "beta", "rc1", etc. // such as "dev" (in development), "beta", "rc1", etc.
@ -26,13 +30,14 @@ var (
func GetHumanVersion() string { func GetHumanVersion() string {
version := Version version := Version
release := VersionPrerelease release := VersionPrerelease
metadata := VersionMetadata
if release != "" { if release != "" {
suffix := "-" + release version += fmt.Sprintf("-%s", release)
if !strings.HasSuffix(version, suffix) { }
// if we tagged a prerelease version then the release is in the version already
version += suffix if metadata != "" {
} version += fmt.Sprintf("+%s", metadata)
} }
// Strip off any single quotes added by the git information. // Strip off any single quotes added by the git information.