# _helpers.tpl
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "redmine.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "redmine.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "redmine.mariadb.fullname" -}}
{{- printf "%s-%s" .Release.Name "mariadb" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "redmine.postgresql.fullname" -}}
{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "redmine.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "redmine.labels" -}}
app.kubernetes.io/name: {{ template "redmine.name" . }}
helm.sh/chart: {{ template "redmine.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
*/}}
{{- define "redmine.matchLabels" -}}
app.kubernetes.io/name: {{ template "redmine.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Return the proper Redmine image name
*/}}
{{- define "redmine.image" -}}
{{- $registryName := .Values.image.registry -}}
{{- $repositoryName := .Values.image.repository -}}
{{- $tag := .Values.image.tag | toString -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
Also, we can't use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
    {{- if .Values.global.imageRegistry }}
        {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
    {{- else -}}
        {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
    {{- end -}}
{{- else -}}
    {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- end -}}

{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "redmine.imagePullSecrets" -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
Also, we can not use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
{{- if .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- range .Values.global.imagePullSecrets }}
  - name: {{ . }}
{{- end }}
{{- else if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
  - name: {{ . }}
{{- end }}
{{- end -}}
{{- else if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
  - name: {{ . }}
{{- end }}
{{- end -}}
{{- end -}}

{{/*
Return  the proper Storage Class
*/}}
{{- define "redmine.storageClass" -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 does not support it, so we need to implement this if-else logic.
*/}}
{{- if .Values.global -}}
    {{- if .Values.global.storageClass -}}
        {{- if (eq "-" .Values.global.storageClass) -}}
            {{- printf "storageClassName: \"\"" -}}
        {{- else }}
            {{- printf "storageClassName: %s" .Values.global.storageClass -}}
        {{- end -}}
    {{- else -}}
        {{- if .Values.persistence.storageClass -}}
              {{- if (eq "-" .Values.persistence.storageClass) -}}
                  {{- printf "storageClassName: \"\"" -}}
              {{- else }}
                  {{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
              {{- end -}}
        {{- end -}}
    {{- end -}}
{{- else -}}
    {{- if .Values.persistence.storageClass -}}
        {{- if (eq "-" .Values.persistence.storageClass) -}}
            {{- printf "storageClassName: \"\"" -}}
        {{- else }}
            {{- printf "storageClassName: %s" .Values.persistence.storageClass -}}
        {{- end -}}
    {{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for deployment.
*/}}
{{- define "redmine.deployment.apiVersion" -}}
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
{{- print "extensions/v1beta1" -}}
{{- else -}}
{{- print "apps/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "redmine.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "redmine.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Return the name of the Secret used to store the passwords
*/}}
{{- define "redmine.secretName" -}}
{{- if .Values.existingSecret -}}
{{ .Values.existingSecret }}
{{- else -}}
{{ template "redmine.fullname" . }}
{{- end -}}
{{- end -}}

{{/*
Renders a value that contains template.
Usage:
{{ include "redmine.tplValue" (dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "redmine.tplValue" -}}
    {{- if typeIs "string" .value }}
        {{- tpl .value .context }}
    {{- else }}
        {{- tpl (.value | toYaml) .context }}
    {{- end }}
{{- end -}}

{{/*
Expand the name of the chart.
*/}}
{{- define "redmine.mailReceiver.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified mail receiver app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "redmine.mailReceiver.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s-mail-receiver" .Release.Name $name | trunc 40 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return the proper Redmine mail Receiver image name
*/}}
{{- define "redmine.mailReceiver.image" -}}
{{- $registryName := .Values.mailReceiver.image.registry -}}
{{- $repositoryName := .Values.mailReceiver.image.repository -}}
{{- $tag := .Values.mailReceiver.image.tag | toString -}}
{{/*
Helm 2.11 supports the assignment of a value to a variable defined in a different scope,
but Helm 2.9 and 2.10 doesn't support it, so we need to implement this if-else logic.
Also, we can't use a single if because lazy evaluation is not an option
*/}}
{{- if .Values.global }}
    {{- if .Values.global.imageRegistry }}
        {{- printf "%s/%s:%s" .Values.global.imageRegistry $repositoryName $tag -}}
    {{- else -}}
        {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
    {{- end -}}
{{- else -}}
    {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}
{{- end -}}

{{/*
Mail Receiver CronJob labels
*/}}
{{- define "redmine.mailReceiver.labels" -}}
app.kubernetes.io/name: {{ template "redmine.mailReceiver.name" . }}
helm.sh/chart: {{ template "redmine.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
 # cronjob.yaml
{{- if .Values.mailReceiver.enabled }}
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: {{ template "redmine.mailReceiver.fullname" . }}
  labels: {{- include "redmine.mailReceiver.labels" . | nindent 4 }}
spec:
  schedule: "{{ .Values.mailReceiver.schedule }}"
  suspend: {{ .Values.mailReceiver.suspend }}
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        metadata:
          labels: {{- include "redmine.mailReceiver.labels" . | nindent 12 }}
        spec:
          volumes:
            - name: mail-receiver
              configMap:
                name: {{ template "redmine.fullname" . }}
                defaultMode: 0744
          restartPolicy: Never
          containers:
            - name: {{ template "redmine.mailReceiver.fullname" . }}
              image: {{ template "redmine.mailReceiver.image" . }}
              imagePullPolicy: {{ .Values.mailReceiver.image.pullPolicy | quote }}
              command:
                - bash
              args:
                - -c
                - /cj/receive.sh
              volumeMounts:
                - name: mail-receiver
                  mountPath: /cj
              resources:
{{ toYaml .Values.resources | indent 16 }}
              env:
                {{- if eq .Values.databaseType "mariadb" }}
                - name: REDMINE_MAIL_RECEIVER_DB_MYSQL
                {{- if .Values.mariadb.enabled }}
                  value: {{ template "redmine.mariadb.fullname" . }}
                - name: REDMINE_MAIL_RECEIVER_DB_DATABASE
                  value: {{ .Values.mariadb.db.name | quote }}
                - name: REDMINE_MAIL_RECEIVER_DB_USERNAME
                  value: {{ .Values.mariadb.db.user | quote }}
                - name: REDMINE_MAIL_RECEIVER_DB_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: {{ template "redmine.mariadb.fullname" . }}
                      key: mariadb-password
                - name: REDMINE_MAIL_RECEIVER_DB_PORT
                  value: "3306"
                {{- else }}
                  value: {{ .Values.externalDatabase.host | quote }}
                {{- end }}
                {{- else if eq .Values.databaseType "postgresql" }}
                - name: REDMINE_MAIL_RECEIVER_DB_POSTGRES
                {{- if .Values.postgresql.enabled }}
                  value: {{ template "redmine.postgresql.fullname" . }}
                - name: REDMINE_MAIL_RECEIVER_DB_DATABASE
                  value: {{ .Values.postgresql.postgresqlDatabase | quote }}
                - name: REDMINE_MAIL_RECEIVER_DB_USERNAME
                  value: {{ .Values.postgresql.postgresqlUsername | quote }}
                - name: REDMINE_MAIL_RECEIVER_DB_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: {{ template "redmine.postgresql.fullname" . }}
                      key: postgresql-password
                - name: REDMINE_MAIL_RECEIVER_DB_PORT
                  value: "5432"
                {{- else }}
                  value: {{ .Values.externalDatabase.host | quote }}
                {{- end }}
                {{- end }}
                {{- if or (and (eq .Values.databaseType "mariadb") (not .Values.mariadb.enabled)) (and (eq .Values.databaseType "postgresql") (not .Values.postgresql.enabled)) }}
                - name: REDMINE_MAIL_RECEIVER_DB_DATABASE
                  value: {{ .Values.externalDatabase.name | quote }}
                - name: REDMINE_MAIL_RECEIVER_DB_USERNAME
                  value: {{ .Values.externalDatabase.user | quote }}
                - name: REDMINE_MAIL_RECEIVER_DB_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: {{ template "redmine.secretName" . }}
                      key: external-db-password
                - name: REDMINE_MAIL_RECEIVER_DB_PORT
                  value: {{ .Values.externalDatabase.port | quote }}
                {{- end }}
                - name: REDMINE_MAIL_RECEIVER_HOST
                  value: {{ .Values.mailReceiver.host | quote }}
                - name: REDMINE_MAIL_RECEIVER_PORT
                  value: {{ .Values.mailReceiver.port | quote }}
                - name: REDMINE_MAIL_RECEIVER_USERNAME
                  value: {{ .Values.mailReceiver.username | quote }}
                - name: REDMINE_MAIL_RECEIVER_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: {{ template "redmine.secretName" . }}
                      key: mail-receiver-password
                - name: REDMINE_MAIL_RECEIVER_USE_SSL
                  value: {{ .Values.mailReceiver.ssl | quote }}
                - name: REDMINE_MAIL_RECEIVER_STARTTLS
                  value: {{ .Values.mailReceiver.startTLS | quote }}
                - name: REDMINE_MAIL_RECEIVER_IMAP_FOLDER
                  value: {{ .Values.mailReceiver.imapFolder | quote }}
                - name: REDMINE_MAIL_RECEIVER_IMAP_MOVE_ON_SUCCESS
                  value: {{ .Values.mailReceiver.moveOnSuccess | quote }}
                - name: REDMINE_MAIL_RECEIVER_IMAP_MOVE_ON_FAILURE
                  value: {{ .Values.mailReceiver.moveOnFailure | quote }}
                - name: REDMINE_MAIL_RECEIVER_UNKNOWN_USER_ACTION
                  value: {{ .Values.mailReceiver.unknownUserAction | quote }}
                - name: REDMINE_MAIL_RECEIVER_NO_PERMISSION_CHECK
                  value: {{ .Values.mailReceiver.noPermissionCheck | quote }}
                - name: REDMINE_MAIL_RECEIVER_NO_ACCOUNT_NOTICE
                  value: {{ .Values.mailReceiver.noAccountNotice | quote }}
                - name: REDMINE_MAIL_RECEIVER_DEFAULT_GROUP
                  value: {{ .Values.mailReceiver.defaultGroup | quote }}
                - name: REDMINE_MAIL_RECEIVER_PROJECT
                  value: {{ .Values.mailReceiver.project | quote }}
                - name: REDMINE_MAIL_RECEIVER_PROJECT_FROM_SUBADDRESS
                  value: {{ .Values.mailReceiver.projectFromSubaddress | quote }}
                - name: REDMINE_MAIL_RECEIVER_STATUS
                  value: {{ .Values.mailReceiver.status | quote }}
                - name: REDMINE_MAIL_RECEIVER_TRACKER
                  value: {{ .Values.mailReceiver.tracker | quote }}
                - name: REDMINE_MAIL_RECEIVER_CATEGORY
                  value: {{ .Values.mailReceiver.category | quote }}
                - name: REDMINE_MAIL_RECEIVER_PRIORITY
                  value: {{ .Values.mailReceiver.priority | quote }}
                - name: REDMINE_MAIL_RECEIVER_ASSIGNED_TO
                  value: {{ .Values.mailReceiver.assignedTo | quote }}
                - name: REDMINE_MAIL_RECEIVER_ALLOW_OVERRIDE
                  value: {{ .Values.mailReceiver.allowOverride | quote }}
                - name: REDMINE_MAIL_RECEIVER_SECRET_KEY_BASE
                  value: {{ randAlphaNum 64 | quote }}
                - name: REDMINE_MAIL_RECEIVER_PROTOCOL
                  value: {{ .Values.mailReceiver.mailProtocol | quote }}
                - name: REDMINE_MAIL_RECEIVER_POP3_DELETE_UNPROCESSED
                  value: {{ .Values.mailReceiver.moveOnFailure | quote }}
{{- end }}
 # deployment.yaml
apiVersion: {{ template "redmine.deployment.apiVersion" . }}
kind: Deployment
metadata:
  name: {{ template "redmine.fullname" . }}
  labels: {{- include "redmine.labels" . | nindent 4 }}
spec:
  selector:
    matchLabels: {{- include "redmine.matchLabels" . | nindent 6 }}
  replicas: {{ .Values.replicas }}
  template:
    metadata:
      labels: {{- include "redmine.labels" . | nindent 8 }}
      {{- if .Values.podAnnotations }}
      annotations: {{- include "redmine.tplValue" (dict "value" .Values.podAnnotations "context" $) | nindent 8 }}
      {{- end }}
    spec:
{{- include "redmine.imagePullSecrets" . | indent 6 }}
      {{- if .Values.affinity }}
      affinity: {{- include "redmine.tplValue" (dict "value" .Values.affinity "context" $) | nindent 8 }}
      {{- end }}
      {{- if .Values.nodeSelector }}
      nodeSelector: {{- include "redmine.tplValue" (dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
      {{- end }}
      {{- if .Values.tolerations }}
      tolerations: {{- include "redmine.tplValue" (dict "value" .Values.tolerations "context" $) | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ template "redmine.serviceAccountName" . }}
      {{- with .Values.securityContext }}
      securityContext: {{- toYaml . | nindent 8 }}
      {{- end }}
      containers:
        - name: {{ template "redmine.fullname" . }}
          image: {{ template "redmine.image" . }}
          imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
          {{- if .Values.resources }}
          resources: {{- toYaml .Values.resources | nindent 12 }}
          {{- end }}
          env:
            {{- if .Values.extraVars }}
            {{- toYaml .Values.extraVars | nindent 12 }}
            {{- end }}
            {{- if eq .Values.databaseType "mariadb" }}
            - name: REDMINE_DB_MYSQL
            {{- if .Values.mariadb.enabled }}
              value: {{ template "redmine.mariadb.fullname" . }}
            - name: REDMINE_DB_NAME
              value: {{ .Values.mariadb.db.name | quote }}
            - name: REDMINE_DB_USERNAME
              value: {{ .Values.mariadb.db.user | quote }}
            - name: REDMINE_DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ template "redmine.mariadb.fullname" . }}
                  key: mariadb-password
            {{- else }}
              value: {{ .Values.externalDatabase.host | quote }}
            {{- end }}
            {{- else if eq .Values.databaseType "postgresql" }}
            - name: REDMINE_DB_POSTGRES
            {{- if .Values.postgresql.enabled }}
              value: {{ template "redmine.postgresql.fullname" . }}
            - name: REDMINE_DB_NAME
              value: {{ .Values.postgresql.postgresqlDatabase | quote }}
            - name: REDMINE_DB_USERNAME
              value: {{ .Values.postgresql.postgresqlUsername | quote }}
            - name: REDMINE_DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ template "redmine.postgresql.fullname" . }}
                  key: postgresql-password
            {{- else }}
              value: {{ .Values.externalDatabase.host | quote }}
            {{- end }}
            {{- end }}
            {{- if or (and (eq .Values.databaseType "mariadb") (not .Values.mariadb.enabled)) (and (eq .Values.databaseType "postgresql") (not .Values.postgresql.enabled)) }}
            - name: REDMINE_DB_NAME
              value: {{ .Values.externalDatabase.name | quote }}
            - name: REDMINE_DB_USERNAME
              value: {{ .Values.externalDatabase.user | quote }}
            - name: REDMINE_DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ template "redmine.secretName" . }}
                  key: external-db-password
            - name: REDMINE_DB_PORT_NUMBER
              value: {{ .Values.externalDatabase.port | quote }}
            {{- end }}
            - name: REDMINE_USERNAME
              value: {{ default "" .Values.redmineUsername | quote }}
            - name: REDMINE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ template "redmine.secretName" . }}
                  key: redmine-password
            - name: REDMINE_EMAIL
              value: {{ .Values.redmineEmail | quote }}
            - name: REDMINE_LANG
              value: {{ .Values.redmineLanguage | quote }}
            {{- if .Values.smtpHost }}
            - name: SMTP_HOST
              value: {{ .Values.smtpHost | quote }}
            {{- end }}
            {{- if .Values.smtpPort }}
            - name: SMTP_PORT
              value: {{ .Values.smtpPort | quote }}
            {{- end }}
            {{- if .Values.smtpUser }}
            - name: SMTP_USER
              value: {{ .Values.smtpUser | quote }}
            {{- end }}
            {{- if .Values.smtpPassword }}
            - name: SMTP_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ template "redmine.secretName" . }}
                  key: smtp-password
            {{- end }}
            {{- if .Values.smtpTls }}
            - name: SMTP_TLS
              value: {{ .Values.smtpTls | quote }}
            {{- end }}
          ports:
            - name: http-redmine
              containerPort: 3000
          {{- if .Values.livenessProbe.enabled }}
          livenessProbe:
            httpGet:
              path: /
              port: http-redmine
            initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
            periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
            timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
            successThreshold: {{ .Values.livenessProbe.successThreshold }}
            failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
          {{- end }}
          {{- if .Values.readinessProbe.enabled }}
          readinessProbe:
            httpGet:
              path: /
              port: http-redmine
            initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
            periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
            timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
            successThreshold: {{ .Values.readinessProbe.successThreshold }}
            failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
          {{- end }}
          volumeMounts:
            - name: redmine-data
              mountPath: /bitnami/redmine
      volumes:
        - name: redmine-data
          {{- if .Values.persistence.enabled }}
          persistentVolumeClaim:
            claimName: {{ .Values.persistence.existingClaim | default (include "redmine.fullname" .) }}
          {{- else }}
          emptyDir: {}
          {{- end }}
 # ingress.yaml
{{- if .Values.ingress.enabled }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ template "redmine.fullname" . }}
  labels: {{- include "redmine.labels" . | nindent 4 }}
  annotations:
    {{- if .Values.ingress.certManager }}
    kubernetes.io/tls-acme: "true"
    {{- end }}
    {{- if .Values.ingress.annotations }}
    {{- include "redmine.tplValue" (dict "value" .Values.ingress.annotations "context" $) | nindent 4 }}
    {{- end }}
spec:
  rules:
    {{- if .Values.ingress.hostname }}
    - host: {{ .Values.ingress.hostname }}
      http:
        paths:
        - path: /
          backend:
            serviceName: "{{ template "redmine.fullname" . }}"
            servicePort: http-redmine
    {{- end }}
    {{- range .Values.ingress.extraHosts }}
    - host: {{ .name }}
      http:
        paths:
        - path: {{ default "/" .path }}
          backend:
            serviceName: "{{ template "redmine.fullname" $ }}"
            servicePort: http-redmine
    {{- end }}
  {{- if or .Values.ingress.tls .Values.ingress.extraTls .Values.ingress.hosts }}
  tls:
    {{- if .Values.ingress.tls }}
    - hosts:
        - {{ .Values.ingress.hostname }}
      secretName: {{ printf "%s-tls" .Values.ingress.hostname }}
    {{- end }}
    {{- if .Values.ingress.extraTls }}
    {{- toYaml .Values.ingress.extraTls | nindent 4 }}
    {{- end }}
  {{- end }}
{{- end }}
 # mail-receiver-configmap.yaml
{{- if .Values.mailReceiver.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "redmine.fullname" . }}
  labels: {{- include "redmine.labels" . | nindent 4 }}
data:
  receive.sh: |
    #!/usr/bin/env bash

    if [ $REDMINE_MAIL_RECEIVER_DEBUG ]; then 
        set -x
    fi

    # Perform basic validation
    if [ "$REDMINE_MAIL_RECEIVER_HOST" = "" ]; then
        echo "Envar REDMINE_MAIL_RECEIVER_HOST undefined"
        exit 1
    fi

    if [ "$REDMINE_MAIL_RECEIVER_PORT" = "" ]; then
        echo "Envar REDMINE_MAIL_RECEIVER_PORT undefined"
        exit 1
    fi

    if [ "$REDMINE_MAIL_RECEIVER_USERNAME" = "" ]; then
        echo "Envar REDMINE_MAIL_RECEIVER_USERNAME undefined"
        exit 1
    fi

    if [ "$REDMINE_MAIL_RECEIVER_PASSWORD" = "" ]; then
        echo "Envar REDMINE_MAIL_RECEIVER_PASSWORD undefined"
        exit 1
    fi

    # Set workdir
    cd /opt/bitnami/redmine

    # Configuring Database connection
    if [ $REDMINE_DB_MYSQL ]; then
    cat <<END > config/database.yml
        production:
            adapter: mysql2
            database: <%= ENV["REDMINE_MAIL_RECEIVER_DB_DATABASE"] %>
            host: <%= ENV["REDMINE_MAIL_RECEIVER_DB_MYSQL"] %>
            username: <%= ENV["REDMINE_MAIL_RECEIVER_DB_USERNAME"] %>
            password: <%= ENV["REDMINE_MAIL_RECEIVER_DB_PASSWORD"] %>
            port: <%= ENV["REDMINE_MAIL_RECEIVER_DB_PORT"] %>
            encoding: utf8

        test: 
            adapter: postgresql
            database: <%= ENV["REDMINE_MAIL_RECEIVER_DB_DATABASE"] %>
            host: <%= ENV["REDMINE_MAIL_RECEIVER_DB_POSTGRES"] %>
            username: <%= ENV["REDMINE_MAIL_RECEIVER_DB_USERNAME"] %>
            password: <%= ENV["REDMINE_MAIL_RECEIVER_DB_PASSWORD"] %>
            port: <%= ENV["REDMINE_MAIL_RECEIVER_DB_PORT"] %>
            encoding: utf8
    END
    elif [ $REDMINE_DB_POSTGRES ]; then
    cat <<END > config/database.yml
        test:
            adapter: mysql2
            database: <%= ENV["REDMINE_MAIL_RECEIVER_DB_DATABASE"] %>
            host: <%= ENV["REDMINE_MAIL_RECEIVER_DB_MYSQL"] %>
            username: <%= ENV["REDMINE_MAIL_RECEIVER_DB_USERNAME"] %>
            password: <%= ENV["REDMINE_MAIL_RECEIVER_DB_PASSWORD"] %>
            port: <%= ENV["REDMINE_MAIL_RECEIVER_DB_PORT"] %>
            encoding: utf8

        production: 
            adapter: postgresql
            database: <%= ENV["REDMINE_MAIL_RECEIVER_DB_DATABASE"] %>
            host: <%= ENV["REDMINE_MAIL_RECEIVER_DB_POSTGRES"] %>
            username: <%= ENV["REDMINE_MAIL_RECEIVER_DB_USERNAME"] %>
            password: <%= ENV["REDMINE_MAIL_RECEIVER_DB_PASSWORD"] %>
            port: <%= ENV["REDMINE_MAIL_RECEIVER_DB_PORT"] %>
            encoding: utf8
    END
    else
        echo "No database settings given. Exiting"
        exit 1
    fi

    # Build receiver command
    COMMAND=""

    if [ "$REDMINE_MAIL_RECEIVER_PROTOCOL" = "IMAP" ]; then
        COMMAND="bundle exec rake redmine:email:receive_imap --trace "

        if [ "$REDMINE_MAIL_RECEIVER_IMAP_FOLDER" != "" ]; then
            COMMAND="$COMMAND folder=\"$REDMINE_MAIL_RECEIVER_IMAP_FOLDER\" "
        fi

        if [ "$REDMINE_MAIL_RECEIVER_IMAP_MOVE_ON_SUCCESS" != "" ]; then
            COMMAND="$COMMAND move_on_success=\"$REDMINE_MAIL_RECEIVER_IMAP_MOVE_ON_SUCCESS\" "
        fi

        if [ "$REDMINE_MAIL_RECEIVER_IMAP_MOVE_ON_FAILURE" != "" ]; then
            COMMAND="$COMMAND move_on_failure=\"$REDMINE_MAIL_RECEIVER_IMAP_MOVE_ON_FAILURE\" "
        fi    

    elif [ "$REDMINE_MAIL_RECEIVER_PROTOCOL" = "IMAP" ]; then
        COMMAND="bundle exec rake redmine:email:receive_pop3 --trace "
        
        if [ "$REDMINE_MAIL_RECEIVER_POP3_DELETE_UNPROCESSED" != "" ]; then
            COMMAND="$COMMAND delete_unprocessed=\"$REDMINE_MAIL_RECEIVER_POP3_DELETE_UNPROCESSED\" "
        fi
        
    else
        echo "Unsupported mail receive protocol. Exiting"
        exit 1
    fi

    # Add required values
    COMMAND="$COMMAND RAILS_ENV='production' \
    host=\"$REDMINE_MAIL_RECEIVER_HOST\" \
    port=\"$REDMINE_MAIL_RECEIVER_PORT\" \
    username=\"$REDMINE_MAIL_RECEIVER_USERNAME\" \
    password=\"$REDMINE_MAIL_RECEIVER_PASSWORD\" "


    # Add optional values
    if [ "$REDMINE_MAIL_RECEIVER_USE_SSL" ]; then
        COMMAND="$COMMAND ssl=\"$REDMINE_MAIL_RECEIVER_USE_SSL\" "
    fi

    if [ -z "$REDMINE_MAIL_RECEIVER_STARTTLS" -a "$REDMINE_MAIL_RECEIVER_STARTTLS" ]; then
        COMMAND="$COMMAND starttls=\"$REDMINE_MAIL_RECEIVER_STARTTLS\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_UNKNOWN_USER_ACTION" != "" ]; then
        COMMAND="$COMMAND unknown_user=\"$REDMINE_MAIL_RECEIVER_UNKNOWN_USER_ACTION\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_NO_PERMISSION_CHECK" != "" ]; then
        COMMAND="$COMMAND no_permission_check=\"$REDMINE_MAIL_RECEIVER_NO_PERMISSION_CHECK\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_NO_ACCOUNT_NOTICE" != "" ]; then
        COMMAND="$COMMAND no_account_notice=\"$REDMINE_MAIL_RECEIVER_NO_ACCOUNT_NOTICE\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_DEFAULT_GROUP" != "" ]; then
        COMMAND="$COMMAND default_group=\"$REDMINE_MAIL_RECEIVER_DEFAULT_GROUP\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_PROJECT" != "" ]; then
        COMMAND="$COMMAND project=\"$REDMINE_MAIL_RECEIVER_PROJECT\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_PROJECT_FROM_SUBADDRESS" != "" ]; then
        COMMAND="$COMMAND  project_from_subaddress=\"$REDMINE_MAIL_RECEIVER_PROJECT_FROM_SUBADDRESS\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_STATUS" != "" ]; then
        COMMAND="$COMMAND status=\"$REDMINE_MAIL_RECEIVER_STATUS\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_TRACKER" != "" ]; then
        COMMAND="$COMMAND tracker=\"$REDMINE_MAIL_RECEIVER_TRACKER\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_CATEGORY" != "" ]; then
        COMMAND="$COMMAND category=\"$REDMINE_MAIL_RECEIVER_CATEGORY\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_PRIORITY" != "" ]; then
        COMMAND="$COMMAND priority=\"$REDMINE_MAIL_RECEIVER_PRIORITY\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_ASSIGNED_TO" != "" ]; then
        COMMAND="$COMMAND assigned_to=\"$REDMINE_MAIL_RECEIVER_ASSIGNED_TO\" "
    fi

    if [ "$REDMINE_MAIL_RECEIVER_ALLOW_OVERRIDE" != "" ]; then
        COMMAND="$COMMAND allow_override=\"$REDMINE_MAIL_RECEIVER_ALLOW_OVERRIDE\" "
    fi

    if [ $REDMINE_MAIL_RECEIVER_DEBUG ]; then 
        echo "Unsecure printing mail receiving command"
        echo $COMMAND
        echo ""
    fi

    # Configuring secrets
    cat <<END > config/secrets.yml
        development:
            secret_key_base:

        test:
            secret_key_base:

        production:
            secret_key_base: <%= ENV["REDMINE_MAIL_RECEIVER_SECRET_KEY_BASE"] %>
    END

    echo "Start rake receive email process"

    # Execute command
    eval $COMMAND
    echo "Email receiveing completed"

    exit 0
{{- end -}}
 # pdb.yaml
{{- if .Values.podDisruptionBudget.enabled }}
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  name: {{ template "redmine.fullname" . }}
  labels: {{- include "redmine.labels" . | nindent 4 }}
spec:
  {{- if .Values.podDisruptionBudget.minAvailable }}
  minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
  {{- end }}
  {{- if .Values.podDisruptionBudget.maxUnavailable }}
  maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
  {{- end }}
  selector:
    matchLabels: {{- include "redmine.matchLabels" . | nindent 6 }}
{{- end }}
 # pvc.yaml
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: {{ template "redmine.fullname" . }}
  labels: {{- include "redmine.labels" . | nindent 4 }}
spec:
  accessModes:
    - {{ .Values.persistence.accessMode | quote }}
  resources:
    requests:
      storage: {{ .Values.persistence.size | quote }}
  {{ include "redmine.storageClass" . }}
{{- end }}
 # secrets.yaml
{{- if (not .Values.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "redmine.fullname" . }}
  labels: {{- include "redmine.labels" . | nindent 4 }}
type: Opaque
data:
  {{- if .Values.redminePassword }}
  redmine-password: {{ default "" .Values.redminePassword | b64enc | quote }}
  {{- else }}
  redmine-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  smtp-password: {{ default "" .Values.smtpPassword | b64enc | quote }}
  {{- if or (and (eq .Values.databaseType "mariadb") (not .Values.mariadb.enabled)) (and (eq .Values.databaseType "postgresql") (not .Values.postgresql.enabled)) }}
  {{- if .Values.externalDatabase.password }}
  external-db-password: {{ default "" .Values.externalDatabase.password | b64enc | quote }}
  {{- else }}
  external-db-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  {{- end }}
  {{- if and .Values.mailReceiver.enabled .Values.mailReceiver.password }}
  mail-receiver-password: {{ default "" .Values.mailReceiver.password | b64enc | quote }}
  {{- end }}
{{- end }}
 # serviceaccount.yaml
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ template "redmine.serviceAccountName" . }}
  labels: {{- include "redmine.labels" . | nindent 4 }}
{{- end }}
 # svc.yaml
apiVersion: v1
kind: Service
metadata:
  name: {{ template "redmine.fullname" . }}
  labels: {{- include "redmine.labels" . | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  {{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }}
  externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
  {{- end }}
  {{ if eq .Values.service.type "LoadBalancer" }}
  loadBalancerSourceRanges: {{ .Values.service.loadBalancerSourceRanges }}
  {{ end }}
  {{- if (and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP))) }}
  loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  {{- end }}
  ports:
    - name: http-redmine
      port: {{ .Values.service.port }}
      targetPort: http-redmine
      {{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.http)))}}
      nodePort: {{ .Values.service.nodePorts.http }}
      {{- end }}
  selector: {{- include "redmine.matchLabels" . | nindent 4 }}
 # tls-secrets.yaml
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.secrets }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ .name }}
  labels: {{- include "redmine.labels" . | nindent 4 }}
type: kubernetes.io/tls
data:
  tls.crt: {{ .certificate | b64enc }}
  tls.key: {{ .key | b64enc }}
---
{{- end }}
{{- end }}

## Global Docker image parameters
## Please, note that this will override the image parameters, including dependencies, configured to use the global value
## Current available global Docker image parameters: imageRegistry and imagePullSecrets
##
# global:
#   imageRegistry: myRegistryName
#   imagePullSecrets:
#     - myRegistryKeySecretName
#   storageClass: myStorageClass

## Bitnami Redmine image version
## ref: https://hub.docker.com/r/bitnami/redmine/tags/
##
image:
  registry: docker.io
  repository: bitnami/redmine
  tag: 4.1.0-debian-10-r25
  ## Specify a imagePullPolicy
  ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
  ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
  ##
  pullPolicy: IfNotPresent
  ## Optionally specify an array of imagePullSecrets.
  ## Secrets must be manually created in the namespace.
  ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
  ##
  # pullSecrets:
  #   - myRegistryKeySecretName

## String to partially override redmine.fullname template (will maintain the release name)
##
# nameOverride:

## String to fully override redmine.fullname template
##
# fullnameOverride:

## User of the application
## ref: https://github.com/bitnami/bitnami-docker-redmine/#environment-variables
##
redmineUsername: user

## Application password
## Defaults to a random 10-character alphanumeric string if not set
## ref: https://github.com/bitnami/bitnami-docker-redmine#environment-variables
##
# redminePassword:

## Admin email
## ref: https://github.com/bitnami/bitnami-docker-redmine/#environment-variables
##
redmineEmail: user@example.com

## Redmine default data language
## ref: https://github.com/bitnami/bitnami-docker-redmine/#environment-variables
##
redmineLanguage: en

## SMTP mail delivery configuration
## ref: https://github.com/bitnami/bitnami-docker-redmine/#smtp-configuration
##
# smtpHost:
# smtpPort:
# smtpUser:
# smtpPassword:
# smtpTls:

## Use an existing secret with keys "redmine-password", "smtp-password" and "external-db-password" defined.
## This ignores redminePassword, smtpPassword and externalDatabase.password
# existingSecret:

## Environment variables, to pass to the entry point
##
# extraVars:
#   - name: NAMI_DEBUG
#     value: --log-level trace

## Define a disruption budget
## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/
##
podDisruptionBudget:
  enabled: false
  # minAvailable: 1
  # maxUnavailable: 1

## Define the number of pods the deployment will create
## Do not change unless your persistent volume allows more than one writer, ie NFS
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
##
replicas: 1

## Redmine containers' resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
resources:
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  limits: {}
  #  cpu: 2
  #  memory: 1Gi
  requests: {}
  #  cpu: 1
  #  memory: 1Gi

## Pods Service Account
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
##
serviceAccount:
  ## Specifies whether a ServiceAccount should be created
  ##
  create: true
  ## The name of the ServiceAccount to use.
  ## If not set and create is true, a name is generated using the redmine.fullname template
  # name:

## Pod Security Context
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
##
securityContext: {}

## Pod annotations
## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/
##
podAnnotations: {}

## Affinity for pod assignment
## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
##
affinity: {}

## Node labels for pod assignment. Evaluated as a template.
## Ref: https://kubernetes.io/docs/user-guide/node-selection/
##
nodeSelector: {}

## Tolerations for pod assignment
## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
##
tolerations: []

## Configure extra options for liveness and readiness probes
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes)
##
livenessProbe:
  enabled: true
  initialDelaySeconds: 300
  periodSeconds: 10
  timeoutSeconds: 5
  successThreshold: 1
  failureThreshold: 3
readinessProbe:
  enabled: true
  initialDelaySeconds: 5
  periodSeconds: 10
  timeoutSeconds: 1
  successThreshold: 1
  failureThreshold: 3

## Enable persistence using Persistent Volume Claims
## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
##
persistence:
  enabled: true
  ## A manually manage Persistent Volume Claim
  ## Requires persistence.enable: true
  ## If defined, PVC must be created manually before volume will be bound
  # existingClaim:

  ## redmine data Persistent Volume Storage Class
  ## If defined, storageClassName: <storageClass>
  ## If set to "-", storageClassName: "", which disables dynamic provisioning
  ## If undefined (the default) or set to null, no storageClassName spec is
  ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
  ##   GKE, AWS & OpenStack)
  ##
  # storageClass: "-"
  accessMode: ReadWriteOnce
  size: 8Gi

## Database type. Allowed values: "mariadb" and "postgresql"
## ref: https://github.com/bitnami/bitnami-docker-redmine#run-the-application-using-postgresql-database
##
databaseType: mariadb

## MariaDB chart configuration
##
## https://github.com/helm/charts/blob/master/stable/mariadb/values.yaml
##
mariadb:
  ## Whether to deploy a mariadb server to satisfy the applications database requirements. To use an external database set this to false and configure the externalDatabase parameters
  enabled: true
  ## Disable MariaDB replication
  replication:
    enabled: false

  ## Create a database and a database user
  ## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#creating-a-database-user-on-first-run
  ##
  db:
    name: bitnami_redmine
    user: bn_redmine
    ## If the password is not specified, mariadb will generate a random password
    ##
    # password:

  ## MariaDB admin password
  ## ref: https://github.com/bitnami/bitnami-docker-mariadb/blob/master/README.md#setting-the-root-password-on-first-run
  ##
  # rootUser:
  #   password:

  ## Enable persistence using Persistent Volume Claims
  ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
  ##
  master:
    persistence:
      enabled: true
      ## mariadb data Persistent Volume Storage Class
      ## If defined, storageClassName: <storageClass>
      ## If set to "-", storageClassName: "", which disables dynamic provisioning
      ## If undefined (the default) or set to null, no storageClassName spec is
      ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
      ##   GKE, AWS & OpenStack)
      ##
      # storageClass: "-"
      accessMode: ReadWriteOnce
      size: 8Gi

## PostgreSQL chart configuration
##
## https://github.com/helm/charts/blob/master/stable/postgresql/values.yaml
##
postgresql:
  ## Whether to deploy a PostgreSQL server to satisfy the applications database requirements. To use an external database set this to false and configure the externalDatabase parameters
  enabled: false

  ## Create a database and a database user
  ## ref: https://github.com/bitnami/bitnami-docker-postgresql/#creating-a-database-on-first-run
  ##
  postgresqlDatabase: bitnami_redmine
  postgresqlUsername: bn_redmine
  ##
  ## If the password is not specified, postgresql will generate a random password
  # postgresqlPassword:

  ## Enable persistence using Persistent Volume Claims
  ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
  ##
  persistence:
    enabled: true
    ## A manually manage Persistent Volume Claim
    ## Requires postgresql.persistence.enable: true
    ## If defined, PVC must be created manually before volume will be bound
    # existingClaim:

    ## postgresql data Persistent Volume Storage Class
    ## If defined, storageClassName: <storageClass>
    ## If set to "-", storageClassName: "", which disables dynamic provisioning
    ## If undefined (the default) or set to null, no storageClassName spec is
    ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
    ##   GKE, AWS & OpenStack)
    ##
    # storageClass: "-"
    accessMode: ReadWriteOnce
    size: 8Gi

## All of these values are only used when:
## a) mariadb.enabled is set to false and databaseType=mariadb
## b) postgresql.enabled is set to false and databaseType=postgresql
externalDatabase:
  ## Database host
  host: localhost

  ## Database name
  name: database

  ## Database User
  user: user

  ## Database Password
  password: ""

  ## Database port number (use 5432 when using PostgreSQL)
  port: 3306

## Kubernetes configuration
##   minikube: NodePort
##   ingress: ClusterIP
##   elsewhere: LoadBalancer
##
service:
  type: LoadBalancer
  # HTTP Port
  port: 80
  ## loadBalancerIP:
  ## Control hosts connecting to "LoadBalancer" only
  loadBalancerSourceRanges:
    - 0.0.0.0/0
  ##
  ## nodePorts:
  ##   http: <to set explicitly, choose port between 30000-32767>
  nodePorts:
    http: ""
  ## Enable client source IP preservation
  ## ref http://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip
  ##
  externalTrafficPolicy: Cluster

## Configure the ingress resource that allows you to access the
## Redmine installation. Set up the URL
## ref: http://kubernetes.io/docs/user-guide/ingress/
##
ingress:
  ## Set to true to enable ingress record generation
  ##
  enabled: false

  ## Set this to true in order to add the corresponding annotations for cert-manager
  ##
  certManager: false

  ## When the ingress is enabled, a host pointing to this will be created
  ##
  hostname: redmine.local

  ## Enable TLS configuration for the hostname defined at ingress.hostname parameter
  ## TLS certificates will be retrieved from a TLS secret with name: {{- printf "%s-tls" .Values.ingress.hostname }}
  ## You can use the ingress.secrets parameter to create this TLS secret or relay on cert-manager to create it
  ##
  tls: false

  ## Ingress annotations done as key:value pairs
  ## For a full list of possible ingress annotations,
  ## please see https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/annotations.md
  ##
  ## If certManager is set to true, annotation kubernetes.io/tls-acme: "true" will automatically be set
  ##
  annotations:
    # kubernetes.io/ingress.class: nginx
    ## Keep the connection open with the API server even if idle (the default is 60 seconds)
    ## Setting it to 10 minutes which should be enough for our current use case of deploying/upgrading/deleting apps
    ##
    nginx.ingress.kubernetes.io/proxy-read-timeout: "600"

  ## The list of additional hostnames to be covered with this ingress record.
  ## Most likely the hostname above will be enough, but in the event more hosts are needed, this is an array
  ## extraHosts:
  ## - name: redmine.local
  ##   path: /

  ## The tls configuration for additional hostnames to be covered with this ingress record.
  ## see: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls
  ## extraTls:
  ## - hosts:
  ##     - redmine.local
  ##   secretName: redmine.local-tls

  ## If you're providing your own certificates, please use this to add the certificates as secrets
  ## key and certificate should start with -----BEGIN CERTIFICATE----- or
  ## -----BEGIN RSA PRIVATE KEY-----
  ##
  ## name should line up with a tlsSecret set further up
  ## If you're using cert-manager, this is unneeded, as it will create the secret for you if it is not set
  ##
  ## It is also possible to create and manage the certificates outside of this helm chart
  ## Please see README.md for more information
  ##
  secrets: []
  ## - name: redmine.local-tls
  ##   key:
  ##   certificate:

## Configure CronJob scheduler for receiveing emails and converting them to tasks
## ref: http://www.redmine.org/projects/redmine/wiki/RedmineReceivingEmails
##
mailReceiver:
  ## Whether to enable scheduled task
  enabled: false

  ## CronJob schedule
  schedule: "*/5 * * * *"

  ## CronJob suspend flag
  suspend: true

  image:
    registry: docker.io
    repository: bitnami/redmine
    tag: 4.0.5-debian-9-r28
    ## Specify a imagePullPolicy
    ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
    ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
    ##
    pullPolicy: IfNotPresent

  ## Protocol to use to get emails from configured server.
  ## Supported values are "IMAP" or "POP3"
  mailProtocol: IMAP

  ## Server hostname to connect to
  host: ""

  ## Server TCP port to connect to
  port: 993

  ## Username to authenticate on server
  username: ""

  ## Password to authenticate on server
  password: ""

  ## ssl flag for redmine mail client
  ## If true then client will use SSL/TLS
  ssl: true

  ## starttls flag for redmine mail client
  ## If true then client will use StartTLS
  startTLS: false

  ## IMAP only. Folder to read emails from
  imapFolder: "INBOX"

  ## Folder on mail server to move correctly parsed emails to
  ## If empty - just leave emails as read
  moveOnSuccess: ""

  ## Folder on mail server to move emails with parsing errors to
  ## If empty - just leave emails as read
  moveOnFailure: ""

  ## Action to perform for unknown email sender
  ## ref: http://www.redmine.org/projects/redmine/wiki/RedmineReceivingEmails
  unknownUserAction: ingore

  ## If set to 1 then redmine does not check task creator (source email) permissions for creating a new task
  ## If set to 0 then task creator must have permission to create a new task
  noPermissionCheck: 0

  ## Whether send a just created user (the creator of the task) email about his new account
  ## 0 - send, 1 - not send
  noAccountNotice: 1

  ## Defines a group list to add created user to
  ## Groups must be enumerated as names separated by comma without spaces
  defaultGroup: ""

  ## Defines a project to create a new task in
  project: ""

  ## Defines an email to use as a base for getting project name for a new task
  projectFromSubaddress: ""

  ## Defines a new task status
  status: ""

  ## Defines a new task tracker
  tracker: ""

  ## Defines a new task category
  category: ""

  ## Defines a new task priority
  priority: ""

  ## Defines a new task assignee
  assignedTo: ""

  ## Defines a list of attributes which can be overrided by received email body
  ## "all" means that all attributes can be overrided
  allowOverride: ""
