_validation.tpl 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. {{- define "sftgo.validation" -}}
  2. {{- $ports := list -}}
  3. {{- $ports = append $ports .Values.sftpgoNetwork.webPort -}}
  4. {{- range $k, $v := .Values.sftpgoNetwork -}}
  5. {{- if (hasSuffix "Services" $k) -}}
  6. {{- range $idx, $svc := $v -}}
  7. {{- if $svc.enabled -}}
  8. {{- $ports = append $ports $svc.port -}}
  9. {{- end -}}
  10. {{- end -}}
  11. {{- end -}}
  12. {{- end -}}
  13. {{- if gt (len $ports) 20 -}} {{/* Arbitrary limit, to avoid overallocating ports */}}
  14. {{- fail (printf "SFTPGo - Too many ports defined, max 20 ports can be defined [%s]" (join ", " $ports)) -}}
  15. {{- end -}}
  16. {{- if not (deepEqual ($ports | uniq) $ports) -}}
  17. {{- fail (printf "SFTPGo - Expected ports to be unique for all services, ports defined [%s]" (join ", " $ports)) -}}
  18. {{- end -}}
  19. {{- if .Values.sftpgoNetwork.ftpdServices -}}
  20. {{- with .Values.sftpgoNetwork.ftpdPassivePortRange -}}
  21. {{- if ge (int .start) (int .end) -}}
  22. {{- fail (printf "SFTPGo - ftpd passive port range start [%d] must be less than end [%d]" (int .start) (int .end)) -}}
  23. {{- end -}}
  24. {{- if ge (sub (int .end) (int .start)) 20 -}} {{/* Arbitrary limit, to avoid overallocating ports */}}
  25. {{- fail (printf "SFTPGo - ftpd passive port range must be less than 20 ports, start [%d] end [%d]" (int .start) (int .end)) -}}
  26. {{- end -}}
  27. {{- end -}}
  28. {{- end -}}
  29. {{- end -}}