Refactor arrtrix webhook to use fixed path and remove legacy config
Some checks failed
Test action / kaas (push) Failing after 1s

- Switch arrtrix webhook to a fixed path: /_arrtrix/webhook
- Remove Radarr-specific and secret-based config from arrtrix
- Simplify connector and webhook handler logic
- Update NixOS module to drop legacy webhook config
- Add new tests for generic arrtrix webhook handler
This commit is contained in:
Chris Kruining 2026-04-16 09:47:00 +02:00
parent fe627f3aab
commit bbfe6867c8
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
11 changed files with 211 additions and 285 deletions

View file

@ -14,40 +14,23 @@ import (
//go:embed example-config.yaml
var ExampleConfig string
type Config struct {
Webhooks WebhooksConfig `yaml:"webhooks"`
}
type WebhooksConfig struct {
Radarr webhook.RadarrConfig `yaml:"radarr"`
}
func (c *Config) applyDefaults() {
c.Webhooks.Radarr.ApplyDefaults()
}
func (c *Config) Validate() error {
return c.Webhooks.Radarr.Validate()
}
type Config struct{}
func upgradeConfig(helper up.Helper) {}
func (s *ArrtrixConnector) GetConfig() (string, any, up.Upgrader) {
s.Config.applyDefaults()
return ExampleConfig, &s.Config, up.SimpleUpgrader(upgradeConfig)
}
func (s *ArrtrixConnector) ValidateConfig() error {
s.Config.applyDefaults()
return s.Config.Validate()
return nil
}
func (s *ArrtrixConnector) MountRoutes(router *http.ServeMux) error {
s.Config.applyDefaults()
if s.Bridge == nil {
return fmt.Errorf("bridge is not initialized")
}
return webhook.MountRadarr(router, s.Bridge, s.Config.Webhooks.Radarr)
return webhook.MountArr(router, s.Bridge)
}
var _ bridgev2.ConfigValidatingNetwork = (*ArrtrixConnector)(nil)

View file

@ -1,23 +0,0 @@
package connector
import "testing"
func TestConfigDefaultsApplyRadarrWebhookPath(t *testing.T) {
var cfg Config
cfg.applyDefaults()
if cfg.Webhooks.Radarr.Path == "" {
t.Fatal("expected radarr webhook path default to be set")
}
}
func TestConfigValidateRejectsEnabledWebhookWithoutSecret(t *testing.T) {
cfg := Config{}
cfg.Webhooks.Radarr.Enabled = true
cfg.applyDefaults()
if err := cfg.Validate(); err == nil {
t.Fatal("expected missing secret to fail validation")
}
}

View file

@ -1,10 +1,4 @@
# Arrtrix-specific runtime options.
# No network-specific config is required yet.
#
webhooks:
radarr:
enabled: false
path: /_arrtrix/webhooks/radarr
secret: ""
# The first implementation delivers notifications to the only configured
# management room. If more than one management room exists, the webhook is
# rejected until routing is configured more explicitly.
# Arr-stack webhooks are exposed automatically on the fixed built-in path:
# POST /_arrtrix/webhook