Skip to content

Commit

Permalink
version and revision included in config response
Browse files Browse the repository at this point in the history
  • Loading branch information
anubhavmishra committed Aug 17, 2023
1 parent 98db3a7 commit a4e1e10
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
28 changes: 28 additions & 0 deletions internal/version/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
package version

import (
"runtime/debug"
)

const Version = "0.2.0"

// GetVersion returns
// the version number
func GetVersion() string {
return Version
}

// GetShortRevision returns a short
// commit or checkout revision
// from build information
func GetShortRevision() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
var shortRevision string
if len(setting.Value) > 7 {
shortRevision = setting.Value[:7]
}
return shortRevision
}
}
}
return ""
}
5 changes: 5 additions & 0 deletions web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/hashicorp-forge/hermes/internal/config"
"github.com/hashicorp-forge/hermes/internal/pkg/featureflags"
"github.com/hashicorp-forge/hermes/internal/version"
"github.com/hashicorp-forge/hermes/pkg/algolia"
"github.com/hashicorp/go-hclog"
)
Expand Down Expand Up @@ -64,6 +65,8 @@ type ConfigResponse struct {
ShortLinkBaseURL string `json:"short_link_base_url"`
SkipGoogleAuth bool `json:"skip_google_auth"`
SupportLinkURL string `json:"support_link_url"`
ShortRevision string `json:"short_revision"`
Version string `json:"version"`
}

// ConfigHandler returns runtime configuration for the Hermes frontend.
Expand Down Expand Up @@ -118,6 +121,8 @@ func ConfigHandler(
ShortLinkBaseURL: shortLinkBaseURL,
SkipGoogleAuth: skipGoogleAuth,
SupportLinkURL: cfg.SupportLinkURL,
ShortRevision: version.GetShortRevision(),
Version: version.GetVersion(),
}

w.Header().Set("Content-Type", "application/json")
Expand Down

0 comments on commit a4e1e10

Please sign in to comment.