supabase-operator/internal/webhook/v1alpha1/setup.go
Peter Kurfer 647f602c79
Some checks failed
Lint / Run on Ubuntu (push) Failing after 2m58s
E2E Tests / Run on Ubuntu (push) Failing after 4m18s
Tests / Run on Ubuntu (push) Failing after 2m39s
feat: basic functionality implemented
- added Core CRD to manage DB migrations & configuration, PostgREST and
  GoTrue (auth)
- added APIGateway CRD to manage Envoy proxy
- added Dashboard CRD to manage (so far) pg-meta and (soon) studio
  deployments
- implemented basic Envoy control plane based on K8s watcher
2025-01-04 17:07:49 +01:00

31 lines
1 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()
}