supabase-operator/internal/webhook/v1alpha1/setup.go
Peter Kurfer 0b551325b9
Some checks failed
Lint / Run on Ubuntu (push) Failing after 3m49s
E2E Tests / Run on Ubuntu (push) Failing after 3m58s
Tests / Run on Ubuntu (push) Failing after 3m52s
feat(dashboard): initial support for studio & pg-meta services
2025-01-11 16:51:53 +01:00

39 lines
1.4 KiB
Go

package v1alpha1
import (
ctrl "sigs.k8s.io/controller-runtime"
supabasev1alpha1 "code.icb4dc0.de/prskr/supabase-operator/api/v1alpha1"
)
type WebhookConfig struct {
CurrentNamespace string
}
// SetupAPIGatewayWebhookWithManager registers the webhook for APIGateway in the manager.
func SetupAPIGatewayWebhookWithManager(mgr ctrl.Manager, cfg WebhookConfig) error {
mgr.GetEventRecorderFor("apigateway-defaulter")
return ctrl.NewWebhookManagedBy(mgr).For(&supabasev1alpha1.APIGateway{}).
WithValidator(&APIGatewayCustomValidator{}).
WithDefaulter(&APIGatewayCustomDefaulter{
CurrentNamespace: cfg.CurrentNamespace,
Recorder: mgr.GetEventRecorderFor("apigateway-defaulter"),
}).
Complete()
}
// SetupCoreWebhookWithManager registers the webhook for Core in the manager.
func SetupCoreWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).For(&supabasev1alpha1.Core{}).
WithValidator(&CoreCustomValidator{Client: mgr.GetClient()}).
WithDefaulter(&CoreCustomDefaulter{Client: mgr.GetClient()}).
Complete()
}
// SetupDashboardWebhookWithManager registers the webhook for Dashboard in the manager.
func SetupDashboardWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).For(&supabasev1alpha1.Dashboard{}).
WithValidator(&DashboardCustomValidator{}).
WithDefaulter(&DashboardCustomDefaulter{}).
Complete()
}