|
| 1 | +{{- $cfg := .Values.argocdApplicationRbac | default dict }} |
| 2 | +{{- $doCreate := true }} |
| 3 | +{{- $createFlag := index $cfg "create" }} |
| 4 | +{{- if kindIs "bool" $createFlag }} |
| 5 | +{{- $doCreate = $createFlag }} |
| 6 | +{{- end }} |
| 7 | +{{- $includeArgoCD := false }} |
| 8 | +{{- $argoCrFlag := index $cfg "includeArgoCdOperatorCr" }} |
| 9 | +{{- if kindIs "bool" $argoCrFlag }} |
| 10 | +{{- $includeArgoCD = $argoCrFlag }} |
| 11 | +{{- end }} |
| 12 | +{{- if $doCreate }} |
| 13 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 14 | +kind: ClusterRole |
| 15 | +metadata: |
| 16 | + name: {{ $cfg.clusterRoleName | default "openshift-gitops-application-manager" }} |
| 17 | +rules: |
| 18 | + # Argo CD Application, ApplicationSet, AppProject (incl. status/finalizers for sync + deletion) |
| 19 | + - apiGroups: |
| 20 | + - argoproj.io |
| 21 | + resources: |
| 22 | + - applications |
| 23 | + - applications/status |
| 24 | + - applications/finalizers |
| 25 | + - applicationsets |
| 26 | + - applicationsets/status |
| 27 | + - applicationsets/finalizers |
| 28 | + - appprojects |
| 29 | + - appprojects/status |
| 30 | + verbs: |
| 31 | + - get |
| 32 | + - list |
| 33 | + - watch |
| 34 | + - create |
| 35 | + - update |
| 36 | + - patch |
| 37 | + - delete |
| 38 | + - deletecollection |
| 39 | +{{- if $includeArgoCD }} |
| 40 | + # Argo CD / OpenShift GitOps operator instance (cluster-scoped); enables changing operator-managed settings via CR. |
| 41 | + - apiGroups: |
| 42 | + - argoproj.io |
| 43 | + resources: |
| 44 | + - argocds |
| 45 | + verbs: |
| 46 | + - get |
| 47 | + - list |
| 48 | + - watch |
| 49 | + - create |
| 50 | + - update |
| 51 | + - patch |
| 52 | + - delete |
| 53 | + - deletecollection |
| 54 | +{{- end }} |
| 55 | +{{- $users := $cfg.users | default list }} |
| 56 | +{{- $groups := $cfg.groups | default list }} |
| 57 | +{{- if or (gt (len $users) 0) (gt (len $groups) 0) }} |
| 58 | +--- |
| 59 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 60 | +kind: ClusterRoleBinding |
| 61 | +metadata: |
| 62 | + name: {{ $cfg.clusterRoleBindingName | default "openshift-gitops-application-manager" }} |
| 63 | +roleRef: |
| 64 | + apiGroup: rbac.authorization.k8s.io |
| 65 | + kind: ClusterRole |
| 66 | + name: {{ $cfg.clusterRoleName | default "openshift-gitops-application-manager" }} |
| 67 | +subjects: |
| 68 | +{{- range $users }} |
| 69 | + - apiGroup: rbac.authorization.k8s.io |
| 70 | + kind: User |
| 71 | + name: {{ . | quote }} |
| 72 | +{{- end }} |
| 73 | +{{- range $groups }} |
| 74 | + - apiGroup: rbac.authorization.k8s.io |
| 75 | + kind: Group |
| 76 | + name: {{ . | quote }} |
| 77 | +{{- end }} |
| 78 | +{{- end }} |
| 79 | +{{- end }} |
0 commit comments