Sylvain Desbureaux | 4534881 | 2020-05-19 17:46:54 +0200 | [diff] [blame] | 1 | {{/* |
| 2 | # Copyright © 2020 Orange |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | */}} |
| 16 | |
| 17 | {{- $dot := . -}} |
| 18 | {{- range $role_type := $dot.Values.roles }} |
| 19 | --- |
| 20 | apiVersion: rbac.authorization.k8s.io/v1 |
| 21 | kind: Role |
| 22 | metadata: |
| 23 | name: {{ include "common.fullname" (dict "suffix" $role_type "dot" $dot )}} |
| 24 | namespace: {{ include "common.namespace" $dot }} |
| 25 | rules: |
| 26 | {{- if eq $role_type "read" }} |
| 27 | - apiGroups: |
| 28 | - "" # "" indicates the core API group |
| 29 | - apps |
| 30 | - batch |
| 31 | resources: |
| 32 | - pods |
| 33 | - deployments |
| 34 | - jobs |
| 35 | - jobs/status |
| 36 | - statefulsets |
| 37 | - replicasets |
| 38 | - daemonsets |
| 39 | verbs: |
| 40 | - get |
| 41 | - watch |
| 42 | - list |
| 43 | {{- else }} |
| 44 | {{- if eq $role_type "create" }} |
| 45 | - apiGroups: |
| 46 | - "" # "" indicates the core API group |
| 47 | - apps |
| 48 | - batch |
| 49 | resources: |
| 50 | - pods |
| 51 | - deployments |
| 52 | - jobs |
| 53 | - jobs/status |
| 54 | - statefulsets |
| 55 | - replicasets |
| 56 | - daemonsets |
| 57 | - secrets |
| 58 | verbs: |
| 59 | - get |
| 60 | - watch |
| 61 | - list |
| 62 | - apiGroups: |
| 63 | - "" # "" indicates the core API group |
| 64 | - apps |
| 65 | resources: |
| 66 | - statefulsets |
| 67 | verbs: |
| 68 | - patch |
| 69 | - apiGroups: |
| 70 | - "" # "" indicates the core API group |
| 71 | - apps |
| 72 | resources: |
| 73 | - deployments |
| 74 | - secrets |
| 75 | verbs: |
| 76 | - create |
| 77 | - apiGroups: |
| 78 | - "" # "" indicates the core API group |
| 79 | - apps |
| 80 | resources: |
| 81 | - pods |
| 82 | - persistentvolumeclaims |
| 83 | - secrets |
| 84 | - deployment |
| 85 | verbs: |
| 86 | - delete |
| 87 | - apiGroups: |
| 88 | - "" # "" indicates the core API group |
| 89 | - apps |
| 90 | resources: |
| 91 | - pods/exec |
| 92 | verbs: |
| 93 | - create |
| 94 | {{- else }} |
| 95 | {{- if hasKey $dot.Values.new_roles_definitions $role_type }} |
| 96 | {{ include "common.tplValue" ( dict "value" (index $dot.Values.new_roles_definitions $role_type ) "context" $dot) }} |
| 97 | {{- else}} |
| 98 | # if you don't match read or create, then you're not allowed to use API |
| 99 | - apiGroups: [] |
| 100 | resources: [] |
| 101 | verbs: [] |
| 102 | {{- end }} |
| 103 | {{- end }} |
| 104 | {{- end }} |
| 105 | {{- end }} |