Skip to content

Commit

Permalink
Rename GetBuildInfo to GetVersionInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
kuskoman committed Apr 13, 2023
1 parent 131e6ff commit 840d4fa
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func main() {
logstashUrl := config.LogstashUrl

log.Println("Application starting...")
versionInfo := config.GetBuildInfo()
versionInfo := config.GetVersionInfo()
log.Println(versionInfo.String())

collectorManager := collectors.NewCollectorManager(logstashUrl)
Expand Down
4 changes: 2 additions & 2 deletions config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ var (
BuildDate = "unknown"
)

// GetBuildInfo returns a VersionInfo struct with the current build information.
func GetBuildInfo() *VersionInfo {
// GetVersionInfo returns a VersionInfo struct with the current build information.
func GetVersionInfo() *VersionInfo {
return &VersionInfo{
Version: Version,
GitCommit: GitCommit,
Expand Down
2 changes: 1 addition & 1 deletion config/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func TestGetBuildInfo(t *testing.T) {
versionInfo := GetBuildInfo()
versionInfo := GetVersionInfo()

if versionInfo.Version == "" {
t.Error("Expected Version to be set")
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewAppServer(host, port string) *http.Server {
http.Redirect(w, r, "/metrics", http.StatusMovedPermanently)
})
mux.HandleFunc("/healthcheck", getHealthCheck(config.LogstashUrl))
mux.HandleFunc("/version", getVersionInfoHandler(config.GetBuildInfo()))
mux.HandleFunc("/version", getVersionInfoHandler(config.GetVersionInfo()))

listenUrl := fmt.Sprintf("%s:%s", host, port)

Expand Down
4 changes: 2 additions & 2 deletions server/versioninfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestHandleVersionInfo(t *testing.T) {
t.Parallel()
t.Run("normal case", func(t *testing.T) {
t.Parallel()
ts := httptest.NewServer(http.HandlerFunc(getVersionInfoHandler(config.GetBuildInfo())))
ts := httptest.NewServer(http.HandlerFunc(getVersionInfoHandler(config.GetVersionInfo())))
defer ts.Close()

resp, err := http.Get(ts.URL)
Expand All @@ -54,7 +54,7 @@ func TestHandleVersionInfo(t *testing.T) {
t.Fatalf("failed to decode JSON: %v", err)
}

expectedVersionInfo := config.GetBuildInfo()
expectedVersionInfo := config.GetVersionInfo()
if versionInfo != *expectedVersionInfo {
t.Errorf("expected version info: %+v, but got: %+v", *expectedVersionInfo, versionInfo)
}
Expand Down

0 comments on commit 840d4fa

Please sign in to comment.