{{- if and .Values.webhook.enabled .Values.webhook.networkPolicy.enabled -}}
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  name: {{ include "snapshot-validation-webhook.fullname" . }}
  labels:
    {{- include "snapshot-validation-webhook.labels" . | nindent 4 }}
spec:
  podSelector:
    matchLabels:
      {{- include "snapshot-validation-webhook.selectorLabels" . | nindent 6 }}
  ingress:
    - from:
      - podSelector:
          matchLabels:
            {{- include "snapshot-validation-webhook.selectorLabels" . | nindent 12 }}
    {{- with .Values.webhook.networkPolicy.ingress }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
{{- end -}}
