supabase-operator/internal/webhook/v1alpha1/setup.go
Peter Kurfer b55afea477
Some checks failed
Deploy pages / deploy (push) Successful in 40s
release / release (push) Waiting to run
E2E Tests / Run on Ubuntu (push) Failing after 1m47s
Lint / Run on Ubuntu (push) Failing after 3m33s
Tests / Run on Ubuntu (push) Failing after 5m3s
feat(storage): prepare custom resource for storage API
2025-01-21 21:56:17 +01:00

63 lines
2.3 KiB
Go

/*
Copyright 2025 Peter Kurfer.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
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()
}
// SetupStorageWebhookWithManager registers the webhook for Storage in the manager.
func SetupStorageWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).For(&supabasev1alpha1.Storage{}).
WithValidator(&StorageCustomValidator{}).
WithDefaulter(&StorageCustomDefaulter{Client: mgr.GetClient()}).
Complete()
}