{{- if .Values.networkPolicies.enabled }}
{{- range $key, $value := .Values.networkPolicies -}}
{{- if and (not (eq $key "enabled")) $value.enabled }}
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  {{- with (include "prometheus-fail2ban-exporter.networkPolicies.annotations" (dict "networkPolicy" $value "context" $) | fromYaml) }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  {{- with (include "prometheus-fail2ban-exporter.networkPolicies.labels" (dict "networkPolicy" $value "context" $) | fromYaml) }}
  labels:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  name: {{ printf "%s-%s" (include "prometheus-fail2ban-exporter.fullname" $ ) $key }}
  namespace: {{ $.Release.Namespace }}
spec:
  podSelector:
    matchLabels:
      {{- include "prometheus-fail2ban-exporter.pod.selectorLabels" $ | nindent 6 }}
  {{- with $value.policyTypes }}
  policyTypes:
  {{- toYaml . | nindent 2 }}
  {{- end }}
  {{- with $value.egress }}
  egress:
  {{- toYaml . | nindent 2 }}
  {{- end }}
  {{- with $value.ingress }}
  ingress:
  {{- toYaml . | nindent 2 }}
  {{- end }}
{{- end }}
{{- end }}
{{- end }}