Move to setting version info explicitly in linker flags
Some checks failed
/ golint (push) Failing after 12s

We don't have go built-in VCS information in a nix build because the git
repository isn't present. After struggling to build an overlay that
would provide it, I decided this path is easier of just injecting in the
data that we need.

Issue: #5
This commit is contained in:
Eli Ribble 2026-05-19 19:45:04 +00:00
parent 81826f853e
commit d4cbfb960e
No known key found for this signature in database
8 changed files with 119 additions and 79 deletions

View file

@ -322,7 +322,7 @@ type tegolaURLs struct {
}
func getRoot(ctx context.Context, r *http.Request, q resource.QueryParams) (*about, *nhttp.ErrorWithStatus) {
v := version.Get()
v := GetVersionInfo()
return &about{
Environment: config.Environment,
SentryDSN: config.SentryDSNFrontend,

View file

@ -11,7 +11,6 @@ import (
"source.gleipnir.technology/Gleipnir/nidus-sync/lint"
"source.gleipnir.technology/Gleipnir/nidus-sync/platform"
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/event"
"source.gleipnir.technology/Gleipnir/nidus-sync/version"
)
var connectionsSSE map[*ConnectionSSE]bool = make(map[*ConnectionSSE]bool, 0)
@ -41,7 +40,7 @@ type Status struct {
func (c *ConnectionSSE) SendEvent(w http.ResponseWriter, m platform.Event) error {
if m.Type == event.EventTypeShutdown {
v := version.Get()
v := GetVersionInfo()
return send(w, Status{
BuildTime: v.BuildTime,
IsModified: v.IsModified,
@ -121,7 +120,7 @@ func streamEvents(w http.ResponseWriter, r *http.Request, u platform.User) {
log.Debug().Int32("org", u.Organization.ID).Int("user", u.ID).Str("id", uid.String()).Msg("connected SSE client")
// Send an initial connected event
v := version.Get()
v := GetVersionInfo()
status := Status{
BuildTime: v.BuildTime,
IsModified: v.IsModified,

16
api/version.go Normal file
View file

@ -0,0 +1,16 @@
package api
import (
"source.gleipnir.technology/Gleipnir/nidus-sync/version"
)
var (
versionInfo version.VersionInfo
)
func GetVersionInfo() version.VersionInfo {
return versionInfo
}
func SetVersionInfo(v version.VersionInfo) {
versionInfo = v
}