{{- if .Values.sourceController.create }}
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/instance: {{ .Release.Namespace | quote }}
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/version: {{ .Chart.AppVersion | quote  }}
    app.kubernetes.io/part-of: flux
    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    control-plane: controller
    {{- with .Values.sourceController.service.labels }}{{ toYaml . | nindent 4 }}{{ end }}
  name: source-controller
  {{- with .Values.sourceController.service.annotations }}
  annotations: {{ toYaml . | nindent 4 }}
  {{- end }}
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: http
  {{- if .Values.sourceController.service.ports }}
  {{- toYaml .Values.sourceController.service.ports | nindent 2 }}
  {{- end}}
  selector:
    app: source-controller
  type: ClusterIP
{{- end }}
