feat(master): POST /update webhook with auto-mode updates (#8)

This commit is contained in:
2026-10-12 20:40:38 +02:00
parent cfc6ea6713
commit 5d95a35b3b
10 changed files with 1174 additions and 14 deletions
+11 -2
View File
@@ -23,6 +23,7 @@ import (
"github.com/shcizo/package-updater/internal/master/store"
"github.com/shcizo/package-updater/internal/master/web"
"github.com/shcizo/package-updater/internal/master/webauth"
"github.com/shcizo/package-updater/internal/master/webhook"
"github.com/shcizo/package-updater/internal/pin"
)
@@ -93,6 +94,14 @@ func run() error {
}
_, _ = w.Write([]byte("ok"))
})
// The webhook does its own bearer-token check, so it sits outside the
// OIDC login like /healthz.
mux.Handle("POST /update", webhook.New(st, jobService, broker, webhook.Config{
Token: cfg.UpdaterAPIKey, Timeout: cfg.UpdateTimeout, PublicURL: cfg.PublicURL,
}, logger))
if cfg.UpdaterAPIKey == "" {
logger.Warn("webhook_disabled", "reason", "UPDATER_API_KEY not set")
}
mux.HandleFunc("GET /auth/login", auth.Login)
mux.HandleFunc("GET /auth/callback", auth.Callback)
mux.Handle("POST /auth/logout", auth.Require(http.HandlerFunc(auth.Logout)))
@@ -103,8 +112,8 @@ func run() error {
// instead of holding Shutdown until its timeout.
baseContext := func(net.Listener) context.Context { return ctx }
// No WriteTimeout on either server: SSE streams and agent connections
// are long-lived by design.
// No WriteTimeout on either server: SSE streams, agent connections and
// POST /update (which waits up to UPDATE_TIMEOUT) are long-lived by design.
webSrv := &http.Server{
Addr: ":" + cfg.Port, Handler: mux, ReadHeaderTimeout: 10 * time.Second,
BaseContext: baseContext,