apiVersion: v1
kind: Service
metadata:
  name: {{ include "gitea-mirror.fullname" . }}
  labels:
    {{- include "gitea-mirror.labels" . | nindent 4 }}
    {{- if .Values.service.labels }}
      {{- toYaml .Values.service.labels  | nindent 4 }}
    {{- end }}
  annotations:
    {{- toYaml .Values.service.annotations | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  {{- if eq .Values.service.type "LoadBalancer" }}
  {{- if .Values.service.loadBalancerClass }}
  loadBalancerClass: {{ .Values.service.loadBalancerClass }}
  {{- end }}
  {{- if and .Values.service.loadBalancerIP }}
  loadBalancerIP: {{ .Values.service.loadBalancerIP  }}
  {{- end }}
  {{- end }}
  {{- if .Values.service.externalTrafficPolicy }}
  externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
  {{- end }}
  {{- if and .Values.service.clusterIP (eq .Values.service.type "ClusterIP") }}
  clusterIP: {{ .Values.service.clusterIP }}
  {{- end }}
  ports:
    - name: http
      port: {{ .Values.service.port }}
      protocol: TCP
      targetPort: http
  selector:
    {{- include "gitea-mirror.selectorLabels" . | nindent 4 }}
