apiVersion: v1
kind: Service
metadata:
  name: {{ template "gogs.fullname" . }}
  labels:
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
{{- if .Values.service.annotations }}
  annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
spec:
  type: {{ .Values.serviceType }}
  {{- if and (eq .Values.serviceType "LoadBalancer") .Values.service.loadBalancerIP }}
  loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  {{- end }}
  ports:
  - port: {{ .Values.service.httpPort | int }}
    targetPort: 3000
{{- if (and (eq .Values.serviceType "NodePort") (not (empty .Values.service.httpNodePort))) }}
    nodePort: {{ .Values.service.httpNodePort | int }}
{{- end }}
    name: {{ default "gogs" .Values.service.nameOverride }}-http
  - port: {{ .Values.service.sshPort | int }}
    targetPort: 22
{{- if (and (eq .Values.serviceType "NodePort") (not (empty .Values.service.sshNodePort))) }}
    nodePort: {{ .Values.service.sshNodePort | int }}
{{- end }}
    name: {{ default "gogs" .Values.service.nameOverride }}-ssh
  selector:
    app: {{ template "gogs.fullname" . }}
