Skip to content

Commit

Permalink
Make version getRevision public (#563)
Browse files Browse the repository at this point in the history
Make version package `getRevision()` a public function to allow
implementing `NewCollector()` outside of the version package easier.

Signed-off-by: SuperQ <[email protected]>
  • Loading branch information
SuperQ authored Jan 11, 2024
1 parent 0949959 commit 256500d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions version/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewCollector(program string) prometheus.Collector {
),
ConstLabels: prometheus.Labels{
"version": Version,
"revision": getRevision(),
"revision": GetRevision(),
"branch": Branch,
"goversion": GoVersion,
"goos": GoOS,
Expand All @@ -75,7 +75,7 @@ func Print(program string) string {
m := map[string]string{
"program": program,
"version": Version,
"revision": getRevision(),
"revision": GetRevision(),
"branch": Branch,
"buildUser": BuildUser,
"buildDate": BuildDate,
Expand All @@ -94,7 +94,7 @@ func Print(program string) string {

// Info returns version, branch and revision information.
func Info() string {
return fmt.Sprintf("(version=%s, branch=%s, revision=%s)", Version, Branch, getRevision())
return fmt.Sprintf("(version=%s, branch=%s, revision=%s)", Version, Branch, GetRevision())
}

// BuildContext returns goVersion, platform, buildUser and buildDate information.
Expand Down
2 changes: 1 addition & 1 deletion version/info_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package version

func getRevision() string {
func GetRevision() string {
return Revision
}

Expand Down
2 changes: 1 addition & 1 deletion version/info_go118.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "runtime/debug"
var computedRevision string
var computedTags string

func getRevision() string {
func GetRevision() string {
if Revision != "" {
return Revision
}
Expand Down

0 comments on commit 256500d

Please sign in to comment.