{{- if .Values.imaginary.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "nextcloud.fullname" . }}-imaginary
  labels:
    {{- include "nextcloud.labels"  ( dict "component" "imaginary"  "rootContext" $ ) | nindent 4 }}
spec:
  replicas: {{ .Values.imaginary.replicaCount }}
  selector:
    matchLabels:
      {{- include "nextcloud.selectorLabels"  ( dict "component" "imaginary"  "rootContext" $ ) | nindent 6 }}
  template:
    metadata:
      annotations:
        {{- toYaml .Values.imaginary.podAnnotations | nindent 8 }}
      labels:
        {{- include "nextcloud.selectorLabels"  ( dict "component" "imaginary"  "rootContext" $ ) | nindent 8 }}
        {{- with .Values.imaginary.podLabels }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
    spec:
      {{- with .Values.imaginary.image.pullSecrets }}
      imagePullSecrets:
        {{- range . }}
        - name: {{ . }}
        {{- end}}
      {{- end }}
      containers:
        - name: imaginary
          {{- with .Values.imaginary.image }}
          image: "{{ .registry }}/{{ .repository }}:{{ .tag }}"
          imagePullPolicy: {{ .pullPolicy }}
          {{- end }}
          env:
            - name: PORT
              value: "9000"
          ports:
            - name: http
              containerPort: 9000
          {{- with .Values.imaginary.readinessProbe }}
          {{- if .enabled }}
          readinessProbe:
            httpGet:
              path: /health
              port: http
              scheme: HTTP
            failureThreshold: {{ .failureThreshold }}
            successThreshold: {{ .successThreshold }}
            periodSeconds: {{ .periodSeconds }}
            timeoutSeconds: {{ .timeoutSeconds }}
          {{- end }}
          {{- end }}
          {{- with .Values.imaginary.livenessProbe }}
          {{- if .enabled }}
          livenessProbe:
            httpGet:
              path: /health
              port: http
              scheme: HTTP
            failureThreshold: {{ .failureThreshold }}
            successThreshold: {{ .successThreshold }}
            periodSeconds: {{ .periodSeconds }}
            timeoutSeconds: {{ .timeoutSeconds }}
          {{- end }}
          {{- end }}
          {{- with .Values.imaginary.resources }}
          resources:
            {{- toYaml . | nindent 12 }}
          {{- end }}
          {{- with .Values.imaginary.securityContext }}
          securityContext:
            {{- toYaml . | nindent 12 }}
          {{- end }}
      {{- with .Values.imaginary.podSecurityContext }}
      securityContext:
        {{- toYaml . | nindent 12 }}
      {{- end }}
      {{- with .Values.imaginary.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.imaginary.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
{{- end }}
