{{- $operatorValues :=  index .Values "reporting-operator" -}}
kind: Service
apiVersion: v1
metadata:
  name: reporting-operator
  labels:
    app: reporting-operator
    component: reporting-operator
{{- if $operatorValues.spec.apiService.annotations }}
  annotations:
{{ toYaml $operatorValues.spec.apiService.annotations | indent 4 }}
{{- end }}
spec:
  type: "{{ $operatorValues.spec.apiService.type }}"
  selector:
    app: reporting-operator
  ports:
  - name: api
    port: 8080
{{- if $operatorValues.spec.authProxy.enabled }}
    targetPort: auth-proxy
{{- else }}
    targetPort: api
{{- end }}
{{- if and (eq (lower $operatorValues.spec.apiService.type) "nodeport" "loadbalancer") $operatorValues.spec.apiService.nodePort }}
    nodePort: {{ $operatorValues.spec.apiService.nodePort }}
{{- end }}
  - name: metrics
    port: 8082
    targetPort: metrics
