(calico) Add network policy safety valve

- If a rule set in the network policy override for the calico
  chart is empty, it causes the calico-settings job to fail. This
  safety valve should handle the empty list gracefully.

Change-Id: I4b8a39941f05a8eb86734ff129b2d73830883236
This commit is contained in:
Scott Hussey 2018-12-20 11:01:31 -06:00
parent 4233c25308
commit 048b18a50f

View File

@ -75,10 +75,15 @@ EOF
# Priority: {{ $n }} objects
{{- range $section, $data := $envAll.Values.networking.policy }}
{{- if eq (toString $data.priority) (toString $n) }}
{{/* add a safety check so we don't attempt to run calicoctl with an empty resource set */}}
{{- if gt (len $data.rules) 0 }}
# Section: {{ $section }} Priority: {{ $data.priority }} {{ $n }}
$CTL apply -f - <<EOF
{{ $data.rules | toYaml }}
EOF
{{- else }}
echo "Skipping empty rules list."
{{- end }}
{{- end }}
{{- end }}
{{- end }}