{{ if .Values.coder.enabled }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: coder
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: coder
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  namespace: {{ .Release.Namespace }}
  name: coder
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: dynamic-proxy
  namespace: {{ .Release.Namespace }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: coder-developer
  namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: {{ .Release.Namespace }}
  name: coder-developer
rules:
- apiGroups: [""]
  resources: ["configmaps"]
  verbs: ["get", "list", "create", "update", "patch"]
- apiGroups: [""]
  resources: ["secrets"]
  verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: coder-developer
  namespace: {{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
  name: coder-developer
  namespace: {{ .Release.Namespace }}
roleRef:
  kind: Role
  name: coder-developer
  apiGroup: rbac.authorization.k8s.io
---
{{ end }}