diff --git a/lib/build/build.go b/lib/build/build.go index 833f74b78..b83967285 100644 --- a/lib/build/build.go +++ b/lib/build/build.go @@ -9,6 +9,7 @@ package build import ( "fmt" "log" + "os" "regexp" "runtime" "strconv" @@ -37,6 +38,14 @@ var ( Tags []string allowedVersionExp = regexp.MustCompile(`^v\d+\.\d+\.\d+(-[a-z0-9]+)*(\.\d+)*(\+\d+-g[0-9a-f]+)?(-[^\s]+)?$`) + + envTags = []string{ + "STGUIASSETS", + "STHASHING", + "STNORESTART", + "STNOUPGRADE", + "USE_BADGER", + } ) func init() { @@ -79,6 +88,11 @@ func LongVersionFor(program string) string { // This string and date format is essentially part of our external API. Never change it. date := Date.UTC().Format("2006-01-02 15:04:05 MST") v := fmt.Sprintf(`%s %s "%s" (%s %s-%s) %s@%s %s`, program, Version, Codename, runtime.Version(), runtime.GOOS, runtime.GOARCH, User, Host, date) + for _, envVar := range envTags { + if os.Getenv(envVar) != "" { + Tags = append(Tags, strings.ToLower(envVar)) + } + } if len(Tags) > 0 { v = fmt.Sprintf("%s [%s]", v, strings.Join(Tags, ", ")) }