{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{ if and .Values.rbac.create .Values.features.analytics }}
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
kind: Role
metadata:
  name: {{ printf "%s-analytics" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/part-of: kube-arangodb
    app.kubernetes.io/component: operator
rules:
  - apiGroups:
      - "analytics.arangodb.com"
    resources:
      - "graphanalyticsengines"
      - "graphanalyticsengines/status"
    verbs:
      - "*"
  - apiGroups:
      - "database.arangodb.com"
    resources:
      - "arangodeployments"
    verbs:
      - "get"
      - "list"
      - "watch"
  - apiGroups: ["apps"]
    resources:
      - "statefulsets"
    verbs: ["*"]
  - apiGroups: [ "" ]
    resources:
      - "secrets"
      - "services"
    verbs: [ "*" ]
{{- end }}