{{- if index .Values "argo-cd" "istio" "enabled" }}
{{- if index .Values "argo-cd" "istio" "ipBlocks" }}
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
  name: argocd-deny-not-in-ipblocks
  namespace: istio-system
  labels:
{{ include "kubezero-lib.labels" . | indent 4 }}
spec:
  selector:
    matchLabels:
      app: istio-ingressgateway
  action: DENY
  rules:
  - from:
    - source:
        notIpBlocks:
        {{- with index .Values "argo-cd" "istio" "ipBlocks" }}
        {{- . | toYaml | nindent 8 }}
        {{- end }}
    to:
    - operation:
        hosts: ["{{ index .Values "argo-cd" "server" "config" "url" }}"]
{{- end }}
{{- end }}