Skip to content

Commit 256500d

Browse files
authored
Make version getRevision public (#563)
Make version package `getRevision()` a public function to allow implementing `NewCollector()` outside of the version package easier. Signed-off-by: SuperQ <[email protected]>
1 parent 0949959 commit 256500d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

version/info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func NewCollector(program string) prometheus.Collector {
4848
),
4949
ConstLabels: prometheus.Labels{
5050
"version": Version,
51-
"revision": getRevision(),
51+
"revision": GetRevision(),
5252
"branch": Branch,
5353
"goversion": GoVersion,
5454
"goos": GoOS,
@@ -75,7 +75,7 @@ func Print(program string) string {
7575
m := map[string]string{
7676
"program": program,
7777
"version": Version,
78-
"revision": getRevision(),
78+
"revision": GetRevision(),
7979
"branch": Branch,
8080
"buildUser": BuildUser,
8181
"buildDate": BuildDate,
@@ -94,7 +94,7 @@ func Print(program string) string {
9494

9595
// Info returns version, branch and revision information.
9696
func Info() string {
97-
return fmt.Sprintf("(version=%s, branch=%s, revision=%s)", Version, Branch, getRevision())
97+
return fmt.Sprintf("(version=%s, branch=%s, revision=%s)", Version, Branch, GetRevision())
9898
}
9999

100100
// BuildContext returns goVersion, platform, buildUser and buildDate information.

version/info_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package version
1818

19-
func getRevision() string {
19+
func GetRevision() string {
2020
return Revision
2121
}
2222

version/info_go118.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import "runtime/debug"
2121
var computedRevision string
2222
var computedTags string
2323

24-
func getRevision() string {
24+
func GetRevision() string {
2525
if Revision != "" {
2626
return Revision
2727
}

0 commit comments

Comments
 (0)