Added spec and indexer for PhysicalBackup

This commit is contained in:
mmontes11
2025-05-05 19:30:56 +02:00
committed by Martin Montes
parent 3874281156
commit f89e86c09f
12 changed files with 2379 additions and 81 deletions

View File

@ -2,13 +2,14 @@ package controller
import (
"context"
"fmt"
mariadbv1alpha1 "github.com/mariadb-operator/mariadb-operator/api/v1alpha1"
batchv1 "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
k8sv1alpha1 "github.com/mariadb-operator/mariadb-operator/api/v1alpha1"
)
// PhysicalBackupReconciler reconciles a PhysicalBackup object
@ -30,8 +31,14 @@ func (r *PhysicalBackupReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}
// SetupWithManager sets up the controller with the Manager.
func (r *PhysicalBackupReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&k8sv1alpha1.PhysicalBackup{}).
Complete(r)
func (r *PhysicalBackupReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error {
builder := ctrl.NewControllerManagedBy(mgr).
For(&mariadbv1alpha1.PhysicalBackup{}).
Owns(&batchv1.Job{})
if err := mariadbv1alpha1.IndexPhysicalBackup(ctx, mgr, builder, r.Client); err != nil {
return fmt.Errorf("error indexing PhysicalBackup: %v", err)
}
return builder.Complete(r)
}