Browse Source

lib/api: Returns tags in version as list (#7190)

Jakob Borg 4 years ago
parent
commit
ec5a5d5218
2 changed files with 11 additions and 6 deletions
  1. 1 1
      lib/api/api.go
  2. 10 5
      lib/build/build.go

+ 1 - 1
lib/api/api.go

@@ -643,7 +643,7 @@ func (s *service) getSystemVersion(w http.ResponseWriter, r *http.Request) {
 		"isCandidate": build.IsCandidate,
 		"isRelease":   build.IsRelease,
 		"date":        build.Date,
-		"tags":        build.Tags,
+		"tags":        build.TagsList(),
 		"stamp":       build.Stamp,
 		"user":        build.User,
 	})

+ 10 - 5
lib/build/build.go

@@ -87,6 +87,13 @@ func LongVersionFor(program string) string {
 	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)
 
+	if tags := TagsList(); len(tags) > 0 {
+		v = fmt.Sprintf("%s [%s]", v, strings.Join(tags, ", "))
+	}
+	return v
+}
+
+func TagsList() []string {
 	tags := strings.Split(Tags, ",")
 	if len(tags) == 1 && tags[0] == "" {
 		tags = tags[:0]
@@ -96,9 +103,7 @@ func LongVersionFor(program string) string {
 			tags = append(tags, strings.ToLower(envVar))
 		}
 	}
-	if len(tags) > 0 {
-		sort.Strings(tags)
-		v = fmt.Sprintf("%s [%s]", v, strings.Join(tags, ", "))
-	}
-	return v
+
+	sort.Strings(tags)
+	return tags
 }