From 10d6077775b365a0b5035151a314024188a1f7ff Mon Sep 17 00:00:00 2001
From: csviri <csviri@gmail.com>
Date: Fri, 21 Jul 2023 19:08:44 +0200
Subject: [PATCH] wip

---
 .../templates/cr-cluster-role-binding.yaml       | 11 -----------
 .../templates/cr-cluster-role.yaml               | 15 +++++++++------
 .../templates/cr-role-bindings.yaml              |  7 +++++--
 target-helm-chart-joke/values.yaml               | 16 ++++++++++++++++
 4 files changed, 30 insertions(+), 19 deletions(-)
 delete mode 100644 target-helm-chart-joke/templates/cr-cluster-role-binding.yaml

diff --git a/target-helm-chart-joke/templates/cr-cluster-role-binding.yaml b/target-helm-chart-joke/templates/cr-cluster-role-binding.yaml
deleted file mode 100644
index dddb4fdb8..000000000
--- a/target-helm-chart-joke/templates/cr-cluster-role-binding.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRoleBinding
-metadata:
-  name: jokerequestreconciler-crd-validating-role-binding
-roleRef:
-  kind: ClusterRole
-  apiGroup: rbac.authorization.k8s.io
-  name: josdk-crd-validating-cluster-role
-subjects:
-  - kind: ServiceAccount
-    name: {{ .Chart.Name }}
\ No newline at end of file
diff --git a/target-helm-chart-joke/templates/cr-cluster-role.yaml b/target-helm-chart-joke/templates/cr-cluster-role.yaml
index 4923b1f6a..70af2e34f 100644
--- a/target-helm-chart-joke/templates/cr-cluster-role.yaml
+++ b/target-helm-chart-joke/templates/cr-cluster-role.yaml
@@ -1,14 +1,15 @@
+{{- range $.Values.reconcilers }}
 apiVersion: rbac.authorization.k8s.io/v1
 kind: ClusterRole
 metadata:
-  name: jokerequestreconciler-cluster-role
+  name: {{ .name }}-cluster-role
 rules:
   - apiGroups:
-      - samples.javaoperatorsdk.io
+      - {{ .apiGroup }}
     resources:
-      - jokerequests
-      - jokerequests/status
-      - jokerequests/finalizers
+      - {{ .resource }}
+      - {{ .resource }}/status
+      - {{ .resource }}/finalizers
     verbs:
       - get
       - list
@@ -16,4 +17,6 @@ rules:
       - patch
       - update
       - create
-      - delete
\ No newline at end of file
+      - delete
+---
+{{- end }}
\ No newline at end of file
diff --git a/target-helm-chart-joke/templates/cr-role-bindings.yaml b/target-helm-chart-joke/templates/cr-role-bindings.yaml
index 52c43b77e..93831a269 100644
--- a/target-helm-chart-joke/templates/cr-role-bindings.yaml
+++ b/target-helm-chart-joke/templates/cr-role-bindings.yaml
@@ -1,3 +1,4 @@
+{{- range $.Values.reconcilers }}
 apiVersion: rbac.authorization.k8s.io/v1
 kind: RoleBinding
 metadata:
@@ -5,7 +6,9 @@ metadata:
 roleRef:
   kind: ClusterRole
   apiGroup: rbac.authorization.k8s.io
-  name: jokerequestreconciler-cluster-role
+  name: {{ .name }}-cluster-role
 subjects:
   - kind: ServiceAccount
-    name: {{ .Chart.Name }}
\ No newline at end of file
+    name: {{ $.Chart.Name }}
+---
+{{- end }}
\ No newline at end of file
diff --git a/target-helm-chart-joke/values.yaml b/target-helm-chart-joke/values.yaml
index d46acbb62..10baa1a5d 100644
--- a/target-helm-chart-joke/values.yaml
+++ b/target-helm-chart-joke/values.yaml
@@ -1,4 +1,20 @@
+
+# can be a one of:
+#  - "all-namespaces"
+#  - "current-namespace"
+#  - comma separated list of namespaces
+watch-namespaces: all-namespaces
+
+# values that can be directly generated into templates
 qosdk:
   version: 6.2.2-SNAPSHOT
 
 image: csviri/quarkus-operator-sdk-samples-joke:6.2.2-SNAPSHOT
+
+reconcilers:
+  - name: jokerequestreconciler
+    resource: jokerequests
+    apiGroup: samples.javaoperatorsdk.io
+  - name: reconciler2
+    resource: sampleresource2
+    apiGroup: samples.javaoperatorsdk.io
\ No newline at end of file