mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-10 02:16:59 +00:00
fix(config): set correct defaults for resolving version
Co-authored-by: sindrerh2 <sindre.rodseth.hansen@nav.no>
This commit is contained in:
@@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"time"
|
||||
|
||||
@@ -201,21 +202,34 @@ func resolveVersion() {
|
||||
return
|
||||
}
|
||||
|
||||
var rev string
|
||||
var last time.Time
|
||||
commit := "unknown"
|
||||
commitDate := time.Now()
|
||||
uncommittedChanges := true
|
||||
|
||||
for _, kv := range info.Settings {
|
||||
switch kv.Key {
|
||||
case "vcs.revision":
|
||||
rev = kv.Value
|
||||
commit = kv.Value
|
||||
case "vcs.time":
|
||||
last, _ = time.Parse(time.RFC3339, kv.Value)
|
||||
commitDate, _ = time.Parse(time.RFC3339, kv.Value)
|
||||
case "vcs.modified":
|
||||
if kv.Value == "true" {
|
||||
uncommittedChanges = true
|
||||
} else if kv.Value == "false" {
|
||||
uncommittedChanges = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(rev) > 7 {
|
||||
rev = rev[:7]
|
||||
if len(commit) > 7 {
|
||||
commit = commit[:7]
|
||||
}
|
||||
|
||||
viper.Set("version", fmt.Sprintf("%s-%s", last.Format("2006-01-02-150405"), rev))
|
||||
version := fmt.Sprintf("%s-%s", commitDate.Format("2006-01-02-150405"), commit)
|
||||
if uncommittedChanges {
|
||||
version += "-dirty"
|
||||
}
|
||||
|
||||
viper.Set("version", version)
|
||||
logger.Infof("config: starting wonderwall version %q built with %q", version, runtime.Version())
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/extra/redisotel/v9"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/nais/wonderwall/pkg/config"
|
||||
@@ -38,15 +37,15 @@ func NewStore(cfg *config.Config) (Store, error) {
|
||||
err = redisClient.Ping(ctx).Err()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to connect to configured Redis: %w", err)
|
||||
} else {
|
||||
log.Infof("Using Redis as session backing store")
|
||||
}
|
||||
|
||||
if cfg.OpenTelemetry.Enabled {
|
||||
if err := redisotel.InstrumentTracing(redisClient); err != nil {
|
||||
if err := redisotel.InstrumentTracing(redisClient, redisotel.WithDBStatement(false)); err != nil {
|
||||
return nil, fmt.Errorf("failed to instrument Redis Client: %w", err)
|
||||
}
|
||||
log.Infof("Setup telemtry for Redis")
|
||||
log.Infof("session: using redis as backing store with OpenTelemetry instrumentation")
|
||||
} else {
|
||||
log.Infof("session: using redis as backing store")
|
||||
}
|
||||
|
||||
return NewRedis(redisClient), nil
|
||||
|
||||
Reference in New Issue
Block a user