Files
zitadel/cmd/build/info.go
Tim Möhlmann 6e90d4a927 fix(cache): use key versioning (#10657)
# Which Problems Are Solved

Cached object may have a different schema between Zitadel versions.

# How the Problems Are Solved

Use the curent build version in DB based cache connectors PostgreSQL and
Redis.

# Additional Changes

- Cleanup the ZitadelVersion field from the authz Instance
- Solve potential race condition on global variables in build package.

# Additional Context

- Closes https://github.com/zitadel/zitadel/issues/10648
- Obsoletes https://github.com/zitadel/zitadel/pull/10646
- Needs to be back-ported to v4 over
https://github.com/zitadel/zitadel/pull/10645

(cherry picked from commit f6f37d3a31)
2025-09-16 07:19:12 +02:00

47 lines
945 B
Go

package build
import (
"time"
"github.com/zitadel/logging"
)
// These variables are set via ldflags in the Makefile
var (
version = ""
commit = ""
date = ""
)
// dateTime is the parsed version of [date]
var dateTime time.Time
// init prevents race conditions when accessing dateTime and version.
func init() {
var err error
dateTime, err = time.Parse(time.RFC3339, date)
if err != nil {
logging.WithError(err).Warn("could not parse build date, using current time instead")
dateTime = time.Now()
}
if version == "" {
logging.Warn("no build version set, using timestamp as version")
version = date
}
}
// Version returns the current build version of Zitadel
func Version() string {
return version
}
// Commit returns the git commit hash of the current build of Zitadel
func Commit() string {
return commit
}
// Date returns the build date of the current build of Zitadel
func Date() time.Time {
return dateTime
}