Skip to content

Commit

Permalink
Make version dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
tparker00 committed Sep 1, 2024
1 parent 15d7096 commit 9a92980
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions internal/pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log/slog"
"net/http"
"runtime/debug"
"strings"
"time"

Expand All @@ -18,6 +19,18 @@ import (
"github.com/pkg/errors"
)

var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
return setting.Value
}
}
}

return ""
}()

type API struct {
SecretTTL time.Duration
WebTTL time.Duration
Expand All @@ -42,8 +55,7 @@ func New(config *config.Config) http.Handler {
MessageFieldName: "message",
TimeFieldFormat: time.RFC3339,
Tags: map[string]string{
"version": "v0.1.8",
"env": "prod",
"version": commit,
},
QuietDownRoutes: []string{
"/",
Expand Down

0 comments on commit 9a92980

Please sign in to comment.