Skip to content

Commit 09e7920

Browse files
committed
Restrict to one RSCT CR
1 parent 785aeea commit 09e7920

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

internal/controller/rsct_controller.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ type RSCTReconciler struct {
6565
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
6666
func (r *RSCTReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
6767
_ = log.FromContext(ctx)
68+
69+
rsctList := &rsctv1alpha1.RSCTList{}
70+
if err := r.Client.List(ctx, rsctList, &client.ListOptions{}); err != nil {
71+
return reconcile.Result{}, fmt.Errorf("failed to list RSCT resources: %w", err)
72+
}
73+
if len(rsctList.Items) > 1 {
74+
return reconcile.Result{}, fmt.Errorf("only one RSCT custom resource is allowed, but found %d", len(rsctList.Items))
75+
}
76+
6877
rsct := &rsctv1alpha1.RSCT{}
6978
if err := r.Client.Get(ctx, req.NamespacedName, rsct); err != nil {
7079
if errors.IsNotFound(err) {

0 commit comments

Comments
 (0)