{{- if and (eq .Values.global.platform "openshift") (eq .Values.global.openshift.deploymentType "deploymentConfigs")}}
{{- if .Values.gerrit.deploy -}}
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  labels:
    app: {{ .Values.gerrit.name }}
    {{- include "gerrit-operator.labels" . | nindent 4 }}
  {{- with .Values.gerrit.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  name: {{ .Values.gerrit.name }}
spec:
  replicas: 1
  selector:
    app: {{ .Values.gerrit.name }}
  strategy:
    activeDeadlineSeconds: 21600
    recreateParams:
      timeoutSeconds: 6000
    resources: {}
    type: Recreate
  template:
    metadata:
      labels:
        app: {{ .Values.gerrit.name }}
    spec:
      {{- if .Values.gerrit.imagePullSecrets}}
      imagePullSecrets:
        {{- range .Values.gerrit.imagePullSecrets }}
        - {{. -}}
        {{- end -}}
      {{end}}
      containers:
        - env:
            - name: HTTPD_LISTENURL
              value: 'proxy-https://*:8080'
            - name: WEBURL
              value: https://{{if .Values.gerrit.basePath}}{{.Values.global.dnsWildCard}}{{else}}gerrit-{{ .Release.Namespace }}.{{.Values.global.dnsWildCard}}{{end}}
            - name: GERRIT_INIT_ARGS
              value: '--install-plugin=delete-project --install-plugin=plugin-manager --install-plugin=commit-message-length-validator --install-plugin=download-commands
                        --install-plugin=hooks --install-plugin=reviewnotes --install-plugin=singleusergroup --install-plugin=replication --install-plugin=webhooks'
            {{- with .Values.gerrit.extraEnv }}
              {{- toYaml . | nindent 12 }}
            {{- end }}
          image: {{.Values.gerrit.image}}:{{.Values.gerrit.version}}
          imagePullPolicy: "{{ .Values.gerrit.imagePullPolicy }}"
          name: {{ .Values.gerrit.name }}
          ports:
            - containerPort: {{ .Values.gerrit.port }}
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /
              port: {{ .Values.gerrit.port }}
              scheme: HTTP
            initialDelaySeconds: 60
            periodSeconds: 20
            successThreshold: 1
            timeoutSeconds: 5
          resources:
            requests:
              memory: 500Mi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /var/gerrit/review_site
              name: {{ .Values.gerrit.name }}-data
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: {{ .Values.gerrit.name }}
      serviceAccountName: {{ .Values.gerrit.name }}
      terminationGracePeriodSeconds: 30
      volumes:
        - name: {{ .Values.gerrit.name }}-data
          persistentVolumeClaim:
            claimName: {{ .Values.gerrit.name }}-data
      {{- with .Values.gerrit.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.gerrit.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.gerrit.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
  test: false
  triggers:
    - type: ConfigChange
{{- end -}}
{{- end -}}
