feat: add unauthenticated web dashboard showing monitoring state and recent alerts #83

Merged
sneak merged 3 commits from fix/issue-82-web-ui into main 2026-03-04 13:03:38 +01:00
6 changed files with 15 additions and 32 deletions
Showing only changes of commit c96ed42c31 - Show all commits

View File

@@ -2,8 +2,7 @@
BINARY := dnswatcher BINARY := dnswatcher
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILDARCH := $(shell go env GOARCH) LDFLAGS := -X main.Version=$(VERSION)
LDFLAGS := -X main.Version=$(VERSION) -X main.Buildarch=$(BUILDARCH)
all: check build all: check build

View File

@@ -171,7 +171,7 @@ cmd/dnswatcher/main.go Entry point (uber/fx bootstrap)
internal/ internal/
config/config.go Viper-based configuration config/config.go Viper-based configuration
globals/globals.go Build-time variables (version, arch) globals/globals.go Build-time variables (version)
logger/logger.go slog structured logging (TTY detection) logger/logger.go slog structured logging (TTY detection)
healthcheck/healthcheck.go Health check service healthcheck/healthcheck.go Health check service
middleware/middleware.go HTTP middleware (logging, CORS, metrics auth) middleware/middleware.go HTTP middleware (logging, CORS, metrics auth)
@@ -363,11 +363,10 @@ make clean # Remove build artifacts
### Build-Time Variables ### Build-Time Variables
Version and architecture are injected via `-ldflags`: Version is injected via `-ldflags`:
```sh ```sh
go build -ldflags "-X main.Version=$(git describe --tags --always) \ go build -ldflags "-X main.Version=$(git describe --tags --always)" ./cmd/dnswatcher
-X main.Buildarch=$(go env GOARCH)" ./cmd/dnswatcher
``` ```
--- ---

View File

@@ -25,15 +25,13 @@ import (
// //
//nolint:gochecknoglobals // build-time variables //nolint:gochecknoglobals // build-time variables
var ( var (
Appname = "dnswatcher" Appname = "dnswatcher"
Version string Version string
Buildarch string
) )
func main() { func main() {
globals.SetAppname(Appname) globals.SetAppname(Appname)
globals.SetVersion(Version) globals.SetVersion(Version)
globals.SetBuildarch(Buildarch)
fx.New( fx.New(
fx.Provide( fx.Provide(

View File

@@ -19,9 +19,8 @@ func newTestParams(t *testing.T) config.Params {
t.Helper() t.Helper()
g := &globals.Globals{ g := &globals.Globals{
Appname: "dnswatcher", Appname: "dnswatcher",
Version: "test", Version: "test",
Buildarch: "amd64",
} }
l, err := logger.New(nil, logger.Params{Globals: g}) l, err := logger.New(nil, logger.Params{Globals: g})

View File

@@ -12,17 +12,15 @@ import (
// //
//nolint:gochecknoglobals // Required for ldflags injection at build time //nolint:gochecknoglobals // Required for ldflags injection at build time
var ( var (
mu sync.RWMutex mu sync.RWMutex
appname string appname string
version string version string
buildarch string
) )
// Globals holds build-time variables for dependency injection. // Globals holds build-time variables for dependency injection.
type Globals struct { type Globals struct {
Appname string Appname string
Version string Version string
Buildarch string
} }
// New creates a new Globals instance from package-level variables. // New creates a new Globals instance from package-level variables.
@@ -31,9 +29,8 @@ func New(_ fx.Lifecycle) (*Globals, error) {
defer mu.RUnlock() defer mu.RUnlock()
return &Globals{ return &Globals{
Appname: appname, Appname: appname,
Version: version, Version: version,
Buildarch: buildarch,
}, nil }, nil
} }
@@ -52,11 +49,3 @@ func SetVersion(ver string) {
version = ver version = ver
} }
// SetBuildarch sets the build architecture.
func SetBuildarch(arch string) {
mu.Lock()
defer mu.Unlock()
buildarch = arch
}

View File

@@ -78,6 +78,5 @@ func (l *Logger) Identify() {
l.log.Info("starting", l.log.Info("starting",
"appname", l.params.Globals.Appname, "appname", l.params.Globals.Appname,
"version", l.params.Globals.Version, "version", l.params.Globals.Version,
"buildarch", l.params.Globals.Buildarch,
) )
} }