1.5 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
alerttonotify receives Alertmanager HTTP webhooks and forwards them as notifications via NATS to a dbus notify service. Written in Go (1.23.3).
Build & Development
# Build
go build -v ./...
# Lint (available in nix devshell)
golangci-lint run
# Enter dev environment (requires nix with flakes)
nix develop
# Build with nix
nix build
No tests exist yet. The project uses direnv (.envrc) to auto-load the nix devshell.
Architecture
main.go — Entry point. Reads config from environment variables, sets up NATS connection, creates the HTTP server, handles graceful shutdown on SIGINT.
server/server.go — HTTP server with two routes:
GET /— health checkPOST /alert— receives Alertmanager webhook payloads (AlertMessage/Alertstructs), builds a summary, and publishes viaNotificationService
server/notify.go — NotificationService wraps a NATS connection. Serializes BusNotification (summary, body, timeout) to JSON and publishes to subject home2rjusnet.notifications. Uses NKey authentication.
Configuration
All config is via environment variables:
NATS_URL(required) — NATS server URLNATS_NKEYorNATS_NKEY_FILE(required) — NKey seed for NATS authALERTTONOTIFY_ADDR(optional, default:5001) — HTTP listen address
Nix
The flake builds with buildGoModule. The vendorHash in flake.nix must be updated when Go dependencies change.